ever so slightly faster direct message handler
This commit is contained in:
parent
c146125283
commit
c4194117a7
@ -974,6 +974,12 @@ module.exports.create = function (cfg) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const directMessageCommands = {
|
||||||
|
GET_HISTORY: handleGetHistory,
|
||||||
|
GET_HISTORY_RANGE: handleGetHistoryRange,
|
||||||
|
GET_FULL_HISTORY: handleGetFullHistory,
|
||||||
|
};
|
||||||
|
|
||||||
/* onDirectMessage
|
/* onDirectMessage
|
||||||
* exported for use by the netflux-server
|
* exported for use by the netflux-server
|
||||||
* parses and handles all direct messages directed to the history keeper
|
* parses and handles all direct messages directed to the history keeper
|
||||||
@ -996,16 +1002,11 @@ module.exports.create = function (cfg) {
|
|||||||
// have to abort later (once we know the expiration time)
|
// have to abort later (once we know the expiration time)
|
||||||
if (checkExpired(ctx, parsed[1])) { return; }
|
if (checkExpired(ctx, parsed[1])) { return; }
|
||||||
|
|
||||||
if (parsed[0] === 'GET_HISTORY') {
|
// look up the appropriate command in the map of commands or fall back to RPC
|
||||||
return void handleGetHistory(ctx, seq, user, parsed);
|
var command = directMessageCommands[parsed[0]] || handleRPC;
|
||||||
}
|
|
||||||
if (parsed[0] === 'GET_HISTORY_RANGE') {
|
// run the command with the standard function signature
|
||||||
return void handleGetHistoryRange(ctx, seq, user, parsed);
|
command(ctx, seq, user, parsed);
|
||||||
}
|
|
||||||
if (parsed[0] === 'GET_FULL_HISTORY') {
|
|
||||||
return void handleGetFullHistory(ctx, seq, user, parsed);
|
|
||||||
}
|
|
||||||
return void handleRPC(ctx, seq, user, parsed);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user