-
Notifications
You must be signed in to change notification settings - Fork 43
Chat: Update chat docs for single channel changes #2524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration/chat-single-channel
Are you sure you want to change the base?
Changes from all commits
d62366f
d59aeac
2d52ea2
27eb5d9
133accc
6e45ff2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,31 +11,38 @@ languages: | |
|
||
Rooms are used to organize and logically separate your users and chat messages into 'rooms'. They are the entry object into using chat and provide access to all other chat features, such as messages, online status and typing indicators. A room can represent a 1:1 chat between an agent and a customer, a private message between two users in a chat application, a large group conversation, or the chat section of a livestream with thousands of users. | ||
|
||
You also control which features are enabled in a room when you create one. For instance, you might only want to utilize typing indicators in direct messages between users. | ||
h2(#channel-relationship). Channel <> Room relationship | ||
|
||
It is important to note that each room is backed by a single Ably Pub/Sub channel. | ||
The channel name is the same as the room ID with an appended suffix of @::$chat@ (e.g @some-room-id::$chat@). In most cases, you will not need to worry about this, as the Chat SDK handles the channel creation and management for you and capabilities can be configured at the room level. | ||
|
||
<aside data-type='note'> | ||
<p>You may need to be aware of this when using some integrations with Ably, such as the "Pulsar":https://ably.com/docs/integrations/streaming/pulsar#creating-pulsar-rule connectors, or if you are operating in an environment where a Chat SDK is not available.</p> | ||
</aside> | ||
|
||
h2(#create). Create or retrieve a room | ||
|
||
Users send messages to a room and subscribe to the room in order to receive messages. Other features, such as indicating which users are online, or which users are typing are configured as part of a room's options. | ||
Users send messages to a room and subscribe to the room in order to receive messages. Other features, such as indicating which users are online, or which users are typing can be configured as part of a room's options. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure the second sentence is correct here. Isn't typing enabled by default now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct, I was trying to say here that those features can be configured (e.g. setting the heartbeat interval etc..), but maybe it seems like I'm suggesting they can be turned on/off. I'll reword this a bit :) |
||
|
||
blang[javascript,swift,kotlin]. | ||
A @room@ is created, or an existing one is retrieved from the @rooms@ collection using the <span lang="javascript">"@rooms.get()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Rooms.html#get</span><span lang="swift">"@rooms.get()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/rooms/get%28roomid%3Aoptions%3A%29</span><span lang="kotlin">"@rooms.get()@":https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-rooms/get.html</span> method: | ||
|
||
blang[react]. | ||
The "@ChatRoomProvider@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/functions/chat-react.ChatRoomProvider.html provides access to a specific chat room to all child components in the component tree. | ||
|
||
Pass in the ID of the room to use, and select which which additional chat features you want enabled for that room. This is configured by passing a "@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomOptions.html object to the provider. | ||
Pass in the ID of the room to use. If you need to provide further feature configuration, such as enabling occupancy messages, you can pass in an optional "@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomOptions.html object to the provider. | ||
|
||
<aside data-type='note'> | ||
<p>All components that utilize chat feature hooks must be children of a @ChatRoomProvider@. This includes @useRoom@, "@useMessages@":/docs/chat/rooms/messages, "@useOccupancy@":/docs/chat/rooms/occupancy, "@usePresence@":/docs/chat/rooms/presence, "@usePresenceListener@":/docs/chat/rooms/presence, "@useRoomReactions@":/docs/chat/rooms/reactions and "@useTyping@":/docs/chat/rooms/typing.</p> | ||
</aside> | ||
|
||
```[javascript] | ||
const room = await chatClient.rooms.get('basketball-stream', AllFeaturesEnabled); | ||
const room = await chatClient.rooms.get('basketball-stream', {occupancy: {enableEvents: true}}); | ||
``` | ||
|
||
```[react] | ||
import * as Ably from 'ably'; | ||
import { ChatClientProvider, ChatRoomProvider, LogLevel, AllFeaturesEnabled } from '@ably/chat'; | ||
import { ChatClientProvider, ChatRoomProvider, LogLevel } from '@ably/chat'; | ||
|
||
const realtimeClient = new Ably.Realtime({ key: '{{API_KEY}}', clientId: 'clientId' }); | ||
const chatClient = new ChatClient(realtimeClient); | ||
|
@@ -45,7 +52,7 @@ const App = () => { | |
<ChatClientProvider client={chatClient}> | ||
<ChatRoomProvider | ||
id="my-room-id" | ||
options={AllFeaturesEnabled} | ||
options={{occupancy: {enableEvents: true}}} | ||
> | ||
<RestOfYourApp /> | ||
</ChatRoomProvider> | ||
|
@@ -55,7 +62,7 @@ const App = () => { | |
``` | ||
|
||
```[swift] | ||
let room = try await chatClient.rooms.get(roomID: "basketball-stream", options: RoomOptions()) | ||
let room = try await chatClient.rooms.get(roomID: "basketball-stream", options: .init(occupancy: .init(enableEvents: true))) | ||
``` | ||
|
||
```[kotlin] | ||
|
@@ -70,12 +77,9 @@ blang[react]. | |
</aside> | ||
|
||
blang[javascript,swift,kotlin]. | ||
When you create or retrieve a room using @rooms.get()@, you need to choose which additional chat features you want enabled for that room. This is configured by passing a <span lang="javascript">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomOptions.html</span><span lang="swift">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/roomoptions</span><span lang="kotlin">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-room-options/index.html</span> object as the second argument. In addition to setting which features are enabled, @RoomOptions@ also configures the properties of the associated features, such as the timeout period for typing indicators. | ||
When you create or retrieve a room using @rooms.get()@, you can provide custom configuration for some features for that room by passing a <span lang="javascript">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomOptions.html</span><span lang="swift">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/roomoptions</span><span lang="kotlin">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-room-options/index.html</span> object as the second argument. If you do not provide a @RoomOptions@ object, the default settings will be used. | ||
|
||
```[javascript] | ||
const presence = {enter: false}; | ||
const reactions = {}; | ||
const occupancy = {}; | ||
const typing = {timeoutMs: 5000}; | ||
const room = await chatClient.rooms.get('basketball-stream', {presence, reactions, typing, occupancy}); | ||
``` | ||
|
@@ -95,31 +99,17 @@ blang[javascript,swift,kotlin]. | |
val room = chatClient.rooms.get(roomId = "basketball-stream", options = options) | ||
``` | ||
|
||
blang[javascript]. | ||
You can also use the @AllFeaturesEnabled@ property for each @RoomOption@ to configure whether preconfigured example settings should be used: | ||
|
||
```[javascript] | ||
const room = await chatClient.rooms.get('basketball-stream', {presence: AllFeaturesEnabled.presence}); | ||
``` | ||
|
||
Or configure each feature using your own values: | ||
|
||
```[javascript] | ||
const room = await chatClient.rooms.get('basketball-stream', {typing: {timeoutMs: 5000}}); | ||
``` | ||
|
||
blang[react,swift,kotlin]. | ||
|
||
Enable each feature using its associated option. The details of the options available to each feature are documented on their respective pages: | ||
The details of the options available to each feature are documented on their respective pages: | ||
|
||
blang[javascript]. | ||
blang[javascript,swift]. | ||
| Feature | @RoomOption@ | Default settings | | ||
| "Presence":/docs/chat/rooms/presence | @presence@ | @AllFeaturesEnabled.presence@ | | ||
| "Occupancy":/docs/chat/rooms/occupancy | @occupancy@ | @AllFeaturesEnabled.occupancy@ | | ||
| "Typing indicators":/docs/chat/rooms/typing | @typing@ | @AllFeaturesEnabled.typing@ | | ||
| "Room reactions":/docs/chat/rooms/reactions | @reactions@ | @AllFeaturesEnabled.reactions@ | | ||
| "Presence":/docs/chat/rooms/presence | @presence.enableEvents@ | @true@ | | ||
| "Occupancy":/docs/chat/rooms/occupancy | @occupancy.enableEvents@ | @false@ | | ||
| "Typing indicators":/docs/chat/rooms/typing | @typing.heartbeatThrottleMs@ | @10000@ | | ||
|
||
blang[swift,kotlin]. | ||
blang[kotlin]. | ||
| Feature | @RoomOption@ | Default settings | | ||
| "Presence":/docs/chat/rooms/presence | @presence@ | @PresenceOptions()@ | | ||
| "Occupancy":/docs/chat/rooms/occupancy | @occupancy@ | @OccupancyOptions()@ | | ||
|
@@ -130,7 +120,7 @@ h3(#release). Release a room | |
|
||
Releasing a room allows the underlying resources to be garbage collected or released. | ||
|
||
Releasing a room may be optional for many applications. If you have multiple transient rooms, such as in the case of a 1:1 support chat, then it is may be more beneficial. | ||
Releasing a room may be optional for many applications. If you have multiple transient rooms, such as in the case of a 1:1 support chat, then it may be more beneficial. | ||
|
||
blang[javascript,swift,kotlin]. | ||
Once <span lang="javascript">"@rooms.release()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Rooms.html#release</span><span lang="swift">"@rooms.release()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/rooms/release%28roomid%3A%29</span><span lang="kotlin">"@rooms.release()@":https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-rooms/release.html</span> has been called, the room will be unusable and a new instance will need to be created using "@rooms.get()@":#create if you want to reuse it. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ languages: | |
Occupancy enables you to view the number of users currently online in a room. This feature can be used to display user counts to highlight popular, or trending chat rooms. | ||
|
||
<aside data-type='note'> | ||
<p>Occupancy needs to be "enabled":/docs/chat/rooms#create when creating or retrieving a room.</p> | ||
<p>As Occupancy incurs additional costs, it is disabled by default and needs to be "enabled":/docs/chat/rooms#create when creating or retrieving a room.</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we provide some additional context about the # of messages occupancy can produce so that the extra message costs can be considered? |
||
</aside> | ||
|
||
h2(#subscribe). Subscribe to room occupancy | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest we drop the info from the note and re-order this a little. We've said it's an important thing to note/understand, so I think we should follow that with why it's important to know before explaining the relationship.