コード例 #1
0
    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
コード例 #2
0
    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}
        )
コード例 #3
0
    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
コード例 #4
0
    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}
        )