Пример #1
0
        /// <summary>
        /// Serializes and sends a packet across the wire
        /// </summary>
        /// <param name="msg">The packet to send</param>
        public virtual int Send(Packet msg)
        {
            try
            {
                if (msg.NeedsDeliveryAck)
                {
                    m_NumAcksWaitingFor++;
                }

                byte[] raw = OwningConnection.SerializePacket(msg);
                //Log.LogMsg("Sending -> " + msg.GetType().ToString() + " (" + raw.Length.ToString() + " bytes)");
                //Log.LogMsg("   That message is " + raw.Length.ToString() + " bytes long");
                return(Send(raw, msg.Flags));
            }
            catch (Exception sendExc)
            {
                OwningConnection.KillConnection(sendExc.Message);
                return(-1);;
            }
        }
        /// <summary>
        /// Serializes and sends a packet across the wire
        /// </summary>
        /// <param name="msg">The packet to send</param>
        public virtual int Send(Packet msg)
        {
            try
            {
                SocketDebug(29);
                if (msg.NeedsDeliveryAck)
                {
                    m_NumAcksWaitingFor++;
                }

                SocketDebug(30);
                byte[] raw = OwningConnection.SerializePacket(msg);
                SocketDebug(31);
                Log.LogMsg("Sending -> " + msg.GetType().ToString() + " (" + raw.Length.ToString() + " bytes)");
                Log.LogMsg("That message is " + raw.Length.ToString() + " bytes long");
                Log.LogMsg("1 Socket " + OwningConnection.MyTCPSocket.Handle.ToString() + "IsAlive=" + OwningConnection.MyTCPSocket.Connected.ToString() + ", with socket error reading " + m_LastTCPReceiveStatus.ToString());
                return(Send(raw, msg.Flags));
            }
            catch (Exception sendExc)
            {
                OwningConnection.KillConnection(sendExc.Message);
                return(-1);;
            }
        }