1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 21:01:25 +01:00

Forget withrottle client on disconnect

This commit is contained in:
Asbelos 2022-08-05 18:14:22 +01:00
parent 5430711672
commit 42ac954475
3 changed files with 10 additions and 0 deletions

View File

@ -82,6 +82,7 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
} }
void CommandDistributor::forget(byte clientId) { void CommandDistributor::forget(byte clientId) {
if (clients[clientId]==WITHROTTLE_TYPE) WiThrottle::forget(clientId);
clients[clientId]=NONE_TYPE; clients[clientId]=NONE_TYPE;
} }
#endif #endif

View File

@ -69,6 +69,14 @@ WiThrottle* WiThrottle::getThrottle( int wifiClient) {
return new WiThrottle( wifiClient); return new WiThrottle( wifiClient);
} }
void WiThrottle::forget( byte clientId) {
for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle)
if (wt->clientid==clientId) {
delete wt;
break;
}
}
bool WiThrottle::isThrottleInUse(int cab) { bool WiThrottle::isThrottleInUse(int cab) {
for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle) for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle)
if (wt->areYouUsingThrottle(cab)) return true; if (wt->areYouUsingThrottle(cab)) return true;

View File

@ -37,6 +37,7 @@ class WiThrottle {
void parse(RingStream * stream, byte * cmd); void parse(RingStream * stream, byte * cmd);
static WiThrottle* getThrottle( int wifiClient); static WiThrottle* getThrottle( int wifiClient);
static void markForBroadcast(int cab); static void markForBroadcast(int cab);
static void forget(byte clientId);
private: private:
WiThrottle( int wifiClientId); WiThrottle( int wifiClientId);