This is a twin project of SockJS Real-time Tracker.
It is a websocket-server template that fetches data from MongoDB at regular intervals.
- Maven 3.6.0 or higher versions
- Java 11
- MongoDB 4.4.5 or higher versions
- WebSocket
- Spring Boot
- Spring
- Sping MVC
- Clone this project on IntelliJ IDEA.
- Run
\src\main\java\com\singfung\tracker\WebSocketRealTimeTrackerApplication.java
. - Add some samples to MongoDB by running
\api-samples\saveGPS.http
. It adds the GPS information of two vehicles into MongoDB (v100
andv101
). - Open three tabs in a browser(
http://localhost:8080/v100.html
,http://localhost:8080/v101.html
andhttp://localhost:8080/v102.html
). We could see that tabv100
and tabv101
would receive the GPS information of its own vehicle every 2 seconds, whilev102
could not receive any data since its record is not found in MongoDB.