Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Practice exercises CHAPTER 10 429



  1. Test your work by running the website, using the following command in the command
    prompt window.
    node app.js


You should see the listening message, as shown in Figure 10-2.

FIGURE 10-2 he running chat serviceT

Exercise 2: Create the chat client


In this exercise, you continue with the chat service from Exercise 1 and add the chat client
code. When you’re finished with this exercise, you will have a functional chat application.


  1. Open the client website, which is different from Exercise 1. Open Visual Studio
    Express 2012 for Web. Click File, choose Open Web Site, and select the public folder
    under the chat_service.

  2. In the Solution Explorer window, right-click the public node, choose Add, and then
    select HTML Page. Name the file Index.html and click OK.

  3. In the Solution Explorer window, right-click the public node. Click Add, choose Style
    Sheet, and name the file default.css. Click OK.

  4. In the Solution Explorer window, right-click the public node, choose Add, select New
    Folder, name the folder Scripts, and click OK.

  5. In the Solution Explorer window, right-click the Scripts folder, choose Add, select
    JavaScript File, name the file default.js, and click OK.

  6. Add the jQuery library by right-clicking the public node. Choose Manage NuGet
    Packages, select Online, and type jQuery in the search box.
    You should see jQuery, as shown in Figure 10-3.

Free download pdf