def _get_new_events(self): while True: response = requests.post( self._server_url + _EVENTS_URL, data={"id": self._chat_id} ) json_data = json.loads(response.text) if json_data not in (None, []): # NOTE: Not using implicit boolean comparison here, # because we only want to compare to 'null' and the # empty array. return json_data
def stop_typing(self): """Tell the server that the client has stopped typing. Raise: - PythonOmegleException if the HTTP request fails. Return: - No return value. """ response = requests.post( self._server_url + _STOPPED_TYPING_URL, data={"id": self._chat_id} )
def disconnect(self): """Disconnect from the chat (leave). Raise: - PythonOmegleException if the HTTP request fails. Return: - No return value. """ response = requests.post( self._server_url + _DISCONNECT_URL, data={"id": self._chat_id} ) self._chat_ready_flag = False
def send(self, message): """Send a message to the partner. Arguments: - message (str): The message to send. Raise: - PythonOmegleException if the HTTP request fails. Return: - No return value. """ _check_message_type(message=message) response = requests.post( self._server_url + _SEND_URL, data={"id": self._chat_id, "msg": message} )