コード例 #1
0
        // common message handlers

        protected void HandleExit(ServerPlayer player, NetworkMessage msg)
        {
            MsgExit enter = msg as MsgExit;

            if (enter == null)
            {
                return;
            }

            RemovePlayer(player);
            player.Disconnect();
        }
コード例 #2
0
        private void SendReject(ServerPlayer player, MsgReject.RejectionCodes code, string reason)
        {
            player.Accepted        = false;
            player.RejectionReason = code.ToString() + " :" + reason;

            Logger.Log1("Reject Player " + player.PlayerID + " " + player.RejectionReason);
            player.SendMessage(new MsgReject(code, reason));

            PlayerRejected?.Invoke(this, player);

            player.Disconnect();
            RemovePlayer(player);
        }
コード例 #3
0
        private void Players_PlayerLagUpdated(object sender, ServerPlayer e)
        {
            LatencyInfo info = e.GetTag <LatencyInfo>(LatencyInfo.Name);

            bool didWarn = false;

            if (WarnLag > 0)
            {
                if (e.Lag.InstantLagTime > WarnLag && e.Lag.AverageLag > WarnLag)
                {
                    info.Warnings++;
                    didWarn = false;
                }
            }

            if (WarningPacketLoss > 0)
            {
                if (e.Lag.TotalPacketLoss > WarningPacketLoss)
                {
                    if (e.Lag.TotalPacketLoss > info.LastPacketLoss)
                    {
                        info.Warnings++;
                        didWarn = false;
                    }
                    info.LastPacketLoss = e.Lag.TotalPacketLoss;
                }
            }

            if (info.Warnings >= MaxWarnings)
            {
                State.Chat.SendChatToUser(null, e, Resources.KickMessage, false);
                e.FlushTCP();
                e.Disconnect();
            }
            else if (didWarn)
            {
                State.Chat.SendChatToUser(null, e, Resources.WarnMessage, false);
            }
        }
コード例 #4
0
 public static void KickUser(ServerPlayer player)
 {
     player.Disconnect();
 }