Changeset View
Changeset View
Standalone View
Standalone View
support/aphlict/server/lib/AphlictListener.js
| 'use strict'; | 'use strict'; | ||||
| var JX = require('./javelin').JX; | var JX = require('./javelin').JX; | ||||
| JX.install('AphlictListener', { | JX.install('AphlictListener', { | ||||
| construct: function(id, socket) { | construct: function(id, socket, path) { | ||||
| this._id = id; | this._id = id; | ||||
| this._socket = socket; | this._socket = socket; | ||||
| this._path = path; | |||||
| this._subscriptions = {}; | |||||
epriestley: ...this creates a new object for each one, instead. | |||||
| }, | }, | ||||
| members: { | members: { | ||||
| _id: null, | _id: null, | ||||
| _socket: null, | _socket: null, | ||||
| _subscriptions: {}, | _path: null, | ||||
Not Done Inline ActionsSpecifically, this is the subscriptions fix. As written, all concrete instances of AphlictListener share this object. epriestley: Specifically, this is the subscriptions fix. As written, all concrete instances of… | |||||
| _subscriptions: null, | |||||
| getID: function() { | getID: function() { | ||||
| return this._id; | return this._id; | ||||
| }, | }, | ||||
| subscribe: function(phids) { | subscribe: function(phids) { | ||||
| for (var i = 0; i < phids.length; i++) { | for (var i = 0; i < phids.length; i++) { | ||||
| var phid = phids[i]; | var phid = phids[i]; | ||||
| Show All 19 Lines | isSubscribedToAny: function(phids) { | ||||
| return intersection.length > 0; | return intersection.length > 0; | ||||
| }, | }, | ||||
| getSocket: function() { | getSocket: function() { | ||||
| return this._socket; | return this._socket; | ||||
| }, | }, | ||||
| getDescription: function() { | getDescription: function() { | ||||
| return 'Listener/' + this.getID(); | return 'Listener/' + this.getID() + this._path; | ||||
| }, | }, | ||||
| writeMessage: function(message) { | writeMessage: function(message) { | ||||
| this._socket.send(JSON.stringify(message)); | this._socket.send(JSON.stringify(message)); | ||||
| }, | }, | ||||
| }, | }, | ||||
| }); | }); | ||||
...this creates a new object for each one, instead.