public void Update(double t)
 {
     elapsed -= t;
     if (elapsed <= 0.0)
     {
         elapsed = sendTime;
         lock (reliableSend)
         {
             while (reliableSend.Count > 0)
             {
                 var dw = new NetDataWriter();
                 if (reliableSend.Count > 255)
                 {
                     dw.Put((byte)255);
                 }
                 else
                 {
                     dw.Put((byte)reliableSend.Count);
                 }
                 for (int i = 0; (i < 255 && reliableSend.Count > 0); i++)
                 {
                     Packets.Write(dw, reliableSend.Dequeue());
                 }
                 Client.Send(dw, DeliveryMethod.ReliableOrdered);
             }
         }
     }
 }
Esempio n. 2
0
        public void SendPacket(IPacket packet, PacketDeliveryMethod method)
        {
            var om = new NetDataWriter();

            Packets.Write(om, packet);
            method.ToLiteNetLib(out DeliveryMethod mt, out byte ch);
            client.FirstPeer?.Send(om, ch, mt);
        }
        public void SendPacketWithEvent(IPacket packet, Action onAck, PacketDeliveryMethod method)
        {
            var m = new NetDataWriter();

            m.Put((byte)1);
            Packets.Write(m, packet);
            method.ToLiteNetLib(out var mtd, out var channel);
            Client.SendWithDeliveryEvent(m, channel, mtd, onAck);
        }
Esempio n. 4
0
        void BeginAuthentication(NetPeer peer)
        {
            var msg = new NetDataWriter();

            msg.Put((byte)1);
            Packets.Write(msg, new AuthenticationPacket()
            {
                Type = AuthenticationKind.GUID
            });
            peer.Send(msg, DeliveryMethod.ReliableOrdered);
            peer.Tag = TagConnecting;
        }
 public void SendPacket(IPacket packet, PacketDeliveryMethod method)
 {
     method.ToLiteNetLib(out DeliveryMethod mt, out byte ch);
     if (mt == DeliveryMethod.ReliableOrdered)
     {
         lock (reliableLock)
         {
             reliableSend.Enqueue(packet);
         }
     }
     else
     {
         var m = new NetDataWriter();
         m.Put((byte)1);
         Packets.Write(m, packet);
         Client.Send(m, ch, mt);
     }
 }