-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Websocket Library for stability
- Loading branch information
1 parent
a964aef
commit 8c35849
Showing
5 changed files
with
55 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .echo_client import EchoClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from ws4py.client.threadedclient import WebSocketClient | ||
import asyncio | ||
|
||
from ..rustplus_pb2 import * | ||
from ..structures import RustChatMessage | ||
|
||
class EchoClient(WebSocketClient): | ||
|
||
def __init__(self, ip, port, api, protocols=None, extensions=None, heartbeat_freq=None, ssl_options=None, headers=None, exclude_headers=None): | ||
super().__init__(f"ws://{ip}:{port}", protocols=protocols, extensions=extensions, heartbeat_freq=heartbeat_freq, ssl_options=ssl_options, headers=headers, exclude_headers=exclude_headers) | ||
|
||
self.api = api | ||
|
||
def opened(self): | ||
pass | ||
|
||
def closed(self, code, reason): | ||
pass | ||
|
||
def received_message(self, message): | ||
|
||
app_message = AppMessage() | ||
app_message.ParseFromString(message.data) | ||
|
||
if app_message.broadcast.teamMessage.message.message == "": | ||
if app_message.response.seq not in self.api.ignored_responses: | ||
self.api.responses[app_message.response.seq] = app_message | ||
else: | ||
self.api.ignored_responses.remove(app_message.response.seq) | ||
else: | ||
message = RustChatMessage(app_message.broadcast.teamMessage.message) | ||
|
||
if message.message.startswith(self.api.prefix): | ||
asyncio.new_event_loop().run_until_complete(self.api.command_handler.run_command(message=message)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters