All room members that are subscribed to the chat will receive the text messages. You must first enter the room before you may send and receive messages.
Initializing
First, instantiate the chat service. The Room Service exposes a method to get the chat associated with the active room.
JavaScript
1var chatService = roomService.getChatService();
[object ChatService]
Name
Signature
Returns
Description
start
(batchSize)
void
Start receiving messages and store the most recent of size batchSize
stop
()
void
Stop receiving messages
getObservableChatMessages
()
Observable(of Array)
Get the observable of the most recent chat messages. This is a buffer of the most recent N messages up to a max of 100. See Listen for Chat Messages
getObservableChatEnabled
()
Observable(of Boolean)
Get the observable of the enabled status of the chat service. Use this to disable or enable the chat.
The chat service exposes an observable of the most recent N (batchSize) messages in the active room up to a max of 100 messages. To view older messages you will need to use the getMessages method.
7// mostRecentChatMessages is an array of messages
8// The messages in the array are not guaranteed to be in order, and may contain duplicates
9});
10
11chatService.start(batchSize);
Send a Message to the Active Room
Send a single message to the active room. If the message is successfully sent the chatMessageObservable will trigger notifications on all subscribers with the new chat message.