how to receive messages from clients to server using pubnub.
Can i subscribe to a channel and listen to it in server end(node.js)?
Need to use pubnub for following scenario:-
=> Lot of users namely, depositors and withdrawers want to send their details to "P2P" microservice via web sockets.
=> depositors and withdrawers are at client end and P2P microservice is a server end(built in node.js).
=> Now, with pubnub i'am able get this functionality such as :- server is able to publish messages to a channel and client in the browsers are able to listen to those messages through websockets.
=> But i need the opposite functionality that is , client will publish messages in a channel after subscribing to it and server(Node.js) must be able to listen to that messages.
Server.js
const publishConfig = {
channel: "pubnub_onboarding_channel",
message: { "sender": uuid, "content": "Hello From Node.js SDK" }
}
pubnub.addListener({
message: function (message) {
console.log(message);
},
presence: function (presenceEvent) {
console.log(presenceEvent);
}
}); // What is this listener? is it supposed to listen the messages from client? no messages are received here
pubnub.subscribe({
channel: "pubnub_onboarding_channel",
withPresence: true,
}); // This function is used for subscribing to channel
pubnub.publish(publishConfig, function (status, response) {
console.log(status, response);
}); // This is to again publish to client