Exemplo n.º 1
0
        public void SendPacket(uint clientId, byte[] packetBytes, bool isReliable)
        {
            Packet packet     = default;
            var    packetFlag = isReliable ? PacketFlags.Reliable : PacketFlags.None;

            packet.Create(packetBytes, packetFlag);

            _clientConnectedDic[clientId].Send(_udpServerInfo.ChannelId, ref packet);
        }
        public void Send(MessageType type, Peer peer, byte[] data, PacketFlags flags)
        {
            Packet packet = default(Packet);

            byte[] buffer = new byte[MessageConfig.MESSAGE_LEN + data.Length];

            byte[] byteType = BitConverter.GetBytes((ushort)type);
            Array.Copy(byteType, buffer, MessageConfig.MESSAGE_LEN);

            Array.Copy(data, 0, buffer, MessageConfig.MESSAGE_LEN, data.Length);

            packet.Create(buffer, flags);
            peer.Send(0, ref packet);
        }