private void sendUDPConnectionConfirmed(ClientNetworked client) { var buffer = new byte[4 + 1]; BitConverter.GetBytes((int)1).CopyTo(buffer, 0); buffer[4] = (byte)ClientPacketManagerNetworked.InternalPacketType.ServerConfirmUDPConnection; client.PacketManager.tcpConnection.SendPacket(buffer, TCPPacketBuilder.TCPPacketFlags.None); }
void listener_ClientConnected(object sender, TCPConnectionListener.ClientConnectedEventArgs e) { Console.WriteLine(@"Client connected from: (" + e.CL.Client.RemoteEndPoint.ToString() + @")"); var cl = new ClientNetworked(new TCPConnection(e.CL)); Clients.Add(cl); sendUDPClientID(cl); }
private void sendUDPClientID(ClientNetworked client) { var id = createUniqueUDPID(); client.UDPID = id; var buffer = new byte[4 + 1 + 4 + 4]; BitConverter.GetBytes((int)1).CopyTo(buffer, 0); buffer[4] = (byte)ClientPacketManagerNetworked.InternalPacketType.ServerEstablishUDPID; BitConverter.GetBytes(id).CopyTo(buffer, 4 + 1); BitConverter.GetBytes(udpPort).CopyTo(buffer, 4 + 1 + 4); client.PacketManager.tcpConnection.SendPacket(buffer, TCPPacketBuilder.TCPPacketFlags.None); }
private void createTransportersForNewClient(ClientNetworked cl) { var clTrans = new ClientPacketManagerNetworked.IClientPacketTransporterNetworked[transporters.Count]; for (int i = 0; i < transporters.Count; i++) { var t = transporters[i]; var fact = transporterFactories[t]; var clientTransporter = fact.CreateTransporter(cl.PacketManager); clTrans[i] = clientTransporter; } cl.PacketManager.AutoAssignPacketIDs(); sendUDPConnectionConfirmed(cl); cl.PacketManager.WaitForRemotePacketIDsSynced(); for (int i = 0; i < transporters.Count; i++) { transporters[i].AddClientTransporter(cl, clTrans[i]); } }