ACR_ServerCommunicator.ACR_ServerCommunicator.GetServerName C# (CSharp) Method

GetServerName() public method

Get the name of a server.
public GetServerName ( int ServerId ) : string
ServerId int Supplies the id of the server to /// query.
return string
        public string GetServerName(int ServerId)
        {
            lock (WorldManager)
            {
                GameServer Server = WorldManager.ReferenceServerById(ServerId, GetDatabase());

                if (Server == null)
                    return null;

                return Server.Name;
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// This when a cross-server ping response is received.  Its purpose is
        /// to compute the channel latency and send a message to that effect to
        /// the requesting player.
        /// </summary>
        /// <param name="SourceServerId">Supplies the server id of the server
        /// that completed the ping request.</param>
        /// <param name="Arguments">Supplies the serialized state arguments
        /// string.</param>
        /// <param name="Script">Supplies the current script object.</param>
        /// <returns>TRUE on success, else FALSE on failure.</returns>
        public static int HandleServerPingResponse(int SourceServerId, string Arguments, ACR_ServerCommunicator Script)
        {
            int Tick = Environment.TickCount;

            try
            {
                PingState RemoteState;

                //
                // Deserialize the remote ping state.  If null, a protocol
                // violation has occurred.
                //

                if ((RemoteState = PingState.FromString(Arguments)) == null)
                {
                    Script.WriteTimestampedLogEntry(String.Format(
                                                        "ACR_ServerCommunicator.ServerLatencyMeasurer.HandleServerPingResponse({0}, {1}): Invalid request.",
                                                        SourceServerId,
                                                        Arguments));
                    return(ACR_ServerCommunicator.FALSE);
                }

                string ServerName = Script.GetServerName(SourceServerId);

                if (ServerName == null)
                {
                    return(ACR_ServerCommunicator.FALSE);
                }

                Script.SendMessageToPC(RemoteState.PCObjectId, String.Format(
                                           "IPC channel latency to {0}: {1}ms", ServerName, Tick - RemoteState.TickCount));
            }
            catch (Exception e)
            {
                Script.WriteTimestampedLogEntry(String.Format(
                                                    "ACR_ServerCommunicator.ServerLatencyMeasurer.HandleServerPingResponse({0}, {1}): Exception: {0}",
                                                    SourceServerId,
                                                    Arguments,
                                                    e));
                return(ACR_ServerCommunicator.FALSE);
            }

            return(ACR_ServerCommunicator.TRUE);
        }
All Usage Examples Of ACR_ServerCommunicator.ACR_ServerCommunicator::GetServerName
ACR_ServerCommunicator