Chat Room Memberships
Once a profile joins a room, they are a member of that room until they leave it. Joining a room is useful because the list of room memberships can be maintained per-user and looked up across sessions and devices.
A user does not have to be a member of a room to enter it and send messages.
Use memberships to keep track of which rooms a user wants to return to in future visits.
Browse available chat rooms for the current user
Use this API to get list of chat room the current profile is member of. This returns a Promise that resolves a list of all memberships present for the current user.
import { getProfileChatRoomMemberships } from '@livelike/javascript'
const chatroomMemberships = await getProfileChatRoomMemberships()
Browse the members for a given chat room
Returns a Promise that resolves a list of all memberships present on a given chat room.
import { getChatRoomMemberships } from '@livelike/javascript'
const members = await getChatRoomMemberships({roomId: "<Chat Room ID>"})
Join a chat room
Adds a membership for the current user for the chat room that is supplied by the room id argument. Returns a Promise that resolves the membership info object.
import { joinChatRoom } from '@livelike/javascript'
joinChatRoom({roomId: "<Chat Room ID>"})
.then(membership => console.log(membership))
Leave a chat room
Removes the current user's membership from the chat room that is supplied by the room id argument. Resolves a Boolean.
import { leaveChatRoom } from '@livelike/javascript'
leaveChatRoom({roomId: "<Chat Room ID>"})
.then(success => console.log(success))
Add new member to chat room
Use this method to add other users to chat rooms.
The method takes an object argument with a chat room id string as a roomId
property,
an object argument with a user profile id string as a profileId
property.
Please note
User can add another user to the chat room only if they are already a member of the chat room, use
joinChatRoom
API for becoming a member.
import { addNewMemberToChatRoom } from '@livelike/javascript'
addNewMemberToChatRoom({
roomId: "<Chat Room ID>",
profileId: "<Profile ID>"
}).then(membership => console.log(membership))
Add event listener for Chat Room Membership
Whenever a new member is added to the Chat Room, ADD_NEW_MEMBER event is emitted
Use this method to add event listener for the ADD_NEW_MEMBER event
import { addChatRoomEventListener } from '@livelike/javascript'
function onReceieveNewMemberListener(newMemberEvent) {
console.log(newMemberEvent);
}
addChatRoomEventListener(
ChatRoomEvent.ADD_NEW_MEMBER,
onReceieveNewMemberListener,
})
Remove event listener for Chat Room Membership
Use this method to remove the event listener for the ADD_NEW_MEMBER event
import { removeChatRoomEventListener } from '@livelike/javascript'
removeChatRoomEventListener(
ChatRoomEvent.ADD_NEW_MEMBER,
onReceieveNewMemberListener,
})
Get chat user muted status
Using our producer suite website, a producer has the ability to mute a user. Muting a user disables their ability to send messages to the room they were muted in. As an integrator you have the ability to query our backend to find out whether a user is muted or not. This can be achieved using the getChatUserMutedStatus
function.
import { getChatUserMutedStatus } from '@livelike/javascript'
getChatUserMutedStatus({roomId: "<Chat Room ID>"})
.then(muted_status => console.log(muted_status))
Updated 3 months ago