Example #1
0
        /// <inheritdoc/>
        public void Send(DistributedMessage distributedMessage)
        {
            var bytesStack = distributedMessage.Content;

            try
            {
                NetworkStatistics.ReportSentPackage(bytesStack.Count);
                Peer.Send(bytesStack.RawData, 0, bytesStack.Count, GetDeliveryMethod(distributedMessage.Type));
            }
            catch (TooBigPacketException)
            {
                Log.Error($"Too large message to be sent: {bytesStack.Count}.");
            }
        }
Example #2
0
        /// <inheritdoc/>
        public void Broadcast(DistributedMessage distributedMessage)
        {
            var bytesStack = distributedMessage.Content;

            try
            {
                NetworkStatistics.ReportSentPackage(bytesStack.Count);
                NetClient.SendToAll(bytesStack.RawData, 0, bytesStack.Count,
                                    LiteNetLibPeerManager.GetDeliveryMethod(distributedMessage.Type));
            }
            catch (TooBigPacketException)
            {
                Log.Error($"Too large message to be sent: {bytesStack.Count}.");
            }

            distributedMessage.Release();
        }