websocket-server – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 Thanks to help from the following websites:
2  
3 Step by step guide
4 https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers
5  
6 The official Web Socket spec
7 http://tools.ietf.org/html/rfc6455
8  
9 Some useful stuff in c#
10 https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_server
11  
12 Web Socket Protocol 13 (and above) supported
13  
14 To run:
15 Run the console application
16 NOTE You will get a firewall warning because you are listening on a port. This is normal for any socket based server.
17 The console application will run a self test so you can see if anything is wrong. The self test will open a connection, perform the open handshake, send a message, receive a response and start the close handshake and disconnect.
18  
19 If the self test is a success then the following should work too:
20 Open a browser and enter: http://localhost/client.html
21 The web server will then serve up the web page requested (client.html),
22 The javascript in that webpage will execute and attempt to make a WebSocket connection to that same server and port (80)
23 At this point the webserver will upgrade the connection to a web socket connection and you can chat with the server
24 If you want to access this from another machine then make sure your firewall is not blocking the port
25  
26 Note:
27 A lot of the Web Socket examples out there are for old Web Socket versions and included complicated code for fall back communication.
28 All modern browsers (including safari on an iphone) support at least version 13 of the Web Socket protocol so I'd rather not complicate things.
29 This application serves up basic html pages as well as handling WebSocket connections.
30 This may seem confusing but it allows you to send the client the html they need to make a web socket connection and also allows you to share the same port
31 However, the HttpConnection is very rudimentary. I'm sure it has some glaring security problems. It was just made to make this demo easier to run. Replace it with your own or dont use it.
32  
33 Debugging:
34 A good place to put a breakpoint is in the WebServer class in the HandleAsyncConnection function.
35 Note that this is a multithreaded server to you may want to freeze threads if this gets confusing. The console output prints the thread id to make things easier
36 If you want to skip past all the plumbing then another good place to start is the Respond function in the WebSocketService class
37 If you are not interested in the inner workings of Web Sockets and just want to use them then take a look at the OnTextFrame in the ChatWebSocketService class
38  
39 Problems with Proxy Servers:
40 Proxy servers which have not been configured to support Web sockets will not work well with them.
41 I suggest that you use transport layer security (SSL) if you want this to work across the wider internet especially from within a corporation
42  
43 Sub Folders:
44 You can assign different web socket handlers depending on the folder attribute of the first line of the http request
45 eg:
46 GET /chat HTTP/1.1
47 This folder has been setup to use the ChatWebSocketService class
48  
49 Change Log:
50  
51 10 Apr 2016: SSL support
52 02 Apr 2016: c# Client