Add Pterodactyl cog #19
1 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,7 @@ from pterodactyl.pterodactyl import Pterodactyl
|
|||
async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
|
||||
base_url = await config.base_url()
|
||||
|
||||
logger.debug("Establishing WebSocket connection")
|
||||
logger.info("Establishing WebSocket connection")
|
||||
|
||||
websocket_credentials = await retrieve_websocket_credentials(coginstance)
|
||||
|
||||
|
@ -26,18 +26,18 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
|
|||
|
||||
auth_message = json.dumps({"event": "auth", "args": [websocket_credentials['data']['token']]})
|
||||
await websocket.send(auth_message)
|
||||
logger.debug("Authentication message sent")
|
||||
logger.info("Authentication message sent")
|
||||
|
||||
coginstance.websocket = websocket
|
||||
|
||||
while True: # pylint: disable=too-many-nested-blocks
|
||||
message = await websocket.recv()
|
||||
if json.loads(message)['event'] in ('token expiring', 'token expired'):
|
||||
logger.debug("Received token expiring/expired event. Refreshing token.")
|
||||
logger.info("Received token expiring/expired event. Refreshing token.")
|
||||
websocket_credentials = await retrieve_websocket_credentials(coginstance)
|
||||
auth_message = json.dumps({"event": "auth", "args": [websocket_credentials['data']['token']]})
|
||||
await websocket.send(auth_message)
|
||||
logger.debug("Authentication message sent")
|
||||
logger.info("Authentication message sent")
|
||||
|
||||
if json.loads(message)['event'] == 'auth success':
|
||||
logger.info("WebSocket authentication successful")
|
||||
|
|
Loading…
Reference in a new issue