original_docstring: 
          Connect the websocket and generate events
          
docstring: Connect the websocket and generate events
docstring_tokens: Connect the websocket and generate events
code: async def connect_ws(self):
          """
          Connect the websocket and generate events
          """
          if self._ws_username is None:
              _LOGGER.warning("No websocket username configured, cannot connect")
              return
  
          try:
              credentials = await self.get_ws_pass(self._ws_username)
          except:
              _LOGGER.error("No credentials!")
              return
  
          if ("username" not in credentials) or ("wskey" not in credentials):
              _LOGGER.error(credentials)
              return
  
          # connect event callback
          async def _async_on_connect():
              _LOGGER.info("Websocket connected with sid %s", self._sio.sid)
  
          self._sio.on("connect", _async_on_connect)
  
          # disconnect event callback
          async def _async_on_disconnect():
              _LOGGER.info("disconnect")
  
          self._sio.on("disconnect", _async_on_disconnect)
  
          # serveroutput event callback
          async def _async_on_serveroutput(data):
              _LOGGER.debug(data)
              _LOGGER.info("Trying to register...")
              await self._sio.emit("register", { "username": credentials["username"], "wskey": credentials["wskey"] })
  
          self._sio.on("serveroutput", _async_on_serveroutput)
  
          # Notify event callback
          async def _async_on_notify(data):
              _LOGGER.debug("Notify received")
              _LOGGER.debug(data)
              self._hass.bus.fire(DOMAIN, data)
  
          self._sio.on("notify", _async_on_notify)
  
          await self._sio.connect(VOIPCENTER_WS_ENDPOINT)
code_tokens: async def connect_ws ( self ) : if self . _ws_username is None : _LOGGER . warning ( "No websocket username configured, cannot connect" ) return try : credentials = await self . get_ws_pass ( self . _ws_username ) except : _LOGGER . error ( "No credentials!" ) return if ( "username" not in credentials ) or ( "wskey" not in credentials ) : _LOGGER . error ( credentials ) return async def _async_on_connect ( ) : _LOGGER . info ( "Websocket connected with sid %s" , self . _sio . sid ) self . _sio . on ( "connect" , _async_on_connect ) async def _async_on_disconnect ( ) : _LOGGER . info ( "disconnect" ) self . _sio . on ( "disconnect" , _async_on_disconnect ) async def _async_on_serveroutput ( data ) : _LOGGER . debug ( data ) _LOGGER . info ( "Trying to register..." ) await self . _sio . emit ( "register" , { "username" : credentials [ "username" ] , "wskey" : credentials [ "wskey" ] } ) self . _sio . on ( "serveroutput" , _async_on_serveroutput ) async def _async_on_notify ( data ) : _LOGGER . debug ( "Notify received" ) _LOGGER . debug ( data ) self . _hass . bus . fire ( DOMAIN , data ) self . _sio . on ( "notify" , _async_on_notify ) await self . _sio . connect ( VOIPCENTER_WS_ENDPOINT )
short_docstring: Connect the websocket and generate events
short_docstring_tokens: Connect the websocket and generate events
comment: """
          Connect the websocket and generate events
          """$SEP$# connect event callback$SEP$# disconnect event callback$SEP$# serveroutput event callback$SEP$# Notify event callback