ServiceAudience Class

Packages > fluid-framework > ServiceAudience

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: IServiceAudienceEvents

Implements: IServiceAudience

Type parameters:

M – A service-specific member type.

Constructors

List of constructors for this class
Constructor Modifiers Description
(constructor)(container) Constructs a new instance of the ServiceAudience class

Properties

List of properties for this class
Property Modifiers Type Description
audience IAudience
container
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

Methods

List of methods on this class
Method Modifiers Description
createServiceMember(audienceMember)
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.
getMyself() Returns the current active user on this client once they are connected. Otherwise, returns undefined.
shouldIncludeAsMember(member)

Constructors

ServiceAudience.(constructor)

Constructs a new instance of the ServiceAudience class

Signature:

constructor(container: IContainer);

Parameters

List of parameters
Parameter Type Description
container

Properties

audience

Signature:

protected readonly audience: IAudience;

container

Signature:

protected readonly container: 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>;

Methods

createServiceMember

Signature:

protected abstract createServiceMember(audienceMember: IClient): M;

Parameters

List of parameters
Parameter Type Description
audienceMember

Returns:

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:

getMyself

Returns the current active user on this client once they are connected. Otherwise, returns undefined.

Signature:

getMyself(): M | undefined;

Returns:

shouldIncludeAsMember

Signature:

protected shouldIncludeAsMember(member: IClient): boolean;

Parameters

List of parameters
Parameter Type Description
member

Returns: