Пример #1
0
        public void Send(Peer peer, short opcode, ISerializablePacket packet)
        {
            if (peer == null || !peer.IsConnected)
            {
                return;
            }

            using (PooledNetWriter w = NetWriterPool.GetWriter())
            {
                MessageHelper.CreateAndFinalize(w, opcode, packet);
                var segment = w.ToArraySegment();
                if (NetLogFilter.messageDiagnostics)
                {
                    NetDiagnostics.OnSend(opcode, segment.Count, 1);
                }
                if (!isSimulated)
                {
                    peer.SendMessage(segment, UDPTransport.Source.Server);
                }
                else
                {
                    peer.SendSimulatedMessage(segment, UDPTransport.Source.Server);
                }
            }
        }
Пример #2
0
 public void Send(short opcode, ISerializablePacket packet)
 {
     using (PooledNetWriter w = NetWriterPool.GetWriter())
     {
         MessageHelper.CreateAndFinalize(w, opcode, packet);
         var segment = w.ToArraySegment();
         if (NetLogFilter.messageDiagnostics)
         {
             NetDiagnostics.OnSend(opcode, segment.Count, connectedPeers.Values.Count);
         }
         if (!isSimulated)
         {
             foreach (var peer in connectedPeers.Values)
             {
                 peer.SendMessage(segment, UDPTransport.Source.Server);
             }
         }
         else
         {
             foreach (var peer in connectedPeers.Values)
             {
                 peer.SendSimulatedMessage(segment, UDPTransport.Source.Server);
             }
         }
     }
 }
Пример #3
0
        /// <summary>
        ///     Sends a message to server.
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="qos"></param>
        public void Send(short opcode, ISerializablePacket packet)/* OutgoingMessage msg)*/
        {
            if (!IsConnected)
            {
                return;
            }

            using (PooledNetWriter w = NetWriterPool.GetWriter())
            {
                MessageHelper.CreateAndFinalize(w, opcode, packet);
                var segment = w.ToArraySegment();
                if (NetLogFilter.messageDiagnostics)
                {
                    NetDiagnostics.OnSend(opcode, segment.Count, 1);
                }
                Send(segment);
            }
        }