Skip to content

Pack as uint16 #352

@marek22k

Description

@marek22k

Hello,

I would like to rebuild a network protocol. The reference implementation is written in Go. The following MsgPack structure is available there:

type handshakeStruct struct {
	Type    uint8  `msgpack:"Y"` // MUST be 'h' for a handshake
	Magic   uint16 `msgpack:"M"`
	Version uint16 `msgpack:"V"`
	Session uint32 `msgpack:"S"`
}

Now I wanted to rebuild this in Ruby, but the length of the field "V" is different. I think this is because the version number 3 is treated as uint8 in Ruby and as uint16 in Go. How can I produce the same result in Ruby as in Go?

{
            'Y' => 'h',
            'M' => 11181,
            'V' => 3,
            'S' => @session_id
}.to_msgpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions