For the example we are going to create we will need a few things:
- node >= 0.1.100
- http://github.com/gimite/web-socket-js
- http://github.com/miksago/node-websocket-server (npm websocket-server)
- http://github.com/senchalabs/Connect/ (npm connect)
- a port to serve files on (8000 in our example)
- port 843 on the server
Note:
- Flash websockets will not be active until the SWF is loaded, either wait for an onload or test other ways to see if the WebSocket interface is ready.
- IE 64-bit does not support Flash as of the time of this post.
Websocket Client:
web-socket-js has a sample.html file which will serve as our example of a simple publication/subscription service client. It requires WebSocketMain.swf , swfobject.js , web_socket.js , and FABridge.js . All the browser will have to do to get to this is direct to this page from HTTP:// (Flash Sockets will not work on FILE://)
The only modifications to this file that we need to do are where the WebSocket(url) is going.
- If you move WebSocketMain.swf be sure to set WEB_SOCKET_SWF_LOCATION
- You can remove WEB_SOCKET_DEBUG if you do not want messages in your console
Websocket Server:
Our server needs to do 3 things:
- Serve the files we want to make up our client
- Accept websocket connections
- Serve a policy file using TCP (Not HTTP://!)
To see all of these in action download:
0 comments:
Post a Comment