This repository has been archived on 2024-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
python-aternos/examples/websocket_example.py

21 lines
412 B
Python
Raw Permalink Normal View History

2022-04-06 10:44:14 +03:00
import asyncio
from getpass import getpass
from python_aternos import Client, atwss
user = input('Username: ')
pswd = getpass('Password: ')
aternos = Client.from_credentials(user, pswd)
s = aternos.list_servers()[0]
socket = s.wss()
@socket.wssreceiver(atwss.Streams.console)
2022-04-02 07:58:59 +03:00
async def console(msg):
2022-04-06 10:44:14 +03:00
print('Received:', msg)
2022-04-06 10:44:14 +03:00
async def main():
s.start()
await socket.connect()
asyncio.run(main())