예제 #1
0
    public void Send(object msg)
    {
        if (_socket == null || !_socket.Connected || _isConnecting || _isCloseing)
        {
            return;
        }

        var sendBytes = Packer.Encode(msg);

        _sendQueue.EnqueueFrom(sendBytes);
        if (_sendQueue.Count == 1)
        {
            var node = _sendQueue.Peek();
            _socket.BeginSend(node.Bytes, node.ReadIdx, node.Length, 0, SendCallback, _socket);
        }
    }