public async Task <IMessage> Decode(BinaryReader reader)
        {
            await readLock.WaitAsync();

            try
            {
                int count = await reader.ReadInt32();

                MessageType messageType = (MessageType)await reader.ReadByte();

                switch (messageType)
                {
                case MessageType.Notification:
                {
                    Notification notification = new Notification();
                    notification.CommandID = await reader.ReadInt32();

                    notification.Sequence = await reader.ReadUInt32();

                    notification.ContentType = await reader.ReadInt16();

                    byte[] buffer = new byte[count - 11];
                    await reader.Read(buffer, 0, buffer.Length);

                    notification.Content = buffer;
                    return(notification);
                }

                case MessageType.Response:
                {
                    Response response = new Response();
                    response.Status = await reader.ReadInt32();

                    response.Sequence = await reader.ReadUInt32();

                    response.ContentType = await reader.ReadInt16();

                    byte[] buffer = new byte[count - 11];
                    await reader.Read(buffer, 0, buffer.Length);

                    response.Content = buffer;
                    return(response);
                }

                case MessageType.Request:
                {
                    //客户端解码器不需要解码Request类型
                    Request request = new Request();
                    request.CommandID = await reader.ReadInt32();

                    request.Sequence = await reader.ReadUInt32();

                    request.ContentType = await reader.ReadInt16();

                    byte[] buffer = new byte[count - 11];
                    await reader.Read(buffer, 0, buffer.Length);

                    request.Content = buffer;
                    return(request);
                }
                }

                throw new IOException();
            }
            finally
            {
                readLock.Release();
            }
        }