- Clone the respository
- Run
./gradlew shaowJarto build the server - To start the server with default configuration run
java -jar web/build/distributions/trumpet-server-1.0.0-shadow.jarWhen bootstrapping tha application will scan for configurations in the order described below. Properties defined in one file has precedence over properties defined later in the list of sources.
file:trumpet.config
file:~/.trumpet.config
file:/etc/trumpet.config
Default port: 9191 Default host: 0.0.0.0
java -Dserver.http.port=9999 -Dserver.http.host=localhost -Dgcm.apiKey=GCM_API_KEY -jar trumpet-server-1.0.0-shadow.jar
curl "http://localhost:9191/api/"
Response: 200
{
"_links": {
"create-trumpeteer": { "href" : "http://localhost:9191/api/trumpeteers/" },
}
}curl -X POST --data "type=sse®istrationID=32314234234&latitude=55.583985&longitude=12.957578&accuracy=100" http://localhost:9191/api/trumpeteers
The form parameter type can be : sse | gcm Only type 'sse' will produce "sse-subscribe" link Only type 'gcm' will have a registrationID parameter "self" link supports GET and DELETE Response: Content-type: application/json
{
"type": "sse",
"trumpeteerId" : 1,
"maxMessageLength" : 220,
"maxDistance" : 200,
"_links": {
"sse-subscribe": { "href" : "http://localhost:9191/api/trumpeteers/1/subscription/sse" },
"self": { "href" : "http://localhost:9191/api/trumpeteers/1" },
"update-location": { "href" : "http://localhost:9191/api/trumpeteers/1/location" },
"trumpet": { "href" : "http://localhost:9191/api/trumpeteers/1/trumpet" },
}
}curl -X DELETE http://localhost:9191/api/trumpeteers/1
Unsubscribe the supplied trumpeteers
curl -X GET "Accept: application/json" http://localhost:9191/api/trumpeteers/1?distance=200
Response:
{
"trumpeteersInRange": 12
}curl -X PUT -H --data "latitude=55.583985&longitude=12.957578&accuracy=10" http://localhost:9191/api/trumpeteers/1/location
Response: 200 no content
curl -X POST --data "message=This is my first trumpet&distance=200&topic=foo" http://localhost:9191/api/trumpeteers/1/trumpet
The form parameter distance is optional Response: Content-type: application/json
{
"trumpetId": "121212121"
}- Open EventSource to entry point link with rel 'subscription' returned when POSTING to ep:subscriptions
- Message to subscribe to is 'trumpet'
- Message format is:
{
"messageType" : "trumpet",
"message" : {
"id": "1",
"timestamp": 121212122,
"message": "foo",
"topic": "bar",
"distanceFromSource": 240,
"accuracy": 10,
"sentByMe": false
}
}Notification of trumpeters in range is triggered when other trumpeteers update their location:
{
"messageType" : "trumpeteersInRange",
"message" : {
"trumpeteersInRange": "1"
}
}