diff --git a/cmd/xconn/main.go b/cmd/xconn/main.go index efbc787..7b4e552 100644 --- a/cmd/xconn/main.go +++ b/cmd/xconn/main.go @@ -11,7 +11,6 @@ import ( "golang.org/x/exp/slices" "gopkg.in/yaml.v3" - "github.com/xconnio/wampproto-protobuf/go" "github.com/xconnio/xconn-go" ) @@ -25,8 +24,6 @@ const ( ConfigDir = ".xconn" ConfigFile = ConfigDir + "/config.yaml" - - ProtobufSubProtocol = "wamp.2.protobuf" ) type cmd struct { @@ -96,10 +93,7 @@ func Run(args []string) error { for _, transport := range config.Transports { if slices.Contains(transport.Serializers, "protobuf") { - serializer := &wampprotobuf.ProtobufSerializer{} - protobufSpec := xconn.NewWSSerializerSpec(ProtobufSubProtocol, serializer) - - if err := server.RegisterSpec(protobufSpec); err != nil { + if err := server.RegisterSpec(xconn.ProtobufSerializerSpec); err != nil { return err } } diff --git a/go.mod b/go.mod index 1b5d2b0..2ef2f04 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/gobwas/ws v1.4.0 github.com/stretchr/testify v1.8.4 github.com/xconnio/wampproto-go v0.0.0-20240630150305-316020c30fb7 - github.com/xconnio/wampproto-protobuf/go v0.0.0-20240611092706-1e859744b5a2 + github.com/xconnio/wampproto-protobuf/go v0.0.0-20240701141955-e9a1025ec125 golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index ac5fad1..de0386d 100644 --- a/go.sum +++ b/go.sum @@ -40,6 +40,7 @@ github.com/xconnio/wampproto-go v0.0.0-20240630150305-316020c30fb7 h1:DrQEqUq14X github.com/xconnio/wampproto-go v0.0.0-20240630150305-316020c30fb7/go.mod h1:/b7EyR1X9EkOHPQBJGz1KvdjClo1GsalBGIzjQU5+i4= github.com/xconnio/wampproto-protobuf/go v0.0.0-20240611092706-1e859744b5a2 h1:1WkQ68ICoin0wTerMn5FrWl+ZbK4XS3/W2Wr86jS9K8= github.com/xconnio/wampproto-protobuf/go v0.0.0-20240611092706-1e859744b5a2/go.mod h1:SZAkbKSDucIUBrPgcKlT0SzVmktfrsD7OdP1chFR+vw= +github.com/xconnio/wampproto-protobuf/go v0.0.0-20240701141955-e9a1025ec125/go.mod h1:SZAkbKSDucIUBrPgcKlT0SzVmktfrsD7OdP1chFR+vw= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= diff --git a/types.go b/types.go index f227246..fc7be08 100644 --- a/types.go +++ b/types.go @@ -7,6 +7,7 @@ import ( "github.com/xconnio/wampproto-go/messages" "github.com/xconnio/wampproto-go/serializers" + wampprotobuf "github.com/xconnio/wampproto-protobuf/go" ) type ( @@ -27,6 +28,8 @@ var ( CborWebsocketProtocol, &serializers.CBORSerializer{}) MsgPackSerializerSpec = NewWSSerializerSpec( //nolint:gochecknoglobals MsgpackWebsocketProtocol, &serializers.MsgPackSerializer{}) + ProtobufSerializerSpec = NewWSSerializerSpec( //nolint:gochecknoglobals + ProtobufSubProtocol, &wampprotobuf.ProtobufSerializer{}) ) type BaseSession interface { diff --git a/wamp.go b/wamp.go index e8048f9..ea71daf 100644 --- a/wamp.go +++ b/wamp.go @@ -4,4 +4,5 @@ const ( JsonWebsocketProtocol = "wamp.2.json" MsgpackWebsocketProtocol = "wamp.2.msgpack" CborWebsocketProtocol = "wamp.2.cbor" + ProtobufSubProtocol = "wamp.2.protobuf" )