Exemple #1
0
        public override void Send(IClientMsg clientMsg)
        {
            lock (netLock)
            {
                if (socket == null || netStream == null)
                {
                    DebugLog.WriteLine("TcpConnection", "Attempting to send client message when not connected: {0}", clientMsg.MsgType);
                    return;
                }

                var data = clientMsg.Serialize();

                if (netFilter != null)
                {
                    data = netFilter.ProcessOutgoing(data);
                }

                try
                {
                    netWriter.Write((uint)data.Length);
                    netWriter.Write(TcpConnection.MAGIC);
                    netWriter.Write(data);
                }
                catch (IOException ex)
                {
                    DebugLog.WriteLine("TcpConnection", "Socket exception while writing data: {0}", ex);
                }
            }
        }
Exemple #2
0
        public void Send(byte[] data)
        {
            if (state == EncryptionState.Encrypted)
            {
                data = encryption.ProcessOutgoing(data);
            }

            inner.Send(data);
        }
Exemple #3
0
        /// <summary>
        /// Serializes and sends the provided message to the server in as many packets as is necessary.
        /// </summary>
        /// <param name="clientMsg">The ClientMsg</param>
        public override void Send(IClientMsg clientMsg)
        {
            if (state != (int)State.Connected)
            {
                return;
            }

            byte[] data = clientMsg.Serialize();

            if (filter != null)
            {
                data = filter.ProcessOutgoing(data);
            }

            SendData(new MemoryStream(data));
        }