Is websocket api global event subscription possible?

I’ve been using the Websocket API to develop tools for moderators. But it is running as an NPC player that can only subscripe to player events related to API key owner “only”, such as, playerChats, playerInteracts.

Is it possible to provide an global level of subscription on all players so we can listen to events of every player. Especially for the playerInteracts event. That would be every helpful.

Please let me know if this is considered or impossible? I’ll have to make a decision if I can keep putting my effort in this direction or give up for these features.

@jcyh So I’ve just spent an exhaustive time looking into specifically “playerChats”, and the game.chat functions using the API. Some strange things I have found:

  • Subscribing to playerChats allows for global listening only in the ‘Global_Chat’ level. In ‘Local_Chat’ and DMs, it will only ‘listen’ for the trigger if the player could see the chat. This is how the “Twitch plays Gather” API example works.

  • If your API holding character is not currently in the space, and a connection using their API key is made, that character can still listen to Global_Chat, and will also be able to game.chat into Global, but may show up as themselves or anonymous, depending on…something. I suspect if they have been logged into the space on the current game server.

To your question, but not to answer it directly: There are a number of difficulties that the per-account API keys causes. This chat listening question is one of them. I hope they change something about this soon.

As for “playerInteracts”, what have you seen that this does not do? For me, this event has been wonderful. I would be interested to hear some limitations, if you have found some.

Thanks, I’ve done something simular to you. The playerChats event behaves exactly as you described.

For playerInteracts event, it only emits when you are using the player of the API key. It will emit an event when the player press “x” with an object. This is the most valuable event but it restrict to the owner of the API key.

I also see that there’s an object type interface to design interactive object like password door. But lacking the event of the player’s interact. Even if we can made some special interactable objests, we still don’t get the triggers from player to handle the behavior.

Hope that it can be the same as PlayerJoins event that we can subscribe on every player.

Hello,
Currently we do not have any functionality to have a global listener for all events, however thank you for bringing this to our attention and we will keep it in mind for future features. Also thank you @Bill_Uncork-It for brining this chat behavior to my attention. @jcyh would you be able to describe in more detail your limitations with the playerInteracts event? I apologize as I am still a little confused on what you are describing. I believe that the interacts event should be sent to all clients that have Builder access for the space. Is this the limitation that you are describing? This also seems like another issue that could be solved with a global listener enabled for the extension. Thank you for your questions and insights into the API!

1 Like

If there are two players in the room, A is the owner of the API key and B is the guest player. When subscribing the playerInteracts event, it will only emit when player A press x to some object.

I want to received event when player B press x to objects.

Updates:

After adding the role for builder, I can received the event!!! Thanks so much!!! @eli
(I thought given the owner role will propergate moderator and builder role)

This playerInteract event open lots of space for creation!!!

1 Like

Glad you got it working!

Hi, @eli I came up with a problem about the roles. Do I need to have owner role to use the Websocket API to get the full abilities to call actions or listen to all events? or the moderator and builder roles are completely enought for interacting with the game client?

I currently grant all of the roles for the API key holder. But I think other people may consider granting the owner role of their space to try my bot.

Owner will be required for any time you are using the targetId field. Generally, any map changes will require you to have the Builder role, and events like spotlighting or banning will require moderator/owner roles. So, to get the full functionality of the Websocket API, your API key should be associated with an account that has Owner, Builder, and Moderator roles.

Thanks! It’s really important that we can get confirm from the official so that we can keep working on making things with the correct understanding!

I’ll add a note to tell users why the roles are required.

Appreciated for your help!