示例#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);
         }
     }
 }
示例#2
0
        void SendCommand(string targetnick, XmlCommands.Command command)
        {
            string message = XmlCommands.GetInstance().Encode(command);

            LogFile.WriteLine(message);
            chat.SendPrivateMessage(targetnick, message);
        }
示例#3
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);
         }
     }
 }
示例#4
0
 void STUNResponseForOwnInterface( IPAddress ipaddress, int port )
 {
     LogFile.WriteLine( "showserverdialog.STUNResponseForOwnInterface( " + ipaddress + " " + port + " )" );
     MetaverseClient.GetInstance().imimplementation.SendPrivateMessage( servername,
         XmlCommands.GetInstance().Encode( new XmlCommands.PingMe( ipaddress, port ) ) );
 }