JaxNode October 2017
Speakers
Hosting Node on Azure
Game server
Unity3D
WebAssembly Intro
int add(int a, int b) {
return a + b;
}
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "_Z3addii" (func $_Z3addii))
(func $_Z3addii (; 0 ;) (param $0 i32) (param $1 i32) (result i32)
(i32.add
(get_local $1)
(get_local $0)
)
)
)
wasm-function[0]:
sub rsp, 8 ; 0x000000 48 83 ec 08
mov ecx, esi ; 0x000004 8b ce
mov eax, ecx ; 0x000006 8b c1
add eax, edi ; 0x000008 03 c7
nop ; 0x00000a 66 90
add rsp, 8 ; 0x00000c 48 83 c4 08
ret ; 0x000010 c3
WebSockets, part of the HTML5 specification, enables two-way communication between web pages and a remote host. (https://tools.ietf.org/html/rfc6455)
The good (read bad) old days of browser based games
Long Polling - server holds the request open until new data is available. Once available, the server responds and sends the new information.
Flash Socket uses a flash object to establish a connection to the WebSocket server and communicates using the WebSocket protocol. This means an additional Flash object (SWF files) will need to be leveraged.
Short Polling - an XHR request is made from the browser it is answered immediately and closes immediately
Websocket vs UDP/TCP
The overhead induced by TCP/IP and TLS in particular can dwarf the overhead of WebSocket itself.
Applications can use application-level message batching to effectively reduce the overhead that can be induced by TCP/IP and TLS.
WSS gives you easy encryption
HMAC-SHA256 gives you payload signing
Websockets make streaming easy.
Cell phone IP's aren't static there proxied
Sends strings, buffered arrays, and blobs
No need for port mapping , UPNP, etc.
Benchmarks Here:
https://crossbario.com/blog/Dissecting-Websocket-Overhead/
Another Great write up:
https://stackoverflow.com/questions/13040752/websockets-udp-and-benchmarks