25.02.2013 Views

Peter Lubbers - Pro HTML 5 Programming

Pro HTML 5 Programming

Pro HTML 5 Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 6 ■ USING THE <strong>HTML</strong>5 WEBSOCKET API<br />

Next, open another command prompt, navigate to the folder that contains the WebSocket code, and<br />

issue the following command to run the Python WebSocket server:<br />

python websocket.py<br />

Finally, open a browser that supports WebSockets natively and navigate to<br />

http://localhost:9999/websocket.html.<br />

Figure 6-6 shows the web page in action.<br />

Figure 6-6. websocket.html in action<br />

The example code folder also contains a web page that connects to the broadcast service that was<br />

created in the previous section. To see that action, close the command prompt that is running the<br />

WebSocket server and navigate to the folder that contains the WebSocket code, and issue the following<br />

command to run the python WebSocket server.<br />

python broadcast.py<br />

Open two separate browsers that supports WebSockets natively and navigate (in each browser) to<br />

http://localhost:9999/broadcast.html.<br />

Figure 6-7 shows the broadcast WebSocket server in action on two separate web pages.<br />

157

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!