The `ChatService` is the entry point for chat functionality. Chat is defined as textual communication limited to either a fixed set of participants, or a ChatRoom in which any members can send and receive messages.

See the developer guide for a few chat examples.

### Hierarchy

- ConvergenceEventEmitter<IChatEvent>
  - ChatService

## Index

### Properties

- Events

### Methods

- addListener
- create
- direct
- events
- exists
- get
- join
- joined
- leave
- off
- on
- once
- permissions
- remove
- removeAllListeners
- removeListener
- removeListeners
- session

## Properties

### StaticEvents

Events: ChatServiceEvents = Events

## Methods

### addListener

- addListener(event: string, listener: ConvergenceEventListener<IChatEvent>): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.addListener

  Adds a new event listener for the specified event. The class will ignore duplicate registrations of the same listener to the same event.

  #### Parameters

  - ##### event: string

    The name of the event to add the listener for.

  - ##### listener: ConvergenceEventListener<IChatEvent>

    The listener callback to register.

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### create

- create(options: CreateChatChannelOptions): Promise<string>

- Creates a new Chat. The specific type of Chat created will depend on the options provided.

  #### Parameters

  - ##### options: CreateChatChannelOptions

    The options that define how to create the Chat.

  #### Returns Promise<string>

  A promise that will be resolved with the id of the successfully created Chat.

### direct

- direct(user: string | DomainUserId): Promise<DirectChat>
- direct(users: Array<string | DomainUserId>): Promise<DirectChat>

- Gets a DirectChat for the communication between the local user and another specified user.

  #### Parameters

  - ##### user: string | DomainUserId

    The other user to get the DirectChat for.

  #### Returns Promise<DirectChat>

  A Promise resolved with the specified DirectChat.

- Gets a DirectChat for the communication between the local user and a set of users.

  #### Parameters

  - ##### users: Array<string | DomainUserId>

    The other users to get the DirectChat for.

  #### Returns Promise<DirectChat>

  A Promise resolved with the specified DirectChat.

### events

- events(): Observable<IChatEvent>

- Inherited from ConvergenceEventEmitter.events

  Provides the events emitted by this object as an Observable stream.

  example

        eventEmitter.events()
          .filter(e => e.name === "myevent")
          .subscribe(e => console.log(e));

  #### Returns Observable<IChatEvent>

  An Observable stream of all events emitted by this object.

### exists

- exists(chatId: string): Promise<boolean>

- Determines if a Chat with the specified id exists.

  #### Parameters

  - ##### chatId: string

    The chat id to check.

  #### Returns Promise<boolean>

  A promise resolved with true if the specified chat exists, or false otherwise.

### get

- get(chatId: string): Promise<Chat>

- Gets a Chat object for the specified id. The exact subclass returned will depend on the type of Chat the id refers to.

  #### Parameters

  - ##### chatId: string

    The id of the Chat to get.

  #### Returns Promise<Chat>

  A Promise that will be resolved with the specified Chat, if it exists.

### join

- join(chatId: string): Promise<Chat>

- Joins a Chat with the specified id. The Chat must already exist. The type of Chat returned will vary depdning on what type of Chat the id refers to.

  #### Parameters

  - ##### chatId: string

    The id of an existing Chat to join.

  #### Returns Promise<Chat>

  A Promise resolved with the successfully joined Chat.

### joined

- joined(): Promise<ChatInfo[]>

- Gets the ChatInfo for currently joined Chats.

  #### Returns Promise<ChatInfo[]>

  A promise that is resolved with the joined chats.

### leave

- leave(chatId: string): Promise<void>

- Leaves the specified Chat. The id must refer to an existing chat that the user is presently joined to.

  #### Parameters

  - ##### chatId: string

    The id of the Chat to leave.

  #### Returns Promise<void>

  A Promise that will be resolved when the Chat is successfully left.

### off

- off(event: string, listener: ConvergenceEventListener<IChatEvent>): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.off

  Removes a single event listener for a specific event.

  #### Parameters

  - ##### event: string

    The name of the event to remove the listener for.

  - ##### listener: ConvergenceEventListener<IChatEvent>

    The listener callback to unregister.

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### on

- on(event: string, listener: ConvergenceEventListener<IChatEvent>): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.on

  Adds a new event listener for the specified event. The class will ignore duplicate registrations of the same listener to the same event.

  #### Parameters

  - ##### event: string

    The name of the event to add the listener for.

  - ##### listener: ConvergenceEventListener<IChatEvent>

    The listener callback to register.

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### once

- once(event: string, listener: ConvergenceEventListener<IChatEvent>): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.once

  Adds a single shot event listener for the specified event. The listener will be called the first time the specified event is fired after the event registration occurs, after which the registration will be removed and no further events will be passed to the listener.

  #### Parameters

  - ##### event: string

    The name of the event to add the listener for.

  - ##### listener: ConvergenceEventListener<IChatEvent>

    The listener callback to register.

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### permissions

- permissions(chatId: string): ChatPermissionManager

- Gets a ChatPermissionManager which allows for querying and modifying permissions for the specified chat.

  #### Parameters

  - ##### chatId: string

  #### Returns ChatPermissionManager

### remove

- remove(chatId: string): Promise<void>

- Removes the Chat with the specified id.

  #### Parameters

  - ##### chatId: string

    The id of the Chat to remove.

  #### Returns Promise<void>

  A promise that will be resolved when the Chat is successfully removed.

### removeAllListeners

- removeAllListeners(): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.removeAllListeners

  Removes all listeners for all events. This is useful for cleanup before disposing of this particular event emitter.

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### removeListener

- removeListener(event: string, listener: ConvergenceEventListener<IChatEvent>): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.removeListener

  Removes a single event listener for a specific event.

  #### Parameters

  - ##### event: string

    The name of the event to remove the listener for.

  - ##### listener: ConvergenceEventListener<IChatEvent>

    The listener callback to unregister.

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### removeListeners

- removeListeners(event: string): ConvergenceEventEmitter<IChatEvent>

- Inherited from ConvergenceEventEmitter.removeListeners

  Removes all listeners bound on the given event.

  #### Parameters

  - ##### event: string

    the name of the event to remove listeners for

  #### Returns ConvergenceEventEmitter<IChatEvent>

  This object, in support of a fluent API.

### session

- session(): ConvergenceSession

- #### Returns ConvergenceSession

  The current ConvergenceSession.