static void WebServerOnDisconnect(int id)
{
_connectedIds.Remove(id);
_playerDatas.Remove(id);
// Tell other players about the disconnection
_bitBuffer.Clear();
_bitBuffer.AddByte(4);
_bitBuffer.AddUShort((ushort)id);
_bitBuffer.ToArray(_buffer);
_webServer.SendAll(_connectedIds, new ArraySegment <byte>(_buffer, 0, 3));
// Check if we have less than 2 players and should cancel the game
if (_currentState != GameState.Waiting && _connectedIds.Count < 2)
{
beginTimer?.Stop();
_currentState = GameState.Waiting;
SendStateUpdate(_currentState);
}
}