public void HandleRequestConnect(EndPoint publicEndPoint, C2SMessageReader mr) { Debug.WriteLine("SR: Client" + mr.ClientEP() + " connected"); int clientEp = mr.ClientEP(); if (clientEp == -1) { Peer p = new Peer(); p.LastVisit = DateTime.Now; p.IpAddress = IPAddress.Any; int id = p.Add(); ServerCommunicationCenter.commCenter.ClientConnected(id, new ClientEndPoint((IPEndPoint)publicEndPoint, mr.ClientPrivateEP())); ServerMessageProvider smp = new ServerMessageProvider(SocketResourcesManager.srm.ProvideBuffer()); OutputMessage om = smp.ProvideApplicationRegisterResponseMessage(id); ServerCommunicationCenter.commCenter.SendMessage(publicEndPoint, om); } else { ServerCommunicationCenter.commCenter.ClientConnected(mr.ClientEP(), new ClientEndPoint((IPEndPoint)publicEndPoint, mr.ClientPrivateEP())); ServerMessageProvider smp = new ServerMessageProvider(SocketResourcesManager.srm.ProvideBuffer()); OutputMessage om = smp.ProvideConnectedMessage(); ServerCommunicationCenter.commCenter.SendMessageTo(mr.ClientEP(), om); } }