Unverified Commit 6aa36a8d authored by Mikael Mello's avatar Mikael Mello
Browse files

Change clientCommand attribute from 'msg' to 'key'

parent 4b64fef8
......@@ -282,7 +282,7 @@ The `callback` receives a `ClientCommand` object as the first parameter and retu
- ClientCommand.u._id: ID of the user,
- ClientCommand.u.username: Username of the user
- ClientCommand.cmd: Object representing the command itself
- ClientCommand.msg: Key of the command
- ClientCommand.key: String key of the command
- ClientCommand.options: Addional options or parameters of the command, no defined structure
- ClientCommand.ts: Timestamp of when the command was issued
......
......@@ -8,8 +8,7 @@ export interface IClientCommand {
username: string
}
cmd: {
msg: string,
options: object
key: string
}
ts: Date
}
......
......@@ -526,7 +526,7 @@ async function respondToCommands (): Promise<void | void[]> {
if (currentReadTime <= commandLastReadTime) return
// At this point, command has passed checks and can be responded to
logger.info(`[Command] Received command '${command.cmd.msg}' at ${currentReadTime}`)
logger.info(`[Command] Received command '${command.cmd.key}' at ${currentReadTime}`)
commandLastReadTime = currentReadTime
// Processing completed, call callback to respond to command
......@@ -541,7 +541,7 @@ async function respondToCommands (): Promise<void | void[]> {
* @param command Command object
*/
async function commandHandler (command: IClientCommand): Promise<void | void[]> {
switch (command.cmd.msg) {
switch (command.cmd.key) {
// SDK-level command to pause the message stream, interrupting all messages from the server
case 'pauseMessageStream':
subscriptions.map((s: ISubscription) => (s._name === _messageCollectionName ? unsubscribe(s) : undefined))
......@@ -562,7 +562,7 @@ async function commandHandler (command: IClientCommand): Promise<void | void[]>
// If command is not at the SDK-level, it tries to call a handler added by the user
default:
const handler = commandHandlers[command.cmd.msg]
const handler = commandHandlers[command.cmd.key]
if (handler) {
const result = await handler(command)
await asyncCall('replyClientCommand', [command._id, result])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment