Requirements

TURTED defines a list of methods/functionalites that each module needs to implement to be interoperable

Backend

  • notifyUser(String username, String eventName, array payload)
  • notifyChannel(String channelName, String eventName, array payload)

These basic two methods or functions must be provided.
They accept a user or channel name to identify the intended recipient(s) of the event
They accept an eventName that identifies the event that will be available to listen on at the client side
They accept a payload, being an arry or object that can be transported to the client, depending on the way of transport - it mostly will be transported via JSON so it should be prepared to be convertable

COMET

Requirements on server functionality

  • The server needs to keep track of a userlist and connected clients, so events can be forwarded to a user/login name
  • The server implements (according to configuration) a verifyUser method to accept or reject a user (based on an auth token)
  • The server implements a function to allow a user to join a named channel
  • The server needs to keep track of channels and remember the logins of users that joined a channel
  • The server may (according to configuration) allow or prevent multiple connections per login name
  • The server implements a special command that accepts the request to forward the event and data to a user/channel

Client

The client implements

  • login(String userName, [String tokenToIdentify])
  • listen(String eventName, closure functionToBeCalledInCaseOfEvent())
  • join(String channelName)
  • error handling in case it gets rejected (wrong auth or already logged in (if only one connection per user enforced))