diff --git a/serializers/cbor.go b/serializers/cbor.go index 9a31def..a0c8a06 100644 --- a/serializers/cbor.go +++ b/serializers/cbor.go @@ -9,6 +9,8 @@ import ( "github.com/xconnio/wampproto-go/messages" ) +const CBORSerializerID = 3 + var cborEncoder cbor.DecMode //nolint:gochecknoglobals type CBORSerializer struct{} @@ -44,16 +46,16 @@ func (c *CBORSerializer) Static() bool { return false } -func EncodeCBOR(args []any, kwargs map[string]any) ([]byte, int, error) { +func EncodeCBOR(args []any, kwargs map[string]any) ([]byte, error) { var payload []any payload = append(payload, args) payload = append(payload, kwargs) payloadData, err := cbor.Marshal(payload) if err != nil { - return nil, 0, err + return nil, err } - return payloadData, CBORSerializerValue, nil + return payloadData, nil } func DecodeCBOR(data []byte) ([]any, map[string]any, error) { diff --git a/serializers/helpers.go b/serializers/helpers.go index e99991d..71ed802 100644 --- a/serializers/helpers.go +++ b/serializers/helpers.go @@ -6,13 +6,6 @@ import ( "github.com/xconnio/wampproto-go/messages" ) -const ( - JSONSerializerValue = 1 - MsgPackSerializerValue = 2 - CBORSerializerValue = 3 - ProtobufSerializerValue = 16 -) - func ToMessage(wampMsg []any) (messages.Message, error) { messageType, _ := messages.AsInt64(wampMsg[0]) var msg messages.Message diff --git a/serializers/json.go b/serializers/json.go index d5ccd44..f6f0c83 100644 --- a/serializers/json.go +++ b/serializers/json.go @@ -6,6 +6,8 @@ import ( "github.com/xconnio/wampproto-go/messages" ) +const JSONSerializerID = 1 + type JSONSerializer struct{} func (j *JSONSerializer) Serialize(message messages.Message) ([]byte, error) { diff --git a/serializers/msgpack.go b/serializers/msgpack.go index 7bf3d9e..d52d452 100644 --- a/serializers/msgpack.go +++ b/serializers/msgpack.go @@ -6,6 +6,8 @@ import ( "github.com/xconnio/wampproto-go/messages" ) +const MsgPackSerializerID = 2 + type MsgPackSerializer struct{} func (m *MsgPackSerializer) Serialize(message messages.Message) ([]byte, error) {