diff options
author | makefu <github@syntax-fehler.de> | 2013-12-30 03:10:21 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-12-30 03:10:21 +0100 |
commit | 7f222f547283b03a6e53ef69b228abf11e46e5c8 (patch) | |
tree | 979b46b20d8c7e54ce8f6bea441c6dfd736d8271 /Cancer/webchat/sockjs_server_connection_transport.js | |
parent | 4db3c97ab8a76bd28dc737755c331e89a671d162 (diff) |
webchat -> Cancher
Diffstat (limited to 'Cancer/webchat/sockjs_server_connection_transport.js')
-rw-r--r-- | Cancer/webchat/sockjs_server_connection_transport.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Cancer/webchat/sockjs_server_connection_transport.js b/Cancer/webchat/sockjs_server_connection_transport.js new file mode 100644 index 00000000..6f68b955 --- /dev/null +++ b/Cancer/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 +} |