ServiceAudience Class
Base class for providing audience information for sessions interacting with FluidContainer This can be extended by different service-specific client packages to additional parameters to the user and client details returned in IMember
Signature
export declare abstract class ServiceAudience<M extends IMember = IMember> extends TypedEventEmitter<IServiceAudienceEvents<M>> implements IServiceAudience<M>
Extends: TypedEventEmitter<IServiceAudienceEvents
Implements: IServiceAudience
Type Parameters
Parameter | Constraint | Default | Description |
---|---|---|---|
M | IMember | IMember | A service-specific member type. |
Constructors
Constructor | Description |
---|---|
(constructor)(container) | Constructs a new instance of the ServiceAudience class |
Properties
Property | Type | Description |
---|---|---|
audience | IAudience | Audience object which includes all the existing members of the container. |
container | IContainer | Fluid Container to read the audience from. |
lastMembers | Map<string, M> | Retain the most recent member list. This is so we have more information about a member leaving the audience in the removeMember event. It allows us to match the behavior of the addMember event where it only fires on a change to the members this class exposes (and would actually produce a change in what getMembers returns). It also allows us to provide the client details in the event which makes it easier to find that client connection in a map keyed on the userId and not clientId. This map will always be up-to-date in a removeMember event because it is set once at construction and in every addMember event. It is mapped clientId to M to be better work with what the IAudience event provides |
Methods
Method | Return Type | Description |
---|---|---|
createServiceMember(audienceMember) | M | Provides ability for inheriting class to modify/extend the audience object. |
getMembers() | Map<string, M> | Returns an map of all users currently in the Fluid session where key is the userId and the value is the member object. The implementation may choose to exclude certain connections from the returned map. E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users. |
getMyself() | M | undefined | Returns the current active user on this client once they are connected. Otherwise, returns undefined. |
shouldIncludeAsMember(member) | boolean | Provides ability for the inheriting class to include/omit specific members. An example use case is omitting the summarizer client. |
Constructor Details
(constructor)
Constructs a new instance of the ServiceAudience
class
Signature
constructor(
container: IContainer);
Parameters
Parameter | Type | Description |
---|---|---|
container | IContainer |
Property Details
audience
Audience object which includes all the existing members of the container.
Signature
protected readonly audience: IAudience;
Type: IAudience
container
Fluid Container to read the audience from.
Signature
protected readonly container: IContainer;
Type: IContainer
lastMembers
Retain the most recent member list. This is so we have more information about a member leaving the audience in the removeMember event. It allows us to match the behavior of the addMember event where it only fires on a change to the members this class exposes (and would actually produce a change in what getMembers returns). It also allows us to provide the client details in the event which makes it easier to find that client connection in a map keyed on the userId and not clientId. This map will always be up-to-date in a removeMember event because it is set once at construction and in every addMember event. It is mapped clientId to M to be better work with what the IAudience event provides
Signature
protected lastMembers: Map<string, M>;
Type: Map<string, M>
Method Details
createServiceMember
Provides ability for inheriting class to modify/extend the audience object.
Signature
protected abstract createServiceMember(audienceMember: IClient): M;
Parameters
Parameter | Type | Description |
---|---|---|
audienceMember | IClient | Record of a specific audience member. |
Returns
Return type: M
getMembers
Returns an map of all users currently in the Fluid session where key is the userId and the value is the member object. The implementation may choose to exclude certain connections from the returned map. E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
Signature
getMembers(): Map<string, M>;
Returns
Return type: Map<string, M>
getMyself
Returns the current active user on this client once they are connected. Otherwise, returns undefined.
Signature
getMyself(): M | undefined;
Returns
Return type: M | undefined
shouldIncludeAsMember
Provides ability for the inheriting class to include/omit specific members. An example use case is omitting the summarizer client.
Signature
protected shouldIncludeAsMember(member: IClient): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
member | IClient | Member to be included/omitted. |
Returns
Return type: boolean