I want to list the ip addresses of all connected players. I have edited the "WhoIsOnline()" function in the project. The output after the cycle does not work. AgentContext and AgentContext2 edited same function.
The program does not output when it is on for a long time. The first openings can be output.
Code:
static void ConsolePoolThread(){
...
if (cmd.Contains("/whos"))
{
AgentContext.WhosOnline();
if ((!FilterMain.AGENT_IP2.Equals("0")) && (FilterMain.AGENT_IP2 != String.Empty))
AgentContext2.WhosOnline();
}
...
}
public static void WhosOnline()
{
lock (locker) {
try
{
string clipboard_data = "AGENT\r\nUSERID\tCHARNAME\tIP\r\n";
int count = 0;
foreach (AgentContext current in clientlistgame)
{
if (current.m_ClientSocket.Connected)
{
Console.WriteLine("Method 1: " + current.user_id + " is online! IP: " + current.ip);
}
if (current.m_ClientSocket.Connected && current.m_ModuleSocket.Connected)
{
Console.WriteLine("Method 2: " + current.user_id + " is online! IP: " + current.ip);
}
clipboard_data += current.user_id + "\t" + current.charname + "\t" + current.ip+"\r\n";
count++;
}
Console.WriteLine("Total agent count: " + count);
var rand = new Random();
var _rand = rand.Next(99999);
Program.OutputFile("iplog_" + string.Concat(DateTime.Now.ToString("yyyyMMddHHmmss")) + "_" + _rand + "_agent.txt", clipboard_data);
}
catch { }
}
}







