private void AddPlayerItem(PlayerVO player) { var grid = FindEmptyGrid(PL_PlayerList1); if (grid == null) { grid = FindEmptyGrid(PL_PlayerList2); } if (grid == null) { throw new Exception("no empty grid"); } GameObject item = Instantiate(_playerItemPrefab, grid) as GameObject; //TODO: 改成隐藏/显示的方案 不需要频繁创建/销毁 var playerItem = item.GetComponent <PlayerItem>(); (playerItem.UserId, playerItem.UserName, playerItem.Level, playerItem.PrepareState, playerItem.VehicleName, playerItem.Attack, playerItem.Motility, playerItem.Defend, playerItem.MaxHealth) = (player.UserID, player.UserName, player.Level.ToString(), player.PrepareState, player.CurVehicle.VehicleName, player.CurVehicle.Attack, player.CurVehicle.Motility, player.CurVehicle.Defend, player.CurVehicle.MaxHealth); var kickBtn = item.GetComponentInChildren <Button>(true); kickBtn.onClick.AddListener(() => OnKick?.Invoke(player.UserID)); //显示踢除按钮 if (_playerManagerInstance.RoomOwner.UserID == _playerManagerInstance.LocalPlayer.UserID && playerItem.UserId != _playerManagerInstance.LocalPlayer.UserID) { kickBtn.gameObject.SetActive(true); } //显示房主标签 if (_playerManagerInstance.RoomOwner.UserID == player.UserID) { item.transform.Find("RoomOwnerText").GetComponent <Text>().gameObject.SetActive(true); item.transform.parent.GetComponent <Toggle>().isOn = true; } }
/// <summary> /// Verarbeitet einen Kick /// </summary> /// <seealso cref="OnKick"/> private void _connection_OnKick(object sender, KickEventArgs e) { Log.Information("{Nickname} wurde von {Operator} aus dem Raum {Channel} geworfen", e.Who, e.Whom, e.Channel); MaintainUser(e.Who); ThreadPool.QueueUserWorkItem(x => { OnKick?.Invoke(this, e); }); }
/// <summary> /// Kicks a connection from the server. /// </summary> /// <param name="connection">The connection to kick</param> /// <param name="reason">The reason to kick the connection.</param> /// <returns></returns> public async Task <RconResponse> Kick(int connection, string reason) { var response = await ExecuteAsync($"kick ${connection} \"{reason}\""); if (!(response.Success && response.Message.StartsWith("Successfully"))) { response.Success = false; } OnKick?.Invoke(this, response); return(response); }
public async void TryKick() { if (_timeFromLastKick < _settings.DefaultCharacterSettings.KickRate || !_playerMovement.CanMove) { return; } _timeFromLastKick = 0; OnKick?.Invoke(); StartHitEnemy(); await RemoteKick(); EndHitEnemy(); }
public async Task <Rcon.RconResponse> Kick(int connection, string reason, int duration) { if (duration <= 0) { return new Rcon.RconResponse() { Success = false, Message = "Invalid duration." } } ; var response = await Rcon.Ban(connection, reason, BanType.IP, duration); OnKick?.Invoke(this, connection, reason, duration); return(response); }
public void Kick(Figures selectedFig, List <Figures> actions) { foreach (Figures f in actions) { if (!f.Equals(selectedFig)) { Point othersFig = f.CountCenterCoordinates(); Point forSelectedFig = selectedFig.CountCenterCoordinates(); string result = Utils.CountDistanse(forSelectedFig, othersFig); if (result != null) { String s = selectedFig.Type + " collided with " + f.Type + " in coordinates : (" + result + '\n' + "----------------------------------------------"; OnKick?.Invoke(s); } } } }
public async Task <Rcon.RconResponse> Kick(int connection, string reason) { //TODO: Make this return a kick response code //https://www.youtube.com/watch?v=Qku9aoUlTXA if (Rcon == null) { Logger.LogWarning("Cannot kick a player because the RCON server is not enabled."); return(await Task.FromResult(new Rcon.RconResponse() { Success = false, Message = "Rcon not enabled" })); } //Kick the connection var response = await Rcon.Kick(connection, reason); OnKick?.Invoke(this, connection, reason, -1); return(response); }
public void UserKick(User nick, string kickee, string reason) { Server.Connection.Sender.Names(Name); OnKick?.Invoke(nick, kickee, reason); }
public void ProcessKickCommand(IrcMessage ircMessage) { OnKick?.Invoke(Rfc2812Util.UserFromString(ircMessage.From), ircMessage.Tokens[2], ircMessage.Tokens[3], ircMessage.Message); }
private void ProcessKickCommand(string[] tokens) { tokens[4] = RemoveLeadingColon(tokens[4]); OnKick?.Invoke(Rfc2812Util.UserFromString(tokens[0]), tokens[2], tokens[3], CondenseStrings(tokens, 4)); //Trace.WriteLine("Kick", "IRC"); }
/// <summary> /// Removes a client from the server /// </summary> /// <param name="client"></param> /// <param name="type"></param> public void RemoveClient(TCPServerClient client, TCPDisconnectType type = TCPDisconnectType.Disconnect, int pos = -1) { if (Logging) { Logger.Write("REGION", "Method [RemoveClient]"); } if (type == TCPDisconnectType.NoHandshake) { if (Logging) { Logger.Write("INFO", "Client no handshake: " + client.UID); } OnNoHandshake?.Invoke(client); } else if (type == TCPDisconnectType.Disconnect) { if (Logging) { Logger.Write("INFO", "Client disconnect: " + client.UID); } OnDisconnected?.Invoke(client); } else if (type == TCPDisconnectType.Timeout) { if (Logging) { Logger.Write("INFO", "Client timeout: " + client.UID); } OnTimeout?.Invoke(client); } else if (type == TCPDisconnectType.Kick) { if (Logging) { Logger.Write("INFO", "Client kick: " + client.UID); } OnKick?.Invoke(client); } lock (ClientsDict) ClientsDict.Remove(client.UID); lock (ClientsList) { if (pos >= 0) { ClientsList.RemoveAt(pos); } else { for (int e = ClientsList.Count - 1; e >= 0; e--) { if (ClientsList[e].UID == client.UID) { if (Logging) { Logger.Write("INFO", "Client found in ClientsList: " + client.UID); } ClientsList.RemoveAt(e); break; } } } } try { client.Socket.Shutdown(SocketShutdown.Both); client.Socket.Close(); } catch (Exception e) { if (Logging) { Logger.Write("FAILED", "Socket shutdown/close", e); } } }