lib/turntabler/connection.rb
def on_message(event)
      data = event.data

      response = data.match(/~m~\d*~m~(.*)/)[1]
      message =
        case response
        when /no_session/
          {'command' => 'no_session'}
        when /(~h~[0-9]+)/
          # Send the heartbeat command back to the server
          publish_to_socket($1)
          {'command' => 'heartbeat'}
        else
          JSON.parse(response)
        end
      message['command'] = 'response_received' if message['msgid']

      logger.debug "Message received: #{message.inspect}"
      dispatch(message)
    end
def on_message(event)
      data = event.data

      response = data.match(/~m~\d*~m~(.*)/)[1]
      message =
        case response
        when /no_session/
          {'command' => 'no_session'}
        when /(~h~[0-9]+)/
          # Send the heartbeat command back to the server
          publish_to_socket($1)
          {'command' => 'heartbeat'}
        else
          JSON.parse(response)
        end
      message['command'] = 'response_received' if message['msgid']

      logger.debug "Message received: #{message.inspect}"
      dispatch(message)
    end
def on_message ( event ) data = event . data response = data . match ( / \d / ) [ 1 ] message = case response when / / { 'command' => 'no_session' } when / / # Send the heartbeat command back to the server publish_to_socket ( $1 ) { 'command' => 'heartbeat' } else JSON . parse ( response ) end message [ 'command' ] = 'response_received' if message [ 'msgid' ] logger . debug "Message received: #{message.inspect}" dispatch ( message ) end
Callback when a message has been received from the remote server on the
 open socket.
Callback when a message has been received from the remote server on the open socket .