Exemple #1
0
        /// <summary>
        /// Fires when a child server replies with a heartbeat pong.  Also updates the GSI object with things like current number of users
        /// </summary>
        protected virtual void OnServerPong(INetworkConnection con, Packet msg)
        {
            PacketServerUpdate pong = msg as PacketServerUpdate;
            IPEndPoint         ipe  = (IPEndPoint)((OutboundServerConnection)con).RemoteEndPoint;
            GameServerInfo <OutboundServerConnection> gi = Server.GetGSIByIPAndPort(ipe.Address.ToString(), ipe.Port);

            if (gi == null)
            {
                return;
            }
            //Log1.Logger("Server.Outbound.Network").Debug("Got server heartbeat from " + pong.UserID + "/" + pong.ServerName);
            gi.UserID     = ServerUserID = pong.UserID;
            gi.Name       = gi.Connection.Name = pong.ServerName;
            gi.CurUsers   = pong.CurrentPlayers;
            gi.MaxUsers   = pong.MaxPlayers;
            gi.LastUpdate = DateTime.UtcNow;
            gi.IsOnline   = true;
            Server.UpdateOutboundServerAvailability(gi.ServerGroup);

            if (ServerUserID == null || ServerUserID.Length < 1)
            {
                Log1.Logger("Server.Outbound.Network").Error("Outbound server " + pong.ServerName + " did not indicate their username to us.  Was one set in that server's App.Config?.  Disconnecting from that server. We need that ID.");
                gi.Connection.KillConnection("ServerUserID not set on remote server.");
            }
        }
Exemple #2
0
        private void OnPing(INetworkConnection con, Packet ping)
        {
            //Log1.Logger("Zeus.Inbound.Client").Debug("Sending heartbeat to client " + ((InboundConnection)con).ServerUser.AccountName + ".");
            PacketServerUpdate pong = (PacketServerUpdate)CreatePacket((int)ServerPacketType.ServerStatusUpdate, 0, false, false);

            pong.ServerName     = MyServer.ServerName;
            pong.UserID         = MyServer.ServerUserID;
            pong.MaxPlayers     = MyServer.MaxInboundConnections;
            pong.CurrentPlayers = ConnectionManager.PaddedConnectionCount;
            ping.ReplyPacket    = pong;
        }