DarkCat09 / python-aternos

[UNMAINTAINED] Unofficial Aternos API written in Python
https://pypi.org/project/python-aternos/
Apache License 2.0
92 stars 13 forks source link

Status is not updating #55

Closed Khaleas closed 1 year ago

Khaleas commented 1 year ago

Hello. I'm trying to get real-time information about server status: whether it is online and list of players. For this, i am using atwss module. The issue i encountered is that status stream does not send me signal if i turn on the server. Console and ram streams work fine. I am using Python 3.10.5 64-bit, Windows 10 Here is my code:

import asyncio
from python_aternos import Client, atwss
import logging

# logging.basicConfig(level=logging.DEBUG)
aternos = Client.from_credentials(user, pswd)

server = aternos.list_servers()[0]
socket = server.wss()

@socket.wssreceiver(atwss.Streams.status, 'Server 1')
async def console(msg, args):
    print(args[0], 'received', msg)

async def main():
    server.start()
    await socket.connect()
    await asyncio.create_task(loop())

async def loop():
    while True:
        await asyncio.sleep(1)

asyncio.run(main())
DarkCat09 commented 1 year ago

Thanks for reporting the issue.
Fixed in https://github.com/DarkCat09/python-aternos/commit/bb019d14163a04173a92b69758f8ddc373a35338

DarkCat09 commented 1 year ago

Websocket API works properly in scripts, but very strange in Python REPL.
Socket doesn't receive messages and I don't know why.