Beispiel #1
0
        public void SendAsync(byte[] data)
        {
            if (!IsConnected)
            {
                throw new InvalidOperationException("The client has not connected to server.");
            }

            _client.BeginSend(data);
        }
        public void BeginSend(byte[] data, int offset, int count)
        {
            if (!IsConnected)
            {
                throw new InvalidOperationException("The client has not connected to server.");
            }

            _client.BeginSend(data, offset, count);
        }
        public void SendMessage(TcpSendMsg msg, bool immediate)
        {
            msg.Encode();
            msg.SendImmediate = immediate;

            if (Interlocked.Read(ref tcpSocketState) == 1)
            {
                if (immediate)
                {
                    tcpClient.BeginSend(msg.Packet, msg);
                }
                else
                {
                    EnqueueSendMsgPool(msg);
                    SendMsgPacket();
                }
            }
        }