public void ServerTcpClientAddDotNetSerializer() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- listener.Start(); Thread thread = new Thread(AcceptSocket); thread.Start(); IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3514); TcpClient tcpClient = new TcpClient(); tcpClient.Connect(localEndPoint); DotNetserialization serializer = new DotNetserialization(); Thread.Sleep(50); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- client.AddSerializer(serializer); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
//----------------------------------------------------------------------------------------- private void CreateNewTcpClient(string username) { Socket socket = _listener.GetSocket(); TCPClient client = new TCPClient(socket, username); client.AddSerializer(_serializer); client.AddListener(_listener); client.Start(); _clientList.Add(client); Console.WriteLine("Client Connected!!!"); }
public void ServerTcpClientSendPacket() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- server.Start(); Thread thread = new Thread(AcceptSocket); thread.Start(); TCP_Config config; config.address = "127.0.0.1"; config.port = 3515; IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3515); TcpClient tcpClient = new TcpClient(); tcpClient.Connect(localEndPoint); DotNetserialization serializer = new DotNetserialization(); ServerListenerTCP listener = new ServerListenerTCP(config); Thread.Sleep(50); client.AddListener(listener); client.AddSerializer(serializer); ChatMessagePacket packet = new ChatMessagePacket("This is a test", "Tester"); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- client.Send(packet); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }