Skip to content

Commit

Permalink
Change message type to binary Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
interpretor committed Jul 11, 2017
1 parent e4bfb66 commit 81970e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
12 changes: 4 additions & 8 deletions lib/zre_msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ZreMsg {
* @param {object} [options] - Options object
* @param {number} [options.sequence=1] - Sequence of the message
* @param {string} [options.group] - Group which the node/peer joins or leaves
* @param {string} [options.content] - Content of the message
* @param {Buffer} [options.content] - Content of the message
* @param {string} [options.endpoint] - TCP address of the node/peer
* @param {string[]} [options.groups] - Groups in which the node/peer participates
* @param {number} [options.status] - Groups status of the node/peer
Expand Down Expand Up @@ -179,7 +179,7 @@ class ZreMsg {
}

/**
* @return {string} Content of the message
* @return {Buffer} Content of the message
*/
getContent() {
return this._content;
Expand Down Expand Up @@ -330,9 +330,7 @@ class ZreMsg {

const sequence = getNumber2(position);

const content = frame.toString();

return new ZreMsg(WHISPER, { sequence, content });
return new ZreMsg(WHISPER, { sequence, content: frame });
}

case SHOUT: {
Expand All @@ -345,9 +343,7 @@ class ZreMsg {

const group = getString(position);

const content = frame.toString();

return new ZreMsg(SHOUT, { sequence, group, content });
return new ZreMsg(SHOUT, { sequence, group, content: frame });
}

case JOIN: {
Expand Down
8 changes: 4 additions & 4 deletions lib/zyre.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Zyre extends EventEmitter {
* Sends a message to a ZyrePeer.
*
* @param {string} identity - Identity of the peer
* @param {string} message - Message to send
* @param {Buffer} message - Message to send
*/
whisper(identity, message) {
if (this._zyrePeers.exists(identity)) {
Expand All @@ -173,7 +173,7 @@ class Zyre extends EventEmitter {
* Sends a message to a ZyreGroup.
*
* @param {string} group - Name of the group
* @param {string} message - Message to send
* @param {Buffer} message - Message to send
*/
shout(group, message) {
if (this._zyreGroups.exists(group)) {
Expand Down Expand Up @@ -289,7 +289,7 @@ class Zyre extends EventEmitter {
* @event Zyre#whisper
* @property {string} identity - Identity of the peer
* @property {string} name - Name of the peer
* @property {string} message - Message
* @property {Buffer} message - Message
*/
this.emit('whisper', peer.getIdentity(), peer.getName(), message);
};
Expand All @@ -299,7 +299,7 @@ class Zyre extends EventEmitter {
* @event Zyre#shout
* @property {string} identity - Identity of the peer
* @property {string} name - Name of the peer
* @property {string} message - Message
* @property {Buffer} message - Message
* @property {string} group - Group where the message came from
*/
this.emit('shout', peer.getIdentity(), peer.getName(), message, group);
Expand Down
4 changes: 2 additions & 2 deletions lib/zyre_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ZyreNode extends EventEmitter {
/**
* @event ZyreNode#whisper
* @property {ZyrePeer} zyrePeer - ZyrePeer
* @property {string} message - Message
* @property {Buffer} message - Message
*/
this.emit('whisper', zyrePeer, zreMsg.getContent());
break;
Expand All @@ -212,7 +212,7 @@ class ZyreNode extends EventEmitter {
/**
* @event ZyreNode#shout
* @property {ZyrePeer} zyrePeer - ZyrePeer
* @property {string} message - Message
* @property {Buffer} message - Message
* @property {string} group - Group where the message came from
*/
this.emit('shout', zyrePeer, zreMsg.getContent(), zreMsg.getGroup());
Expand Down

0 comments on commit 81970e6

Please sign in to comment.