     onMessage: (e) =>
         message = e.data.split ' '
         if message[0] is 'ping'
-            @socket.send 'pong ' + message[1...].join(' ')
+            @socket.send? 'pong ' + message[1...].join(' ')
         else if message[0] is 'pub'
             @parent.onUpdate message[1], @_decode(message[2])
 

        @connected = false
        @pending = {}
        @subscribed = {}
        @socket = new WebSocket via
        @socket.onopen = @onOpen
        @socket.onclose = @onClose
        @socket.onmessage = @onMessage
        @socket.onerror = @onError

    _decode: (q) ->
        r = {}


    _send: (method, uri, data) =>
        message = [method, uri, data].join ' '
        @socket.send? message

    _subscribe: (uri) =>
        @_send 'sub', uri, ''
