Here you can easily test pushing data to browsers with Fastly Pub/Sub. This page connects to the service using the JavaScript EventSource API.
Initializing...
This page is subscribed to the topic "35b16767", and will display the results below:
Open this page in a separate window to see how pushing from either window will cause both windows to receive the message.
This page is using the following JavaScript to subscribe to events:
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjRkYWFiMDA3In0.eyJ4LWZhc3RseS1yZWFkIjpbIjM1YjE2NzY3Il0sIngtZmFzdGx5LXdyaXRlIjpbIjM1YjE2NzY3Il0sImlhdCI6MTc0NzQzMDMwOSwiZXhwIjoxNzQ3NDMzOTA5fQ.bAtfJQnOsHJJOa3_VNGqangj0_Fyco3y8ycl8pFoNfI"; const es = new EventSource('https://pubsub-test.edgecompute.app/events?topic=35b16767&auth=' + token); es.addEventListener('message', function (event) { $('#output').text(event.data); }, false);
And here's a curl command that you can use to publish on your own. It contains an authentication token that lasts for 1 hour:
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjRkYWFiMDA3In0.eyJ4LWZhc3RseS1yZWFkIjpbIjM1YjE2NzY3Il0sIngtZmFzdGx5LXdyaXRlIjpbIjM1YjE2NzY3Il0sImlhdCI6MTc0NzQzMDMwOSwiZXhwIjoxNzQ3NDMzOTA5fQ.bAtfJQnOsHJJOa3_VNGqangj0_Fyco3y8ycl8pFoNfI" -d "hello world" "https://pubsub-test.edgecompute.app/events?topic=35b16767"