Annotation Interface RoomService


@Target(TYPE) @Retention(RUNTIME) @Documented public @interface RoomService
Marks a class as a Room handler. Methods annotated with Message, Ready, and Disconnect will be invoked for room lifecycle events, similar to ManagedService but scoped to a Room.

Example:


 @RoomService(path = "/chat/{roomId}")
 public class ChatRoom {

     @Ready
     public void onJoin(AtmosphereResource r) {
         // invoked when a client joins the room
     }

     @Message
     public String onMessage(String message) {
         return message; // broadcast to all room members
     }

     @Disconnect
     public void onLeave(AtmosphereResourceEvent event) {
         // invoked when a client disconnects
     }
 }
 
Since:
4.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    Maximum number of messages to keep in the room history.
    The mapping path for this room handler.
  • Element Details

    • path

      String path
      The mapping path for this room handler. Supports path parameters (e.g. /chat/{roomId}).
      Returns:
      the mapping path
      Default:
      "/"
    • maxHistory

      int maxHistory
      Maximum number of messages to keep in the room history. Set to 0 to disable history (default).
      Returns:
      the max history size
      Default:
      0