Esempio n. 1
0
 public void OnServerRegistration(string nickname, string message)
 {
     LogFile.WriteLine("serverregistration. received from " + nickname + ": " + message);
     if (message.StartsWith("QUERY"))
     {
         SendCommand(nickname, new XmlCommands.ServerInfo(
                         externaladdress, externalport));
     }
     else
     {
         try
         {
             XmlCommands.Command command = XmlCommands.GetInstance().Decode(message);
             if (command.GetType() == typeof(XmlCommands.PingMe))
             {
                 XmlCommands.PingMe pingmecommand = command as XmlCommands.PingMe;
                 LogFile.WriteLine("serverregistration received pingme command: " + new IPAddress(pingmecommand.MyIPAddress) +
                                   " " + pingmecommand.Myport);
                 IPEndPoint endpoint = new IPEndPoint(new IPAddress(pingmecommand.MyIPAddress), pingmecommand.Myport);
                 MetaverseServer.GetInstance().network.networkimplementation.Send(endpoint, new byte[] { 0 });
             }
         }
         catch (Exception ex)
         {
             LogFile.WriteLine(ex);
         }
     }
 }
Esempio n. 2
0
 void imimplementation_IMReceived(object source, IMReceivedArgs e)
 {
     Console.WriteLine("queryserver, im received " + e.Sender + " " + e.MessageText);
     if (e.Sender == targetserver)
     {
         try
         {
             XmlCommands.Command command = XmlCommands.GetInstance().Decode(e.MessageText);
             if (command.GetType() == typeof(XmlCommands.ServerInfo))
             {
                 XmlCommands.ServerInfo serverinfo = command as XmlCommands.ServerInfo;
                 Console.WriteLine("IRCQueryServer Got server response " + serverinfo);
                 callback(targetserver, serverinfo);
                 chat.IMReceived -= handler;
             }
         }
         catch (Exception ex)
         {
             LogFile.WriteLine(ex);
         }
     }
 }