pusher / chatkit-server-node

Node.js SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
16 stars 9 forks source link

how to subscribe from server SDK? #43

Closed dcsan closed 4 years ago

dcsan commented 5 years ago

What?

I can't see any method from the current docs to subscribe to a room from the node/server SDK

tried based on client JS/SDK and get this:

TypeError: currentUser.subscribeToRoom is not a function
    at Rabbit.chatkit.getUserRooms.then (/Users/dc/dev/rikai/nap/web-app/server/routes/Rabbit.js:89:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)

When i try to use the client SDK it gives errors around window not defined. I guess someone hardcoded something in there.

Suggested improvements

How to get events on the server side from a room?

dcsan commented 5 years ago

there are get_room_messages and other APIs, but that's not really the point of using a realtime API. It's really weird you have an SDK with no realtime/subscribe events.

dcsan commented 5 years ago

Looking into the client SDK https://github.com/pusher/chatkit-client-js/blob/master/src/room-subscription.js

it seems like a lot of support libraries would also have to be ported from the client, CursorSubscription etc.

Is there any work done on this? It's exactly what I was hoping that chatkit would provide...

dcsan commented 5 years ago

subscribe example JS code?

is there a simple example of how to subscribe to events like #new-message https://docs.pusher.com/chatkit/reference/subscription-events#new-message

without having to use all the code in the current client. this is to get an MVP up.

dcsan commented 5 years ago

chatkit and channels

can you give any info on how the chatkit-client and your channels models work together?

does a "room" map onto a channel? can i mix the two? eg I could just use the channels SDK and subscribe to a room like:

var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
  alert('Received my-event with message: ' + data.message);
});
vivangkumar commented 5 years ago

Hi!

The server SDK does not support client side functionality. If you'd like to build a chat bot, then the best way to do this is to use web hooks. (https://docs.pusher.com/chatkit/webhooks).

Regarding channels and Chatkit, they do not work together in anyway and are completely separate products solving different problems, so you cannot mix the two.

minaorangina commented 4 years ago

Closing as stale.