Skip to content

Commit

Permalink
go: add unregistered parser
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed Jun 11, 2024
1 parent 1cd6caf commit 24ca652
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions go/parsers/unregistered.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,30 @@ import (
"github.com/xconnio/wampproto-protobuf/go/gen"
)

type Unregistered struct {
gen *gen.UnRegistered
}

func NewUnregisteredFields(gen *gen.UnRegistered) messages.UnRegisteredFields {
return &Unregistered{gen: gen}
}

func (u *Unregistered) RequestID() int64 {
return u.gen.GetRequestId()
}

func UnregisteredToProtobuf(unregistered *messages.UnRegistered) ([]byte, error) {
return nil, nil
msg := &gen.UnRegistered{
RequestId: unregistered.RequestID(),
}

data, err := proto.Marshal(msg)
if err != nil {
return nil, err
}

byteValue := byte(messages.MessageTypeUnRegistered & 0xFF)
return append([]byte{byteValue}, data...), nil
}

func ProtobufToUnregistered(data []byte) (*messages.UnRegistered, error) {
Expand All @@ -18,5 +40,5 @@ func ProtobufToUnregistered(data []byte) (*messages.UnRegistered, error) {
return nil, err
}

return nil, nil
return messages.NewUnRegisteredWithFields(NewUnregisteredFields(msg)), nil
}

0 comments on commit 24ca652

Please sign in to comment.