示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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]);
            }
        }