Browser notifications for PlanetSide 2 alerts.
PS2Alert.me allows a user to receive push notifications for PlanetSide 2 alerts in their browser. The application achieves this by leveraging Service Workers, the IndexedDB API, Web Storage API, Push API, Notifications API and Push Services.
The project has several components:
-
Web application (frontend - PS2Alert.me):
- Users select the PlanetSide 2 server(s) to subscribe to alert notifications for and a Service Worker is registered to receive push notifications.
-
MongoDB (Backend):
-
A user's chosen server(s) to subscribe to alert notifications for and subscription data (forming the Notify model) are stored in the database.
-
The web application and consumer interact with the database. Adding and removing Notify documents and retrieving them respectively.
-
-
RabbitMQ (Backend):
- A messaging broker where MetagameEvents (alerts) are sent from the publisher to a queue which is then consumed.
-
Publisher (Backend):
- Connects to the PlanetSide 2 WebSocket Event Stream and listens for MetagameEvents. When a MetagameEvent has the property
started
, the publisher sends the MetagameEvent to the queue.
- Connects to the PlanetSide 2 WebSocket Event Stream and listens for MetagameEvents. When a MetagameEvent has the property
-
Consumer (Backend):
- Watches the RabbitMQ queue for MetagameEvents. When a MetagameEvent occurs in the queue, find all Notify documents that are subscribed to push notifications for the server which the MetagameEvent is occurring on and send a push notification to each.
The following image provides a high level overview of the PS2Alert.me components and how they interact with one another to send a push notification.
The process of subscribing to push notifications is as follows:
-
A Service Worker is registered in the browser. The Service Worker is responsible for:
-
Saving subscription data in the browser (more on this below).
-
Handling incoming push notifications from a push service.
-
-
The chosen server(s) are retrieved and a subscription is created. The subscription contains an endpoint and encryption keys for sending a push notification securely.
-
The subscription data is saved in the browser using IndexedDB to handle future subscription updates. Details on this can be found in #3.
-
The chosen server(s) and subscription data are then sent to PS2Alert.me in JSON format:
{"subscription": { "keys": { "