Exemplo n.º 1
0
 public void SendToClients(List <ServerClient> receiverList, DAbstract data)
 {
     foreach (ServerClient receiver in receiverList)
     {
         this.SendToClient(receiver, data);
     }
 }
Exemplo n.º 2
0
        internal void Send(DAbstract data)
        {
            if (this.Connected)
            {
                DNetworkPacket <DAbstract> networkPacket = new DNetworkPacket <DAbstract>
                {
                    type = data.GetType().Name,
                    data = data
                };

                byte[] buffer = Encoding.ASCII.GetBytes(networkPacket.ToJson());
                this.stream.Write(new byte[]
                {
                    0x69
                });
                this.stream.Write(BitConverter.GetBytes(buffer.Length));
                this.stream.Write(new byte[] {
                    new PacketFlags().Result()
                });
                this.stream.Write(buffer);
                this.stream.Write(new byte[]
                {
                    Utility.CalculateChecksum(buffer)
                });

                this.stream.Flush();
            }
        }
Exemplo n.º 3
0
 private void SendToClient(ServerClient receiver, DAbstract data)
 {
     if (this.disposed)
     {
         throw new ObjectDisposedException(nameof(Server));
     }
     if (receiver != null && receiver.Connected)
     {
         receiver.Send(data);
     }
 }
Exemplo n.º 4
0
 public void Broadcast(DAbstract data) => this.SendToClients(this.ServerClientManager.ClientList, data);
Exemplo n.º 5
0
        }                                         // use dynamic so you won't need to cast. Base type is always DAbstract
                                                  // dynamic type can be found using BikeDataReceivedEventArgs.Type

        public BikeDataReceivedEventArgs(BikeDataType type, DAbstract data)
        {
            this.Type = type;
            this.Data = data;
        }
Exemplo n.º 6
0
 private void SendData(string id, DAbstract data = null) =>
 this.SendData(new DVRClientPacket <DAbstract>()
 {
     id = id, data = data
 }.ToJson());                                                                           // Create VRClientPacket