public void ServerUdpClientAddListener() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- UDP_Config config; config.address = "127.0.0.1"; config.port = 4480; ServerLibrary.UDPClient client = new ServerLibrary.UDPClient("Tester"); ServerListenerUDP listener = new ServerListenerUDP(config); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- client.AddListener(listener); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerUdpClientSend() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- UDP_Config config; config.address = "127.0.0.1"; config.port = 4486; IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4485); ServerListenerUDP listener = new ServerListenerUDP(config); DotNetserialization serializer = new DotNetserialization(); ServerLibrary.UDPClient client = new ServerLibrary.UDPClient("Tester"); client.AddSerializer(serializer); client.AddEndPoint(endPoint); client.AddListener(listener); ChatMessagePacket packet = new ChatMessagePacket("This is a test", "Tester"); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- client.Send(packet); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerUdpClientConstructor() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- ServerLibrary.UDPClient client; //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- client = new ServerLibrary.UDPClient("Tester"); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
public void ServerUdpClientAddDotNetSerializer() { //--------------------------------------------------------------------- //Setup //--------------------------------------------------------------------- ServerLibrary.UDPClient client = new ServerLibrary.UDPClient("Tester"); DotNetserialization serializer = new DotNetserialization(); //--------------------------------------------------------------------- //Run Test //--------------------------------------------------------------------- client.AddSerializer(serializer); //--------------------------------------------------------------------- //Gather Output //--------------------------------------------------------------------- //--------------------------------------------------------------------- //Assert //--------------------------------------------------------------------- }
//----------------------------------------------------------------------------------------- private bool CheckForNewUser(IPEndPoint remoteClient, string username) { bool alreadyConnected = false; for (int i = 0; i < _clientList.Count(); i++) { UDPClient client = ((UDPClient)_clientList[i]); if (client._remoteClient.Equals(remoteClient)) { alreadyConnected = true; } } if (alreadyConnected == false) { CreateNewUdpClient(username, remoteClient); return(true); } return(false); }