Skip to content

Commit

Permalink
#75 adjust the .say() method to match the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
gil0mendes committed Jun 27, 2017
1 parent 8334a3e commit 51c1a97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,14 @@ StellarClient.prototype.off = function (event, func) { return this.removeListene
* @return Promise
*/
StellarClient.prototype.say = function (room, message) {
return this.send({ event: 'say', room, message })
// set default room as target, and set message with the first argument
if (message === undefined) {
message = room
room = this.options.defaultRoom
}

// emit a 'say' event for the selected room
return this.to(room).emit('message', message)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/servers/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe('Servers: Web Socket', function () {
const listener = response => {
client1.removeListener('say', listener)
response.context.should.equal('user')
response.message.should.equal('hello from client 2')
response.message.data.should.equal('hello from client 2')
done()
}

Expand Down

0 comments on commit 51c1a97

Please sign in to comment.