-
Notifications
You must be signed in to change notification settings - Fork 247
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
Add support for servers to periodically communicate with external services #3446
base: master
Are you sure you want to change the base?
Conversation
This is a prety simple *Manager class that can send periodic requests to another server as a form of heartbeat. This is generally useful and could be used by a server to report uptime, player info, and so on. Not qutie finished yet here but this works for my testing.
This isn't quite working yet
👍 to the idea for sure! Maybe someone can ping @FlaggAC about this as well... he brought up a discussion a few weeks ago about integrating the rcon protocol |
}; | ||
|
||
HttpContent content = new StringContent(JsonConvert.SerializeObject(body)); | ||
response = client.PostAsync(endpoint, content).Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing Result will block. Is it safe to do this on this thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought this was fine but can change if this is problematic. Thanks for catching this @enknamel
Also capture HTTP exceptions and tweak log messages
Hey yes I spoke with the owner of battlemetrics.com and it might be a good thing for any AC Servers that wish to opt in to this. It would show public chat history, player login history, etc. - You can get an idea by going to https://www.battlemetrics.com/subscription/rcon and seeing what it offers. Feel free to ping me in Discord if you want to work together on this or on your own - the guy sent me info on how to get it completely set up. |
That's a pretty neat service, @FlaggAC , thanks for the pointer. Gives me some ideas for things I could add onto TreeStats. I definitely like the idea of implementing something like rcon that gives servers two-way messaging and remote control. That said, I also like the relatively small size of the change I'm proposing here and am probably willing to put more time into it since it's scratching my own itch. |
Hey all, I was talking about something I've built with @LtRipley36706 the other day and he thought other devs would be interested in seeing a PR so here it is:
It would be really interesting if ACE servers could communicate with external services. There's been a ton of discussion about how to do this, going back to #718. Providing an HTTP API is a really powerful idea but presents a ton of problems such as rate limiting, running read-only replicas of the database, and so on.
A lighter weight and simpler approach is to have ACE servers send any information to external services periodically. The biggest downside here is that the feature only works if the external service stays available.
What I've done here is created a new
*Manager
class calledHeartbeatManager
that based on code that already existed in ACE that sends a JSON payload to a configurable HTTP endpoint at a configurable interval. Think webhook.The immediate thing ACE servers could do with this is broadcast whether the server is up and how many players are online to services such as https://treestats.net. People are very interested in how many players are on each server but the TreeStats way of tracking server populations requires players on each server to run my Decal plugin. And even then, the temporal resolution of the population data depends on how many players are running the plugin. With my system here, ACE servers could send their
OnlineCount
to TreeStats at intervals and we'd all have much better data to look at.Some notes:
WorldName
andOnlineCount
but I think we could find some easy way to let users configure the Manager to send more info such as any config properties (xp rate, pk/npk, etc) or even information obtained from database queries such as total characters.WebhookManager
What do you all think? I'm open to both thoughts on the concept as well as specific comments on the PR.