Add DeviceData and eventHandlers.js#14
Conversation
eventHandlers.sample.js
Outdated
There was a problem hiding this comment.
The description is misleading. The PoolAgent was already created at this time (because it is created before the first register arrives). There is also no reason why the PoolAgent instance is not a param on this function.
My suggestions would be
a) add PoolAgent param to beforeRegister
b) rename beforeRegister to onRegisterMessage
c) fix the description to state that it is fired before the message is processed by the PoolAgent
d) also rename onRegister to onRegistrationCompleted to make clear that it is fired after the registration.
src/PoolAgent.js
Outdated
b2121ba to
1409c95
Compare
1409c95 to
2a9ede1
Compare
|
@mar-v-in Addressed your concerns. |
eventHandlers.sample.js
Outdated
There was a problem hiding this comment.
Shouldn't this one be async as well?
There was a problem hiding this comment.
I thought I'd leave it synchronous since I was catching with try/catch but I suppose this will still work as async.
There was a problem hiding this comment.
yes, exceptions do work across async/await
src/PoolAgent.js
Outdated
|
Thanks @mar-v-in, addressed second round of comments. |
| * Fired when a REGISTER message is received, before being processed by the | ||
| * PoolAgent. Good time to perform validation or mutation of message data. | ||
| * @param {PoolAgent} agent - The Agent for the newly registered device. | ||
| * @param {Object} msg - The full register message. This is not a copy; any |
|
This feels like it should be |
@mar-v-in Based on our conversation around nimiq-network/developer-reference#24
This PR does a few things:
deviceDatatoPoolAgentPoolAgent, since we will now be exposing it to pool owners. Properties are:deviceId,deviceLabel,mode,isRegisteredeventHandlers.sample.jsand support foreventHandlers.jswhich allows pool owners to easily add handlers for events. I started withonRegisterandbeforeRegisterbut this can be expanded on.