Init ws connection.

This commit is contained in:
Martin Edenhofer 2015-10-15 17:07:18 +02:00
parent a092e4b3dd
commit 7478cbef98

View file

@ -45,6 +45,27 @@ do($ = window.jQuery, window) ->
input: @onInput input: @onInput
).autoGrow { extraLine: false } ).autoGrow { extraLine: false }
if !window.WebSocket
console.log('no websockets available')
return
zammad_host = 'ws://localhost:6042'
@ws = new window.WebSocket(zammad_host)
console.log("connecting ws #{zammad_host}")
@ws.onopen = =>
console.log('ws connected')
@ws.onmessage = (e) =>
pipe = JSON.parse( e.data )
console.log 'debug', 'ws:onmessage', pipe
@ws.onclose = (e) =>
console.log 'debug', 'close websocket connection'
@ws.onerror = (e) =>
console.log 'debug', 'ws:onerror', e
checkForEnter: (event) => checkForEnter: (event) =>
if not event.shiftKey and event.keyCode is 13 if not event.shiftKey and event.keyCode is 13
event.preventDefault() event.preventDefault()