Package org.eclipse.emf.cdo.session.remote

# Interface CDORemoteSessionManager

All Superinterfaces:
  `org.eclipse.net4j.util.container.IContainer<CDORemoteSession>`, `org.eclipse.net4j.util.event.INotifier`

All Known Subinterfaces:
  `InternalCDORemoteSessionManager`

public interface CDORemoteSessionManager extends org.eclipse.net4j.util.container.IContainer<CDORemoteSession>
Provides collaborative access to the `remote sessions` that are connected to the same repository as the `local session`. A CDORemoteSessionManager can be subscribed or unsubscribed to changes in the set of remote sessions. It is subscribed if at least one is true:

1. At least one `listener` is registered with this remote session manager.
2. At least one `topic` is subscribed with this remote session manager.
3. `Force subscription` is `true`.

If this remote session manager is subscribed it eventually fires the following `events` to `registered` listeners:

- `IContainerEvent` with `CDORemoteSession` as generic type argument to reflect opened or closed remote sessions.
- `CDORemoteSessionEvent.SubscriptionChanged` to reflect the ability of the remote session to receive and possibly handle remote messages from other sessions.
- `CDORemoteSessionEvent.MessageReceived` to deliver custom data `sent` from other sessions.

Since:
  2.0
Author:
  Eike Stepper
No Implement
  This interface is not intended to be implemented by clients.
No Extend
  This interface is not intended to be extended by clients.

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static class`
`CDORemoteSessionManager.EventAdapter`
A default adapter for all kinds of `remote session` related events.
`static interface`
`CDORemoteSessionManager.LocalSubscriptionChangedEvent`
An `event` that is fired by a `remote session manager` after the `subscription mode` of the `local session` changed.

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.container.IContainer

`org.eclipse.net4j.util.container.IContainer.Modifiable<E>, org.eclipse.net4j.util.container.IContainer.Persistable<E>, org.eclipse.net4j.util.container.IContainer.Persistence<E>`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

`org.eclipse.net4j.util.event.INotifier.INotifier2`

## Method Summary

Modifier and Type
Method
Description
`CDOSession`
`getLocalSession()`
Returns the `local session` this CDORemoteSessionManager belongs to.
`CDORemoteSession`
`getRemoteSession(int sessionID)`
Returns the `remote session` with the given `sessionID`, if it is currently connected to the same repository as the `local session`, `null` otherwise.
`CDORemoteSession[]`
`getRemoteSessions()`
Returns the set of `remote sessions` that are connected to the same repository as the `local session`.
`CDORemoteSession[]`
`getRemoteSessions(String userID)`
Returns the set of `remote sessions` that are connected to the same repository as the `local session` and have the given `userID`.
`CDORemoteTopic`
`getSubscribedTopic(String id)`
Returns the `topic` with the given `id`, if it is currently subscribed, `null` otherwise.
`CDORemoteTopic[]`
`getSubscribedTopics()`
Returns an array of the currently subscribed `topics`.
`boolean`
`isForceSubscription()`
Returns `true` if this CDORemoteSessionManager shall be subscribed to changes in the set of remote sessions and delivers `custom data events` even if no `listener` is registered and no `topic` is subscribed, `false` otherwise.
`boolean`
`isSubscribed()`
Returns `true` if this CDORemoteSessionManager is subscribed to changes in the set of remote sessions and delivers `custom data events`, `false` otherwise.
`Set<CDORemoteSession>`
`sendMessage(CDORemoteSessionMessage message, Collection<CDORemoteSession> recipients)`
Same as `sendMessage(CDORemoteSessionMessage, CDORemoteSession...)` but with a recipients `collection`.
`Set<CDORemoteSession>`
`sendMessage(CDORemoteSessionMessage message, CDORemoteSession... recipients)`
Sends a multicast message to the subscribed recipients.
`void`
`setForceSubscription(boolean forceSubscription)`
Enables or disables subscription to changes in the set of remote sessions even if no `listener` is registered and no `topic` is subscribed.
`CDORemoteTopic`
`subscribeTopic(String id)`
Subscribes to the topic identified by the given `id`.

### Methods inherited from interface org.eclipse.net4j.util.container.IContainer

`getElements, isEmpty`

### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

`addListener, getListeners, hasListeners, removeListener`

## Method Details

### getLocalSession

CDOSession getLocalSession()
Returns the `local session` this CDORemoteSessionManager belongs to.

### getRemoteSessions

CDORemoteSession[] getRemoteSessions()
Returns the set of `remote sessions` that are connected to the same repository as the `local session`. If this CDORemoteSessionManager itself is `subscribed` the result is returned from a local cache for remote sessions, otherwise it is requested from the server each time this method is called.

### getRemoteSessions

CDORemoteSession[] getRemoteSessions(String userID)
Returns the set of `remote sessions` that are connected to the same repository as the `local session` and have the given `userID`. If this CDORemoteSessionManager itself is `subscribed` the result is returned from a local cache for remote sessions, otherwise it is requested from the server each time this method is called.

Since:
  4.29

### getRemoteSession

CDORemoteSession getRemoteSession(int sessionID)
Returns the `remote session` with the given `sessionID`, if it is currently connected to the same repository as the `local session`, `null` otherwise. If this CDORemoteSessionManager itself is `subscribed` the result is returned from a local cache for remote sessions, otherwise it is requested from the server each time this method is called.

Since:
  4.29

### isSubscribed

boolean isSubscribed()
Returns `true` if this CDORemoteSessionManager is subscribed to changes in the set of remote sessions and delivers `custom data events`, `false` otherwise. It is subscribed if at least one is true:

1. At least one `listener` is registered with this remote session manager.
2. At least one `topic` is subscribed with this remote session manager.
3. `Force subscription` is `true`.

See Also:
  - `INotifier.addListener(IListener)`
  - `subscribeTopic(String)`
  - `setForceSubscription(boolean)`

### isForceSubscription

boolean isForceSubscription()
Returns `true` if this CDORemoteSessionManager shall be subscribed to changes in the set of remote sessions and delivers `custom data events` even if no `listener` is registered and no `topic` is subscribed, `false` otherwise.

See Also:
  - `INotifier.addListener(IListener)`
  - `subscribeTopic(String)`
  - `setForceSubscription(boolean)`

### setForceSubscription

void setForceSubscription(boolean forceSubscription)
Enables or disables subscription to changes in the set of remote sessions even if no `listener` is registered and no `topic` is subscribed.

See Also:
  - `INotifier.addListener(IListener)`
  - `subscribeTopic(String)`
  - `setForceSubscription(boolean)`

### sendMessage

Set<CDORemoteSession> sendMessage(CDORemoteSessionMessage message, CDORemoteSession... recipients)
Sends a multicast message to the subscribed recipients.

Returns:
  The set of `recipients` that the message has been forwarded to by the server. Note: No assumption must be made on whether a recipient session received the message and was able to handle it adequately!
Since:
  3.0

### sendMessage

Set<CDORemoteSession> sendMessage(CDORemoteSessionMessage message, Collection<CDORemoteSession> recipients)
Same as `sendMessage(CDORemoteSessionMessage, CDORemoteSession...)` but with a recipients `collection`.

Since:
  3.0

### subscribeTopic

CDORemoteTopic subscribeTopic(String id)
Subscribes to the topic identified by the given `id`.

Returns:
  The subscribed `topic`.
Since:
  4.17

### getSubscribedTopic

CDORemoteTopic getSubscribedTopic(String id)
Returns the `topic` with the given `id`, if it is currently subscribed, `null` otherwise.

Since:
  4.19

### getSubscribedTopics

CDORemoteTopic[] getSubscribedTopics()
Returns an array of the currently subscribed `topics`.

Since:
  4.17