ByteBuffer.Close C# (CSharp) Method

Close() public method

public Close ( ) : void
return void
    public void Close()
    {
        if (mBinaryWriter != null)
        {
            mBinaryWriter.Close();
        }

        if (mBinaryReader != null)
        {
            mBinaryReader.Close();
        }

        mMemoryStream.Close();
        mBinaryWriter = null;
        mBinaryReader = null;
        mMemoryStream = null;
    }

Usage Example

Example #1
0
    /// <summary>
    /// 发送消息给server
    /// </summary>
    /// <param name="datas"></param>
    public void SendMessage(int msgId, byte[] datas)
    {
        ByteBuffer writeBuffer = null;

        try
        {
            if (this.socket == null)
            {
                return;
            }

            writeBuffer = new ByteBuffer();

            writeBuffer.WriteInt(msgId);
            writeBuffer.WriteInt(datas.Length);
            writeBuffer.WriteBytes(datas);
            var sendBytes = writeBuffer.ToBytes();
            DebugLog(identiy, "send msg id : " + msgId + "  len: " + datas.Length);
            writeBuffer.Close();

            socket.BeginSend(sendBytes, 0, sendBytes.Length, SocketFlags.None, new AsyncCallback(this.SendMessageCallBack), socket);
        }
        catch (Exception e)
        {
            if (writeBuffer != null)
            {
                writeBuffer.Close();
            }

            DoSocketException();

            DebugLogError(identiy, e.ToString());
        }
    }
All Usage Examples Of ByteBuffer::Close