Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubscribeOption not working in server subscription #22

Open
morya opened this issue Aug 12, 2024 · 0 comments
Open

SubscribeOption not working in server subscription #22

morya opened this issue Aug 12, 2024 · 0 comments

Comments

@morya
Copy link

morya commented Aug 12, 2024

gocent verison: v3.3.0
centrifugo version: v4 / v5 , v3 maybe?

github.com/centrifugal/gocent/v3 v3.3.0 is not working when using with these codes:

func doServerSubscribe(client string) {
	cc := gocent.New(gocent.Config{
		Addr: "http://127.0.0.1:8000/api",
		Key:  "fake-key",
	})
	err := cc.Subscribe(context.TODO(), "foo", client, gocent.WithPresence(true), gocent.WithJoinLeave(true))
	if err != nil {
		log.Fatalf("Server Subscribe failed %v", err)
	}
}

params from gocent.WithPresence(true), gocent.WithJoinLeave(true) will be ignored from centrifugo v4 to v5

encoded json result is:

{"method":"subscribe","params":{"channel":"foo","user":"3e3fc43b-bef9-4ab5-a3da-4c96c688351e","presence":true,"join_leave":true}}

and, this will be ignored when decode from centrifugo server code,
with SubscribeRequest from internal/apiproto/api.pb.go

SubscribeRequest require all fields inside override sub field.

type SubscribeRequest struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Channel      string                   `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	User         string                   `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"`
	ExpireAt     int64                    `protobuf:"varint,3,opt,name=expire_at,json=expireAt,proto3" json:"expire_at,omitempty"`
	Info         Raw                      `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"`
	B64Info      string                   `protobuf:"bytes,5,opt,name=b64info,proto3" json:"b64info,omitempty"`
	Client       string                   `protobuf:"bytes,6,opt,name=client,proto3" json:"client,omitempty"`
	Data         Raw                      `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
	B64Data      string                   `protobuf:"bytes,8,opt,name=b64data,proto3" json:"b64data,omitempty"`
	RecoverSince *StreamPosition          `protobuf:"bytes,9,opt,name=recover_since,json=recoverSince,proto3" json:"recover_since,omitempty"`
	Override     *SubscribeOptionOverride `protobuf:"bytes,10,opt,name=override,proto3" json:"override,omitempty"`
	Session      string                   `protobuf:"bytes,11,opt,name=session,proto3" json:"session,omitempty"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant