// called by SendMessage() and NetPeer.SendMessage; ie. may be user thread internal NetSendResult EnqueueMessage(NetOutgoingMessage msg, NetDeliveryMethod method, int sequenceChannel) { if (m_status != NetConnectionStatus.Connected) { return(NetSendResult.FailedNotConnected); } NetMessageType tp = (NetMessageType)((int)method + sequenceChannel); msg.m_messageType = tp; // TODO: do we need to make this more thread safe? int channelSlot = (int)method - 1 + sequenceChannel; NetSenderChannelBase chan = m_sendChannels[channelSlot]; if (chan == null) { chan = CreateSenderChannel(tp); } if ((method != NetDeliveryMethod.Unreliable && method != NetDeliveryMethod.UnreliableSequenced) && msg.GetEncodedSize() > m_currentMTU) { m_peer.ThrowOrLog("Reliable message too large! Fragmentation failure?"); } var retval = chan.Enqueue(msg); //if (retval == NetSendResult.Sent && m_peerConfiguration.m_autoFlushSendQueue == false) // retval = NetSendResult.Queued; // queued since we're not autoflushing return(retval); }