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); } } }
void SendCommand(string targetnick, XmlCommands.Command command) { string message = XmlCommands.GetInstance().Encode(command); LogFile.WriteLine(message); chat.SendPrivateMessage(targetnick, message); }
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); } } }
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 ) ) ); }