From 21f0d12d31a076efe48cbf2239a4bded4d0abaf5 Mon Sep 17 00:00:00 2001 From: Emily Xie Date: Tue, 14 Jul 2015 17:08:35 -0400 Subject: [PATCH] clientReady hook- pass entire message, updated doc --- doc/api/hooks_server-side.md | 17 +++++++++++++++++ src/node/handler/PadMessageHandler.js | 2 ++ 2 files changed, 19 insertions(+) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 79879b2fe..6ef65cc54 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -384,3 +384,20 @@ exports.userLeave = function(hook, session, callback) { console.log('%s left pad %s', session.author, session.padId); }; ``` + +### clientReady +Called from src/node/handler/PadMessageHandler.js + +This in context: + +1. message + +This hook gets called when handling a CLIENT_READY which is the first message from the client to the server. + +Example: + +``` +exports.clientReady = function(hook, message) { + console.log('Client has entered the pad' + message.padId); +}; +``` diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 248dc1287..cc1260c25 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1009,6 +1009,8 @@ function handleClientReady(client, message) var currentTime; var padIds; + hooks.callAll("clientReady", message); + async.series([ //Get ro/rw id:s function (callback)