public static GetUserNameFromConnection ( BoltConnection connection ) : string | ||
connection | BoltConnection | |
Résultat | string |
public override void Disconnected(BoltConnection connection) { lobby.RemovePlayer(PlayerRegistry.GetUserNameFromConnection(connection)); PlayerRegistry.Remove(connection); }
public override void OnEvent(TeamChangeEvent evnt) { lobby.SetPlayerTeam(PlayerRegistry.GetUserNameFromConnection(evnt.RaisedBy), evnt.NewTeam); }
private void KickAllNonCompliantPlayers() { //linq! // select all connections whose associated username is not contained within the list of all usernames in the controlledPlayers list var playersToKick = PlayerRegistry.Connections.Where(c => !controlledPlayers.Select(x => x.Username).Contains(PlayerRegistry.GetUserNameFromConnection(c))); //playersToKick contains all players who are not in the controlledPlayers list foreach (BoltConnection c in playersToKick) { c.Disconnect(new DisconnectReason("AntiCheat Violation", "Did not surrender control to server in time")); } }