Package org.atmosphere.config.service
Annotation 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 ElementsModifier and TypeOptional ElementDescriptionintMaximum number of messages to keep in the room history.The mapping path for this room handler.
-
Element Details
-
path
String pathThe mapping path for this room handler. Supports path parameters (e.g./chat/{roomId}).- Returns:
- the mapping path
- Default:
"/"
-
maxHistory
int maxHistoryMaximum number of messages to keep in the room history. Set to 0 to disable history (default).- Returns:
- the max history size
- Default:
0
-