Tuesday, 21 August 2018

Pubnub Integration using JS

 <script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.21.5.js">  </script>

<script type="text/javascript">
    console.log('testtt');
    var pubnub = new PubNub({
    subscribeKey: "demo",
    publishKey: "demo",
    ssl: true
})

    pubnub.subscribe({
        channels: ['mahesh']
    });

pubnub.publish({
        channel: 'mahesh',
        message: {
          sender_name: 'Langote Mahesh',
          message: "text,
          date_time: "13 jan 2018",
        }
      });

    pubnub.history(
        {
            channel: 'mahesh',
            reverse: true,
            count: 100
        },
        function (status, response) {
             var data = response.messages;
            $.each( data, function( key, value ) {
              $.each( value, function( key, value ) {
                    if (key == "entry") {
                        console.log(key + " : "+ value);
                            console.log(value.sender_name);
                            console.log(value.message);
                            console.log(value.date_time);
                    }
                });
            });
           
        }
);
 
   
       
       

No comments:

Post a Comment

Django rest api - filter

views.py from django_filters.rest_framework import DjangoFilterBackend class PollList(viewsets.ModelViewSet):     queryset = X.objects...