private static void RunAsClient() { GonzoNet.PacketHandlers.Register(0x02, false, 0, new OnPacketReceive(PacketHandlers.HandleServerChallenge)); //GonzoNet requires a log output stream to function correctly. This is built in behavior. GonzoNet.Logger.OnMessageLogged += new MessageLoggedDelegate(Logger_OnMessageLogged); StaticStaticDiffieHellman.ExportKey("ClientPublic.dat", PacketHandlers.ClientKey.PublicKey); m_Client = new NetworkClient("127.0.0.1", 12345); m_Client.OnConnected += new OnConnectedDelegate(m_Client_OnConnected); LoginArgsContainer LoginArgs = new LoginArgsContainer(); LoginArgs.Enc = new GonzoNet.Encryption.ARC4Encryptor("test"); LoginArgs.Username = "******"; LoginArgs.Password = "******"; LoginArgs.Client = m_Client; PacketHandlers.GenerateClientIV(); m_Client.Connect(LoginArgs); while (true) { Thread.Sleep(1000); } }
private static void RunAsServer() { GonzoNet.PacketHandlers.Register(0x01, false, 0, new OnPacketReceive(PacketHandlers.InitialClientConnect)); GonzoNet.PacketHandlers.Register(0x03, false, 0, new OnPacketReceive(PacketHandlers.HandleChallengeResponse)); //GonzoNet requires a log output stream to function correctly. This is built in behavior. GonzoNet.Logger.OnMessageLogged += new MessageLoggedDelegate(Logger_OnMessageLogged); StaticStaticDiffieHellman.ExportKey("ServerPublic.dat", PacketHandlers.ClientKey.PublicKey); m_Listener.Initialize(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 12345)); while (true) { Thread.Sleep(1000); } }