SocketCluster/socketcluster-client

Think about: Should subscribeFail trigger an error on the socket?

Opened this issue · 5 comments

Right now, 'subscribeFail' does not trigger an error on the socket and it is seen as independent from the socket itself. Maybe this behaviour should change?

hai jondobois,

please add subscribe:succeeded from serverside, because if you develop an clientdriver 'subscribe success' has no callback.

maybe callback like pusher. Pusher has pusher:subscription_succeeded, pusher:subscription_error, etc

what do you think? thanks

@odenktools The server-side socket has a 'subscribe' event which triggers when the subscription succeeds (same as client socket). https://socketcluster.io/#!/docs/api-scsocket-server

You can also use the server 'subscription' event on the SCServer object to listen to subscriptions from a central place (that way you don't need to attach event handlers to individual sockets) https://socketcluster.io/#!/docs/api-scserver

Also note that the subscription cannot fail once it hits the server (that's why there is no server-side 'subscribeFail' event); the subscription can only fail if it is blocked by the user's own middleware; but in that case the user can emit their own error events if they want.

yes on server-side has subscription event, but you must emit custom callback again right?

example my client-driver:
var pongChannel = socket.subscribe('pong');

Server side

scServer.on('connection', function (socket) {
socket.on('subscription', function (data) {
socket.emit('subscription:subscription_succeeded', 'subscription_succeeded')
});
});

@odenktools When listening on the server-side socket, it is 'subscribe'. 'subscription' is when it is emitted on the server (the arguments are different). You don't need to emit a succeeded event from the server like this, you can just listen directly to the 'subscribe' event on the client-side socket.

Currently i am build client-driver for java (android) .. client driver base on pusher java libraries .. its running very well on my android project. but when i make #subscribe event on client driver it does not happen any response on my client driver . So on my serverside, im create custom callback like client: subscribesucess.

you can see @sacOO7 libraries

https://github.com/sacOO7/socketcluster-client-java/blob/master/src/main/java/io/github/sac/Parser.java#L22-L35

we dont have any subscribe_success event. we only

  • publish
  • removeAuthToken
  • setAuthToken

thanks anyway .. maybe its out of topics. Sorry for bad english