Event Streams

Subscribe to events for a Tugboat object by joining its event stream. The type can be one of event, history, or log. If not specified, event is used.

socket.emit('join', { id: objectId, type: type });

If authenticated with an admin API key, an optional authkey can be provided to impersonate another user, allowing Tugboat to handle the permission checking

socket.emit('join', { id: objectId, type: type, authkey: keyId });

An optional callback function can also be provided to determine whether joining the stream was successful

socket.emit('join', { id: objectId, type: type }, function (err) {
    if (err) {
        console.log('Failed to join event stream');
    }
});

To stop receiving events for an object, leave the event stream. If no type is specified here, events for all types will be stopped.

socket.emit('leave', { id: objectId, type: type });

Event Types

Event

Events that come back will be among the following

  • create - A child object was created. The child object is included in the response.
  • update - The object was updated. The new object is included in the response.
  • remove - The object was removed. Only the ID is included in the response.

Log

  • log: level, message

History

  • history: event

Progress

  • progress: event

Special Event Streams

In addition to subscribing to an event stream by ID, there are some special streams that can be subscribed to that do not correspond with a specific object.

  • projects - Receive events when projects are created
  • agents - Receive events when agents register or unregister. Requires admin privileges
  • keys - Receive events when keys are created. Requires admin privileges

results matching ""

    No results matching ""