UNPKG

693 BJavaScriptView Raw
1"use strict";
2
3// Copyright 2017-2018 Jaco Greeff
4// This software may be modified and distributed under the terms
5// of the ISC license. See the LICENSE file for details.
6module.exports = function onMessageSubscribe(self, response) {
7 self.l.debug(() => ['handling: response =', response, 'subscription =', response.params.subscription]);
8 const handler = self.subscriptions[response.params.subscription];
9
10 if (!handler) {
11 self.l.error(`Unable to find handler for subscription=${response.params.subscription}`);
12 return;
13 }
14
15 try {
16 const result = self.coder.decodeResponse(response);
17 handler.callback(null, result);
18 } catch (error) {
19 handler.callback(error);
20 }
21};
\No newline at end of file