View Issue Details

IDProjectCategoryView StatusLast Update
0000786LDMudNetworkingpublic2011-08-24 13:16
Reporterzesstra Assigned Tozesstra  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionwon't fix 
Summary0000786: Support for HTML5 Websockets
DescriptionHTML5 supports so-called sockets to facilitate bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket communication between browser and client. This should be an elegant solution for web-based clients to communicate with MUDs.

However, the websockets require a specific handshake in the beginning (see additionial info). It creates the TCP connection and send a HTTP header requesting the "upgrade" to a websocket. The server responds with a HTTP header confirming this. After that it is a conventional TCP socket.
http://en.wikipedia.org/wiki/WebSocket
http://de.wikipedia.org/wiki/WebSocket

LDMud might support this without an additional proxy by looking for the HTTP header in the beginning (so if the first thing the client sends, is this header), sending the confirmation and after doing the usual stuff, because it is a usual TCP connection.
Additional InformationGET /mud HTTP/1.1
Host: mg.mud.de
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Origin: http://mg.mud.de
Sec-WebSocket-Protocol: telnet
Sec-WebSocket-Version: 10

Response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: telnet
TagsNo tags attached.
External Data (URL)http://en.wikipedia.org/wiki/WebSocket

Activities

zesstra

2011-08-23 11:20

administrator   ~0002057

Ok, the easiest things are always the hardest to see: websockets can be supported on the LPC side by using a dedicated port and a specific login object which handles this HTTP handshake.
Thanks to Gnomi. :-)

Wildcat

2011-08-23 14:36

reporter   ~0002058

Looks like the protocol was changed severely since the last time I looked at it. Last time all data was wrapped in Pascal String style length prefix. (2 byte in network byte order.) Glad that's gone, now I just wish there was a way of preserving query_ip_number through the main webserver.

zesstra

2011-08-23 14:46

administrator   ~0002059

No, I think, we did not read enough specs before I entered this issue.
Although there are short descriptions looking like websockets can be used like traditional sockets, there is more to it: you have to encapsulate messages in so-called frames, de-mask client frames etc. These frames also need two bytes and maybe this was done as replacement to these length prefixes.
Since this is a big change compared to traditional telnet streams, I don't think it is suitable for using it directly in LD-based muds. The better choice for quite some time seems to be a proxy speaking websockets to the client and telnet to the mud. :-( (Although you still can implement websockets on the LPC side if we have the input/output hooks/filters we also discuss somewhere in the tracker.

Issue History

Date Modified Username Field Change
2011-08-23 10:29 zesstra New Issue
2011-08-23 11:20 zesstra Note Added: 0002057
2011-08-23 14:36 Wildcat Note Added: 0002058
2011-08-23 14:46 zesstra Note Added: 0002059
2011-08-24 13:16 zesstra Status new => closed
2011-08-24 13:16 zesstra Assigned To => zesstra
2011-08-24 13:16 zesstra Resolution open => won't fix