prestonp / simple-rcon

Simple, painless node RCON client for Source servers
MIT License
14 stars 4 forks source link

Listen for messages from server #15

Closed egeexyz closed 7 years ago

egeexyz commented 7 years ago

Is it possible to listen to events from the server the way webrconjs does it?

For example, using simple-rcon plugged into a Minecraft server, I'd like a way to respond to particular server events such as players joining or leaving the server.

skibz commented 7 years ago

@egee-irl so, the important thing to note is that no two rcon implementations are equal. the rcon protocol (as defined by valve and implemented by this library) does not support this.

for this to work, the game server's (minecraft, in your case) rcon implementation would need to define more packet types. those extra packet types defined by minecraft's rcon would then need to be included in this library.

if you know where to find or have documentation for minecraft's rcon implementation, please respond with that here so that i can assess the viability of this further.

skibz commented 7 years ago

@egee-irl after some cursory research it appears that minecraft supports the same rcon model as quake-derived games. this means that this library is not what you are looking for.

it seems that what you would like to do is best achieved with a minecraft game mod. rcon is used for remote server administration, not for defining custom game/server configurations and behaviours.

skibz commented 7 years ago

one final note:

it is possible to sort of solve the problem you originally described using this library (although i do not recommend this approach)

you could run a command to, at intervals, fetch a player list from the server. then, keeping that player list state, react (delayed, unfortunately) to players joining or leaving by sending more commands.

egeexyz commented 7 years ago

Interestingly, I had initially considered something like that but felt it would be either too slow or may accidentally cause the game server to freak out from so many reoccuring rcon connections.

To give you a better idea of what I'm aiming to do, here's my use case:

I have a Discord bot that, among other things, reports the status of various game servers I run. One such game server is Rust which uses web-socket based Rcon and reports back (via rcon) messages and server status. This makes it easy for the bot to report back to the Discord server when someone joins the server.

I'd love to do the same for other game servers (Minecraft, Starbound, Gmod, etc) but, as you said, not all Rcon implementations are created equal.

I'm aware I can do this on the game server via mods but I want to avoid that. For now, pinging the bot with a simple command like ~gmod or ~minecraft to report user activity may just have to do.

skibz commented 7 years ago

Interestingly, I had initially considered something like that but felt it would be either too slow or may accidentally cause the game server to freak out from so many reoccuring rcon connections.

this library keeps the rcon connection established between commands sent to the server, meaning no untoward behaviour will come from sending commands to the server at high frequencies.

i hope you manage to sufficiently scratch your itch, and don't hesitate to ask more questions!

egeexyz commented 7 years ago

Hm I suppose I could ping the server for users every second or five and report back when there is a change..

Thanks for your help!