1

i want to integrate pubnub with reactjs frontend and node js backend.My system consist of websocket . I want to replace websocket with pubnub connection .I have installed pubnub using npm in node js its works fine.But in front end side when i run npm start i see only below screen.

enter image description here

The problem with web socket is when connection lost i didnt get back my card details(poker game cards) Did i do something wrong?if please let me know correct way to do it. i have replaced websocket connection of existing system with pubnub.see code below.

import PubNub from 'pubnub';
import { PubNubProvider, usePubNub } from 'pubnub-react';
// import CountDownBgTask from "./containers/CountDownBgTask";
const pubnub = new PubNub({
   publishKey: 'xxxxxxxxxxxxxxxxx',
   subscribeKey: 'xxxxxxxxxxxxxxxxx'
});
componentDidMount() {
        if (isMobile) {
            setTimeout(() => {
                this.setState({
                    isOpen: true
                });
                window.scrollTo(0,1);
            },1000)
        }
        window.onbeforeunload = closingCode;
        // Read res from service via Socket IO
        // socket.on("message", receiveMsg);
        pubnub.on("message", text => {
            let params = text.split("|"); //.map(p => Base64.Decode(p)); // we are not using b64 now
            let message = params.shift(); // message, eg. playerSitOut, clearTable

            this.receiveMsg.push(message);
            this.props.updateMessage({ message, params });
        });
    }
1

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.