- See:
Requests that are sent from a client to a server, for each request
a reply will be sent back with a possible result data. Some
requests will trigger sending rpc.serverNotifications
to
other clients. Result data types are described as returned
values. If chat-service.config.options
useRawErrorObjects
option is off, then errors type is string
. Otherwise errors have
a rpc.datatypes.ChatServiceError
type. Details of how
results or errors are returned depend on a transport used, for more
information see examples below. Essentially each request triggers
an execution of a command in a socket+user context.
Example
let socket = io.connect(url, opts)
socket.on('loginConfirmed', () => {
// Code is run after each reconnection.
socket.emit('roomJoin', roomName, (error, result) => {
// This is a socket.io ack waiting callback. Socket is joined
// the room, or an error occurred, we get here only when the
// server has finished roomJoin command processing. Error
// or results are passed as arguments, using Node.js style
// callbacks.
})
})
Methods
(static) directAddToList(listName, userNames) → {undefined}
Adds user names to user's direct messaging blacklist or whitelist.
Parameters:
Name | Type | Description |
---|---|---|
listName |
string | List name. Possible values are: 'blacklist'|'whitelist' |
userNames |
Array.<string> | User names to add to the list. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) directGetAccessList(listName) → {Array.<string>}
Gets direct messaging blacklist or whitelist.
Parameters:
Name | Type | Description |
---|---|---|
listName |
string | List name. Possible values are: 'blacklist'|'whitelist' |
Returns:
The requested list.
- Type
- Array.<string>
(static) directGetWhitelistMode() → {boolean}
Gets direct messaging whitelist only mode. If it is true then direct messages are allowed only for users that are in the whitelist. Otherwise direct messages are accepted from all users that are not in the blacklist.
Returns:
User's whitelist only mode.
- Type
- boolean
(static) directMessage(toUser, message) → {rpc.datatypes.ProcessedMessage}
Sends rpc.serverNotifications.directMessage
to an another
user, if chat-service.config.options
enableDirectMessages
option is true. Also sends rpc.serverNotifications.directMessageEcho
to other sender's
sockets.
Parameters:
Name | Type | Description |
---|---|---|
toUser |
string | Message receiver. |
message |
rpc.datatypes.Message | Direct message. |
Returns:
Processed message.
(static) directRemoveFromList(listName, userNames) → {undefined}
Removes user names from user's direct messaging blacklist or whitelist.
Parameters:
Name | Type | Description |
---|---|---|
listName |
string | List name. Possible values are: 'blacklist'|'whitelist' |
userNames |
Array.<string> | User names to remove from the list. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) directSetWhitelistMode(mode) → {undefined}
Sets direct messaging whitelist only mode.
Parameters:
Name | Type | Description |
---|---|---|
mode |
boolean | Room mode. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) listOwnSockets() → {rpc.datatypes.SocketsInfo}
Gets a list of all sockets with corresponding joined rooms. This returns information about all user's sockets.
Returns:
User sockets info.
(static) roomAddToList(roomName, listName, userNames) → {undefined}
Adds user names to room's blacklist, adminlist and whitelist. Also
removes users that have lost an access permission in the result of
an operation, sending rpc.serverNotifications.roomAccessRemoved
. Also sends rpc.serverNotifications.roomAccessListAdded
to all room users if
room's enableAccessListsUpdates
option is true.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
listName |
string | List name. Possible values are: 'blacklist'|'adminlist'|'whitelist' |
userNames |
Array.<string> | User names to add to the list. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) roomCreate(roomName, mode) → {undefined}
Creates a room if chat-service.config.options
enableRoomsManagement
option is true.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Rooms name. |
mode |
bool | Room mode. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) roomDelete(roomName) → {undefined}
Deletes a room if chat-service.config.options
enableRoomsManagement
is true and the user has an owner
status. Sends rpc.serverNotifications.roomAccessRemoved
to
all room users.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Rooms name. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) roomGetAccessList(roomName, listName) → {Array.<string>}
Gets room messaging userlist, blacklist, adminlist and whitelist.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
listName |
string | List name. Possible values are: 'blacklist'|'adminlist'|'whitelist'|'userlist' |
Returns:
The requested list.
- Type
- Array.<string>
(static) roomGetOwner(roomName) → {string}
Gets the room owner.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
Room owner.
- Type
- string
(static) roomGetWhitelistMode(roomName) → {boolean}
Gets the room messaging whitelist only mode. If it is true, then join is allowed only for users that are in the whitelist. Otherwise all users that are not in the blacklist can join.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
Whitelist only mode.
- Type
- boolean
(static) roomHistoryGet(roomName, id, limit) → {Array.<rpc.datatypes.ProcessedMessage>}
Returns messages that were sent after a message with the specified
id. The returned number of messages is limited by the limit
parameter. The maximum limit is bounded by chat-service.config.options
historyMaxGetMessages
option. If
the specified id was deleted due to history limit, it returns
messages starting from the oldest available. Messages are sorted
as newest first.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
id |
number | Starting message id (not included in result). |
limit |
number | Maximum number of messages to return. The
maximum number is limited by |
Returns:
An array of messages.
- Type
- Array.<rpc.datatypes.ProcessedMessage>
(static) roomHistoryInfo(roomName) → {rpc.datatypes.HistoryInfo}
Gets the the room history information.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
Room history information.
(static) roomJoin(roomName) → {number}
Joins room, an user must join the room to receive messages or
execute requests with a room
prefix. Sends rpc.serverNotifications.roomJoinedEcho
to other user's
sockets. Also sends rpc.serverNotifications.roomUserJoined
to other room users if room's enableUserlistUpdates
option is
true.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
A number of still joined user's sockets to the room.
- Type
- number
(static) roomLeave(roomName) → {number}
Leaves room. Sends rpc.serverNotifications.roomLeftEcho
to
other user's sockets. Also sends rpc.serverNotifications.roomUserLeft
to other room users if
room's enableUserlistUpdates
option is true.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
A number of joined user's sockets to the room.
- Type
- number
(static) roomMessage(roomName, message) → {number}
Sends rpc.serverNotifications.roomMessage
to all room
users.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
message |
rpc.datatypes.Message | Message. |
Returns:
The message id.
- Type
- number
(static) roomNotificationsInfo(roomName) → {rpc.datatypes.NotificationsInfo}
Gets room's notifications configuration.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
Room notifications information.
(static) roomRecentHistory(roomName) → {Array.<rpc.datatypes.ProcessedMessage>}
Gets latest room messages. The maximum size is set by chat-service.config.options
historyMaxGetMessages
option. Messages are sorted as newest first.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
Returns:
An array of messages.
- Type
- Array.<rpc.datatypes.ProcessedMessage>
(static) roomRemoveFromList(roomName, listName, userNames) → {undefined}
Removes user names from room's blacklist, adminlist and
whitelist. Also removes users that have lost an access permission
in the result of an operation, sending rpc.serverNotifications.roomAccessRemoved
. Also sends rpc.serverNotifications.roomAccessListRemoved
to all room users
if room's enableAccessListsUpdates
option is true.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
listName |
string | List name. Possible values are: 'blacklist'|'adminlist'|'whitelist' |
userNames |
Array.<string> | User names to remove from the list. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) roomSetWhitelistMode(roomName, mode) → {undefined}
Sets room messaging whitelist only mode. Also removes users that
have lost an access permission in the result of an operation,
sending rpc.serverNotifications.roomAccessRemoved
. Also
sends rpc.serverNotifications.roomModeChanged
to all room
users if room's enableAccessListsUpdates
option is true.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Room name. |
mode |
boolean | Room mode. |
Returns:
Acknowledgment without data.
- Type
- undefined
(static) roomUserSeen(roomName, userName) → {rpc.datatypes.UserSeenInfo}
Send user's joined state and last state change timestamp.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
string | Rooms name. |
userName |
string | User name. |
Returns:
Seen info.
(static) systemMessage(message) → {undefined}
Send data to other connected users's sockets.
Parameters:
Name | Type | Description |
---|---|---|
message |
Object | Arbitrary data. |
Returns:
Acknowledgment without data.
- Type
- undefined