Class CometdWebConferencingService
java.lang.Object
org.exoplatform.webconferencing.cometd.CometdWebConferencingService
- All Implemented Interfaces:
org.picocontainer.Startable
Created by The eXo Platform SAS.
- Version:
- $Id: CometdWebConferencingService.java 00000 Aug 17, 2017 pnedonosko $
- Author:
- Peter Nedonosko
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe Class CallEventProxy.static classThe Class CallParticipantEvent (joined and leaved participant).classThe Class CallService.static classThe Class CallStateEvent (started, stopped calls).static classThe Class CallEventProxy.static classThe Class UserCallProxy. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum threads per CPU for thread executors of user call channel.static final intQueue size per CPU for thread executors of user call channel.static final StringThe Constant CALL_SUBSCRIPTION_CHANNEL_NAME.static final StringThe Constant CALL_SUBSCRIPTION_CHANNEL_NAME_ALL.static final StringThe Constant CALL_SUBSCRIPTION_CHANNEL_NAME_PATTERN.static final StringThread name used for calls executor.protected final ExecutorServiceThe call handlers.protected final CallLogServiceThe call logs.static final StringThe Constant CALLS_CHANNEL_NAME.static final StringThe Constant COMMAND_ADD_GUEST.static final StringThe Constant COMMAND_CHECK_INVITE.static final StringThe Constant COMMAND_CREATE.static final StringThe Constant COMMAND_CREATE_ORIGINS.static final StringThe Constant COMMAND_DELETE.static final StringThe Constant COMMAND_GET.static final StringThe Constant COMMAND_GET_CALLS_STATE.static final StringThe Constant COMMAND_GET_ORG_IDENTITIES.static final StringThe Constant COMMAND_UPDATE.static final StringThe Constant COMMAND_UPDATE_INVITES.static final StringThe Constant EVENT_CALL_JOINED.static final StringThe Constant EVENT_CALL_LEAVED.static final StringThe Constant EVENT_CALL_STATE.protected final org.mortbay.cometd.continuation.EXoContinuationBayeuxThe exo bayeux.protected final org.exoplatform.services.security.IdentityRegistryThe identity registry.protected final ScheduledExecutorServiceThe timer delaying what follows the end of a call window's connection by the leave grace time.static final StringThe Constant LOG_OK.static final StringThe Constant LOGS_CHANNEL_NAME.static final intMinimal number of threads maximum possible for remote calls' thread executors.static final intBase minimum number of threads for remote calls' thread executors.protected final org.exoplatform.services.organization.OrganizationServiceThe organization.protected final CometdWebConferencingService.CallServiceThe service.static final intThread idle time for thread executors (in seconds).static final StringThe Constant USER_CACHE_NAME.static final StringThe Constant USER_SUBSCRIPTION_CHANNEL_NAME.static final StringThe Constant USER_SUBSCRIPTION_CHANNEL_PATTERN.protected final org.exoplatform.services.cache.ExoCache<String, CometdWebConferencingService.UserCallProxy> Cache of connected users.protected final WebConferencingServiceThe web conferencing. -
Constructor Summary
ConstructorsConstructorDescriptionCometdWebConferencingService(org.exoplatform.services.security.IdentityRegistry identityRegistry, org.exoplatform.services.organization.OrganizationService organization, WebConferencingService webConferencing, org.mortbay.cometd.continuation.EXoContinuationBayeux exoBayeux, org.exoplatform.services.cache.CacheService cacheService, CallLogService callLogs) Instantiates a new CometD interaction service for WebConferencing. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterLeaveGrace(Runnable task) Runs a task once the leave grace time passed (seeWebConferencingService.getLeaveGraceTime()): a call window whose connection ended, reloaded or reconnected, joins the call again meanwhile, which keeps its user in the call.protected booleanReturn true if it's Boolean instance of TRUE or false if it is not.protected <T> List<T> As list.protected StringReturn object if it's String instance or null if it is not.protected StringCall id.protected StringchannelsAsString(Set<org.cometd.bayeux.server.ServerChannel> channels) Channels as string.protected StringchannelUserId(String channelId) Channel user id.protected ExecutorServicecreateThreadExecutor(String threadNamePrefix, int maxFactor, int queueFactor) Create a new thread executor service.protected StringcurrentUserId(org.cometd.bayeux.server.ServerMessage message) Current user id.Gets the cometd server path.getUserToken(String userId) Gets the user token.protected List<InvitedIdentity> Invited identities list.protected booleanisSessionUser(String userId, org.cometd.bayeux.server.ServerSession session) Tells whether a user is the one the CometD session was opened for, as the handshake recorded it after checking the user's token.protected static booleanisUpdatableState(String state) Tells if a client can set this state on a call through the update command.voidstart()voidstop()Ends the leave grace timer, then the call commands: no new command starts, and the stop waits up toCALL_STOP_WAIT_SECONDSseconds for the commands already submitted, a leave or a stop of a call among them, so that they reach the store before the node goes down.protected voidstopCallOfRemovedChannel(String callId, long removedAt) Stops a call whose channel has no subscriber left: its parties are assumed gone.protected CallInfoApplies a state sent by a client to a call: a participant state applies tocurrentUserId, which is theexoIdof the client's message.
-
Field Details
-
CALLS_CHANNEL_NAME
-
LOGS_CHANNEL_NAME
-
CALL_SUBSCRIPTION_CHANNEL_NAME
The Constant CALL_SUBSCRIPTION_CHANNEL_NAME.- See Also:
-
CALL_SUBSCRIPTION_CHANNEL_NAME_ALL
The Constant CALL_SUBSCRIPTION_CHANNEL_NAME_ALL.- See Also:
-
CALL_SUBSCRIPTION_CHANNEL_NAME_PATTERN
The Constant CALL_SUBSCRIPTION_CHANNEL_NAME_PATTERN.- See Also:
-
USER_SUBSCRIPTION_CHANNEL_NAME
The Constant USER_SUBSCRIPTION_CHANNEL_NAME.- See Also:
-
USER_SUBSCRIPTION_CHANNEL_PATTERN
The Constant USER_SUBSCRIPTION_CHANNEL_PATTERN.- See Also:
-
USER_CACHE_NAME
The Constant USER_CACHE_NAME. -
COMMAND_GET
-
COMMAND_CREATE
-
COMMAND_CREATE_ORIGINS
-
COMMAND_UPDATE
-
COMMAND_DELETE
-
COMMAND_ADD_GUEST
-
COMMAND_UPDATE_INVITES
-
COMMAND_CHECK_INVITE
-
COMMAND_GET_CALLS_STATE
-
COMMAND_GET_ORG_IDENTITIES
The Constant COMMAND_GET_ORG_IDENTITIES.- See Also:
-
EVENT_CALL_LEAVED
-
EVENT_CALL_JOINED
-
EVENT_CALL_STATE
-
LOG_OK
-
MIN_THREADS
public static final int MIN_THREADSBase minimum number of threads for remote calls' thread executors.- See Also:
-
MIN_MAX_THREADS
public static final int MIN_MAX_THREADSMinimal number of threads maximum possible for remote calls' thread executors.- See Also:
-
THREAD_IDLE_TIME
public static final int THREAD_IDLE_TIMEThread idle time for thread executors (in seconds).- See Also:
-
CALL_MAX_FACTOR
public static final int CALL_MAX_FACTORMaximum threads per CPU for thread executors of user call channel.- See Also:
-
CALL_QUEUE_FACTOR
public static final int CALL_QUEUE_FACTORQueue size per CPU for thread executors of user call channel.- See Also:
-
CALL_THREAD_PREFIX
-
webConferencing
The web conferencing. -
exoBayeux
protected final org.mortbay.cometd.continuation.EXoContinuationBayeux exoBayeuxThe exo bayeux. -
service
The service. -
organization
protected final org.exoplatform.services.organization.OrganizationService organizationThe organization. -
identityRegistry
protected final org.exoplatform.services.security.IdentityRegistry identityRegistryThe identity registry. -
callLogs
The call logs. -
callHandlers
The call handlers. -
leaveGraceTimer
The timer delaying what follows the end of a call window's connection by the leave grace time. -
usersCache
protected final org.exoplatform.services.cache.ExoCache<String, CometdWebConferencingService.UserCallProxy> usersCacheCache of connected users.
-
-
Constructor Details
-
CometdWebConferencingService
public CometdWebConferencingService(org.exoplatform.services.security.IdentityRegistry identityRegistry, org.exoplatform.services.organization.OrganizationService organization, WebConferencingService webConferencing, org.mortbay.cometd.continuation.EXoContinuationBayeux exoBayeux, org.exoplatform.services.cache.CacheService cacheService, CallLogService callLogs) Instantiates a new CometD interaction service for WebConferencing.- Parameters:
identityRegistry- the identity registryorganization- the organizationwebConferencing- the web conferencingexoBayeux- the exo bayeuxcacheService- the cache servicecallLogs- the call logs
-
-
Method Details
-
afterLeaveGrace
Runs a task once the leave grace time passed (seeWebConferencingService.getLeaveGraceTime()): a call window whose connection ended, reloaded or reconnected, joins the call again meanwhile, which keeps its user in the call.- Parameters:
task- the task
-
isUpdatableState
Tells if a client can set this state on a call through the update command.- Parameters:
state- the state sent by the client- Returns:
trueif the state is a call or a participant state the update command applies
-
stopCallOfRemovedChannel
protected void stopCallOfRemovedChannel(String callId, long removedAt) throws WebConferencingException Stops a call whose channel has no subscriber left: its parties are assumed gone. A call read as stopped, as the leave of its last party leaves it, is not stopped again, nor a call started again since the channel was removed, its start read withinWebConferencingService.LAST_DATE_PRECISION. The read takes no lock: a leave still running on another handler thread can stop the call after this read.- Parameters:
callId- the call idremovedAt- when the channel was removed, in milliseconds- Throws:
WebConferencingException- if the call cannot be read or stopped
-
updateCallState
protected CallInfo updateCallState(String id, String state, String currentUserId, String clientId, String sessionId) throws WebConferencingException Applies a state sent by a client to a call: a participant state applies tocurrentUserId, which is theexoIdof the client's message. A decline applies only to the user the Cometd session was opened for.- Parameters:
id- the call idstate- the state, one ofisUpdatableState(String)currentUserId- theexoIdof the client's messageclientId- the client idsessionId- the id of the Cometd session the message came from- Returns:
- the call info,
nullif the call was not found - Throws:
ParticipantNotFoundException- if a decline names a user the session was not opened forWebConferencingException- if the call cannot be updated
-
start
public void start()- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()Ends the leave grace timer, then the call commands: no new command starts, and the stop waits up toCALL_STOP_WAIT_SECONDSseconds for the commands already submitted, a leave or a stop of a call among them, so that they reach the store before the node goes down. A command still running past that wait is not waited for: its thread is a daemon and ends with the JVM. A command submitted after the stop is dropped.- Specified by:
stopin interfaceorg.picocontainer.Startable
-
getCometdServerPath
-
getUserToken
-
isSessionUser
Tells whether a user is the one the CometD session was opened for, as the handshake recorded it after checking the user's token.- Parameters:
userId- the user a client message namessession- the server session the message came from- Returns:
trueif the session was opened for that user,falseotherwise
-
currentUserId
Current user id.- Parameters:
message- the message- Returns:
- the string, if user cannot be defined it will be
IdentityConstants.ANONIM
-
channelUserId
Channel user id. It's assumed an user channelUSER_SUBSCRIPTION_CHANNEL_NAME.- Parameters:
channelId- the channel id- Returns:
- the string
- Throws:
IndexOutOfBoundsException- if channel id doesn't look like an user channel
-
channelsAsString
-
callId
-
asString
-
asBoolean
Return true if it's Boolean instance of TRUE or false if it is not.- Parameters:
obj- the obj- Returns:
- the boolean
-
asList
-
invitedIdentitiesFromJson
Invited identities list.- Parameters:
obj- the obj- Returns:
- the list
-
createThreadExecutor
protected ExecutorService createThreadExecutor(String threadNamePrefix, int maxFactor, int queueFactor) Create a new thread executor service.- Parameters:
threadNamePrefix- the thread name prefixmaxFactor- - max processes per CPU corequeueFactor- - queue size per CPU core- Returns:
- the executor service
-