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;
}