Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server: Observer slot and ReceivedItems history command #3408

Open
blackoutroulette opened this issue May 26, 2024 · 5 comments
Open

Server: Observer slot and ReceivedItems history command #3408

blackoutroulette opened this issue May 26, 2024 · 5 comments

Comments

@blackoutroulette
Copy link

blackoutroulette commented May 26, 2024

Hello everyone, I am developing a bot which sends notifications to a discord channel and mentions the player that they received a new item.

The problem:

To reduce network traffic the bot is checking the tracker website in a fixed interval to see if any player is online and if yes connects to the server. Because of the delay until the server connection ReceivedItems packets can be missed. To fix this the bot currently logs in as every player and sends a "Sync" command to update its state and disconnects afterwards. This seems suboptimal and spams the console.

image

Feature request:

I would like to request an easier way to track ReceivedItems packets and resync the state after connecting. Some ideas I had are:

  • Hide player connects/disconnects which have a ['Tracker'] tag. This would still require to connect as every player.
  • Implement a server command to request the complete ReceivedItems history for a specified set of player id's.
  • Create an observer slot by generating a random character sequence as the slot name and display it on the lobby page. Connecting to this slot is read only and allows to receive ReceivedItems packets as well as requesting the ReceivedItems history.

Since I got familiar with the code in the past weeks while developing the bot I can try to provide a pull request. Let me know what you think and thank you for reading.

@Berserker66
Copy link
Member

Somewhat related PR: #2663
The ReceivedItems packet is not missable, that's an issue in your code.

@Berserker66
Copy link
Member

(To the point that we've discussed possibly removing the Sync command to enforce correct use of the API)

@blackoutroulette
Copy link
Author

Somewhat related PR: #2663 The ReceivedItems packet is not missable, that's an issue in your code.

Excuse me but it is not clear to me how receive a ReceivedItems packet if my Bot is not connected to the websocket and logged in as a player. Could you elaborate how I do this based on the following example?

Player_One logs in
Player_One sends item x to Player_Two
Bot detects a player is online
Bot logs in as Player_One with the tags ['Tracker']

How do I receive the ReceivedItems packet for item x now?

@Berserker66
Copy link
Member

You just did, the server sends it right after Connected.

@blackoutroulette
Copy link
Author

You just did, the server sends it right after Connected.

Ok, I failed to understand from the docs
that the return of the "Connect" command is actually:
[ {"cmd": "Connected" ...}, {"cmd": "ReceivedItems" ...} ]
instead of only the "Connected" packet. I probably missed it because I forgot to set the items_handling flag to something other than zero the first time when I tested it.

So sending a "Sync" command is unnecessary. But the ReceivedItems still only contain NetworkItem packets with reference to the player slot i logged in, is this right? This would still mean that I have to log into every player slot of the lobby. Please correct me if I am wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants