Beispiel #1
0
        public static ServerResponseCommand FromStream(Stream stream)
        {
            var br      = new BinaryReader(stream);
            var command = new ServerResponseCommand();

            command.statusCode   = (StatusCode)br.ReadInt32();
            command.responseType = (ServerResponseType)br.ReadInt32();

            var messageLength = br.ReadInt32();

            command.Message = CommandUtils.GetString(br.ReadBytes(messageLength));

            return(command);
        }
Beispiel #2
0
        public static ServerResponseCommand FromBytes(byte[] bytes)
        {
            using (var ms = new MemoryStream(bytes))
            {
                var br      = new BinaryReader(ms);
                var command = new ServerResponseCommand();

                command.statusCode   = (StatusCode)br.ReadInt32();
                command.responseType = (ServerResponseType)br.ReadInt32();

                var messageLength = br.ReadInt32();
                command.Message = CommandUtils.GetString(br.ReadBytes(messageLength));

                return(command);
            }
        }