diff options
author | makefu <root@pigstarter.de> | 2013-12-30 14:34:38 +0100 |
---|---|---|
committer | makefu <root@pigstarter.de> | 2013-12-30 14:34:38 +0100 |
commit | 08aa5e406a1f7b39182e79ea4eb7fabf7d61eaa3 (patch) | |
tree | 2db1a54f336167cc3cc3d5f74c77d029fe7e7470 /webchat/sockjs_server_connection_transport.js | |
parent | 133e49566c74f1d21c28536ed31d1514725ed49b (diff) |
//Cancer -> //
because that is what painload is all about
Diffstat (limited to 'webchat/sockjs_server_connection_transport.js')
-rw-r--r-- | webchat/sockjs_server_connection_transport.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/webchat/sockjs_server_connection_transport.js b/webchat/sockjs_server_connection_transport.js new file mode 100644 index 00000000..6f68b955 --- /dev/null +++ b/webchat/sockjs_server_connection_transport.js @@ -0,0 +1,26 @@ + +module.exports = function make_sockjs_server_connection_transport (connection) { + var transport = {} + + connection.on('data', function (data) { + try { + var message = JSON.parse(data) + } catch (error) { + return console.log('error', error) + } + transport.onmessage(message) + }) + connection.on('close', function () { + }) + + transport.send = function (message) { + try { + var data = JSON.stringify(message) + } catch (error) { + return console.log('sockjs transport send error:', error) + } + connection.write(data) + } + + return transport +} |