Room
JavaScript Room APIs
Create a chat room
createRoom(options,callback,)
Please refer to the table below.
N/A
creation_content
CreationContent
Extra keys, such as m.federate
, to be added to the content of the m.room.create
event. The server will overwrite the following keys: creator
, room_version
. Future versions of the specification may allow the server to overwrite other keys.
initial_state
StateEvent
: Please refer to the table below
A list of state events to set in the new room. This allows the user to override the default state events set in the new room. The expected format of the state events are an object with type, state_key and content keys set.
Takes precedence over events set by preset
, but gets overridden by name
and topic
keys.
invite
string
A list of user IDs to invite to the room. This will tell the server to invite everyone in the list to the newly created room.
name
string
If this is included, an m.room.name
event will be sent into the room to indicate the name of the room. See Room Events for more information on m.room.name
.
preset
enum
Convenience parameter for setting various default state events based on a preset.
If unspecified, the server should use the visibility
to determine which preset to use. A visbility of public
equates to a preset of public_chat
and private
visibility equates to a preset of private_chat
.
One of: [private_chat, public_chat, trusted_private_chat]
.
room_alias_name
string
The desired room alias local part. If this is included, a room alias will be created and mapped to the newly created room. The alias will belong to the same node which created the room. For example, if this was set to “foo” and sent to the node “example.com” the complete room alias would be #foo:example.com
.
The complete room alias will become the canonical alias for the room and an m.room.canonical_alias
event will be sent into the room.
topic
string
If this is included, an m.room.topic
event will be sent into the room to indicate the topic for the room. See Room Events for more information on m.room.topic
.
visibility
enum
A public
visibility indicates that the room will be shown in the published room list. A private
visibility will hide the room from the published room list. Rooms default to private
visibility if this key is not included. NB: This should not be confused with join_rules
which also uses the word public
.
One of: [public, private]
.
content
object
The content of the event.
state_key
string
The state_key of the state event. Defaults to an empty string.
type
string
The type of event to send.
Query DM room by User ID
findDMRoomByUserId
userId
: user Id
dm_rooms: room Id array
Join a chat room
joinRoom(roomIdOrAlias, opts, callbackCallback)
roomIdOrAlias: The room identifier or alias to join.
N/A
Leave the chat room
leave(roomId,callback)
roomId: room id
callback (optional):
N/A
Invite user to the room
invite(roomId,userId,callback)
roomId: room id
userId: user id
callback (optional):
N/A
Revoke invitation
revoke(roomId, userId, reason, callback)
roomId: room ID;
userId: user id;reason(optional): string;
callback(optional): function
N/A
Remove user from a room
Remove the user from the room.
kick(roomId,userId,reason,callback)
roomId: room id
userId: user id
reason: reason string
callback (optional):
N/A
Ban user from a room
As the room owner, you can ban users, effectively removing them from the room and preventing their re-entry.
ban(roomId,userId,reason,callback)
roomId: room id
userId: user id
reason: reason string
callback (optional):
N/A
Modify the user's own nickname in a room
setNickName(roomId,userId,membershipValue,nickName)
roomId: room id
userId: user id
membershipValue:
nickName: new nickname
N/A
Modify room name
setRoomName(roomId, name,callback)
roomId: room id
name: new room name
callback (optional):
event_id
Delete room
deleteRoom
roomId: room ID
N/A
Last updated