felixms / arma-rcon-class-php

A lightweight client for sending commands easily to a BattlEye server.
MIT License
46 stars 22 forks source link

Optimization? Avoid RCON connection spam #44

Closed Dunkstormen closed 4 years ago

Dunkstormen commented 4 years ago

I've started playing around with your class in my project. It is working fine for me. But I don't know if there is a smarter to do what I'm doing.

I have created some sort of profile for each player on the server where I can see if they're online on the server by sending a call to the RCON. However I create a new connection every single time meaning that every single time a players profile is accessed it would create a new connection to the RCON. I was wondering if there is any way for me to run something that keeps the connection alive that I then can tell my controllers to use instead of establishing a new connection all the time.

I've seen the socket functions mentioned in the readme. However I'm unsure if those can be used to implement the functionality I'm looking for.

In the end I just wanna avoid spamming the servers RCON with connections if I can keep it to one.

felixms commented 4 years ago

Easiest thing to do would be using a cache, say you query just every 5 minutes. Reduces server load and is less prone to errors.