class_docstr: ChatServiceMessageSocket is a wrapper around websocket to forward messages from the
  remote server to the ChatServiceManager.
class_docstr_tok: ["ChatServiceMessageSocket","is","a","wrapper","around","websocket","to","forward","messages","from","the","remote","server","to","the","ChatServiceManager","."]
docstr: server_url:           url at which the server is to be run
  port:                 port for the socket to operate on
  message_callback:     function to be called on incoming message objects (format: message_callback(self, data))
docstr_tok: ["server_url",":","url","at","which","the","server","is","to","be","run","port",":","port","for","the","socket","to","operate","on","message_callback",":","function","to","be","called","on","incoming","message","objects","(","format",":","message_callback","(","self",",","data",")",")"]
code: def __init__(self, server_url, port, message_callback):
      """
      server_url:           url at which the server is to be run
      port:                 port for the socket to operate on
      message_callback:     function to be called on incoming message objects (format: message_callback(self, data))
      """
      self.server_url = server_url
      self.port = port
      self.message_callback = message_callback
  
      self.ws = None
      self.last_pong = None
      self.alive = False
  
      # initialize the state
      self.listen_thread = None
  
      # setup the socket
      self.keep_running = True
      self._setup_socket()
  
file_path: ParlAI/parlai/chat_service/core/socket.py
imports: import errno
  import json
  import logging
  import threading
  import time
  import websocket
  import parlai.chat_service.utils.logging
label_desc: Use image node_id 1 to create a new ChatServiceMessageSocket object  with example: obj = ChatServiceMessageSocket(server_url, port, message_callback)