Skip to content

Latest commit

 

History

History
38 lines (33 loc) · 816 Bytes

File metadata and controls

38 lines (33 loc) · 816 Bytes

Node Pusher

A simple subscribe / publish interface using Pusher

Routes

POST /push

  • Publishes a message to the pusher API
Content-Type: application/json

{
  "message": "Hello Alex",
  "channel": "my-channel",
  "event": "my-event"
}
  • To subscribe to a message, follow the html below
<!DOCTYPE html>
<head>
  <title>Pusher Test</title>
  <script src="https://js.pusher.com/4.1/pusher.min.js"></script>
  <script>

    // Enable pusher logging - don't include this in production
    Pusher.logToConsole = true;

    var pusher = new Pusher('5c395da69c6cefb9c67d', {
      cluster: 'ap1',
      encrypted: true
    });

    var channel = pusher.subscribe('my-channel');
    channel.bind('my-event', function(data) {
      alert(data.message);
    });
  </script>
</head>