Starting a new Activity

Before starting an activity, a client must have first created a session. For more information on creating sessions, please refer to the appropriate section on session management.

To start an actvitiy, clients should make a POST request to the create_activity link of the current session:

Content-Type: application/json
POST /api/session/activities

{
    "kind": "Game",    
    "type": "urn:my-company:my-game:1"
}

Host: https://localsite.trackmanrange.com

A successful response should look like the following:

{
  "id": "6bbf9452-5c98-4835-b660-8fa2c26c6103",
  "kind": "Game",
  "type": "urn:my-company:my-game:1",
  "createdAt": "2018-03-08T12:55:10.1754358Z",
  "expiresAt": "2018-03-08T13:10:10.1794462Z",
  "players": [
    {
      "id": "205568d6-094f-4c44-9896-7fd187fcbedb",
      "sessionId": "36b0a34c-0a55-4a5c-8cf9-184697c95d8e",
      "name": "LuckyStrike"
    }
  ],
  "bays": [],
  "_links": {
    "self": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103"
    },
    "events": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/events"
    },
    "strokes": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/strokes"
    },
    "sessions": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/sessions"
    },
    "post_message": {
      "method": "POST",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/messages"
    },
    "end_activity": {
      "method": "DELETE",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103"
    },
    "leave_activity": {
      "method": "DELETE",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/me"
    },
    "invite": {
      "method": "POST",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/invitations"
    },
    "invitations": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/invitations"
    },
    "target": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/target"
    },
    "club": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/activities/6bbf9452-5c98-4835-b660-8fa2c26c6103/club"
    }
  }
}

The following table describes the meaning of all the activity links:

Link Description
club Changes the current player's selected club
end_activity Ends the activity and sends a notification to all players in the activity
events Returns a list of all the events that occured in the activity
invitations Returns a list of all pending invitations in the activity
invite Sends an invitation to another player to join the activity
leave_activity Removes the current player from the activity but does not end the activity
post_message Sends a client-specific message to everyone in the activity
sessions Returns a list of players that are part of the activity
strokes Returns a list of all strokes that were shot during the activity
target Changes the current player's selected target

Events

Bellow is a list of activity events that are sent through the Websocket channel

Activity Events

ActivityStarted

Informational message that is sent whenever a new activity is created.