From 51abcc695373083540f30e4870860a56ae91ba25 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sun, 27 Oct 2013 12:26:16 -0400 Subject: [PATCH] Document messager methods --- js/websockets.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/websockets.js b/js/websockets.js index 84077aa..7da4b38 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -196,7 +196,11 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers', var callbacks = {} var currentCallBackId = 0; - var createCallback = function(message) { + /* + * Create a callback, adds it to the callback list + * and return it. + */ + var createCallback = function() { var defer = $q.defer(); callbacks[++currentCallBackId] = { time: new Date, @@ -209,6 +213,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers', /* * Fails every currently subscribed callback for the * given reason + * * @param reason reason for failure */ failCallbacks = function(reason) { @@ -218,6 +223,12 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers', } + /* Send a message to the websocket and returns a promise. + * See: http://docs.angularjs.org/api/ng.$q + * + * @param message message to send + * @returns a promise + */ var send = function(message) { message.replace(/[\r\n]+$/g, "").split("\n"); var cb = createCallback(message);