summaryrefslogtreecommitdiffstats
path: root/webchat/public/sockjs_client_transport.js
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-11-12 14:43:50 +0100
committermakefu <github@syntax-fehler.de>2013-11-12 14:43:50 +0100
commit8b60dff25e85921fe533f621a1b5d0f8149bf38f (patch)
treeb39eb0e15e630f5b5af624ec91b8f222a25170ae /webchat/public/sockjs_client_transport.js
parent8ebba4db20b8127e57490eeea95d50d158dc69dd (diff)
parentb749c216ae84f02330da7396135be11259ec12d9 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'webchat/public/sockjs_client_transport.js')
-rw-r--r--webchat/public/sockjs_client_transport.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/webchat/public/sockjs_client_transport.js b/webchat/public/sockjs_client_transport.js
new file mode 100644
index 00000000..a7b76af3
--- /dev/null
+++ b/webchat/public/sockjs_client_transport.js
@@ -0,0 +1,25 @@
+
+function make_sockjs_client_transport (sock) {
+ var transport = {}
+
+ sock.onmessage = function (data) {
+ console.log('sockjs parse', data)
+ try {
+ var message = JSON.parse(data.data)
+ } catch (error) {
+ return console.log('error', error)
+ }
+ transport.onmessage(message)
+ }
+
+ transport.send = function (message) {
+ try {
+ var data = JSON.stringify(message)
+ } catch (error) {
+ return console.log('sockjs transport send error:', error)
+ }
+ sock.send(data)
+ }
+
+ return transport
+}