Skip to content

Commit

Permalink
Merge pull request #133 from RocketChat/use-new-streamer
Browse files Browse the repository at this point in the history
Modify to use the new stream package
  • Loading branch information
rodrigok committed Jun 7, 2016
2 parents 44627dd + aaa66c5 commit 0847f85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/rocketchat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ RespondToDirectMessage = process.env.RESPOND_TO_DM or "false"
RespondToEditedMessage = (process.env.RESPOND_TO_EDITED or "false").toLowerCase()
SSLEnabled = "false"

if ListenOnAllPublicRooms.toLowerCase() is 'true'
RocketChatRoom = ''

# Custom Response class that adds a sendPrivate and sendDirect method
class RocketChatResponse extends Response
sendDirect: (strings...) ->
Expand Down Expand Up @@ -111,6 +114,10 @@ class RocketChatBotAdapter extends Adapter
)
# Subscribe to msgs in all rooms
.then((res) =>
if ListenOnAllPublicRooms.toLowerCase() is 'true'
res = [0]
rooms = ['__my_messages__']

@robot.logger.info "All rooms joined."
subs = []
for result, idx in res
Expand Down
8 changes: 4 additions & 4 deletions src/rocketchat_driver.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ LRU = require('lru-cache')

# TODO: need to grab these values from process.env[]

_msgsubtopic = 'stream-messages' # 'messages'
_msgsubtopic = 'stream-room-messages' # 'messages'
_msgsublimit = 10 # this is not actually used right now
_messageCollection = 'stream-messages'
_messageCollection = 'stream-room-messages'

# room id cache
_roomCacheSize = parseInt(process.env.ROOM_ID_CACHE_SIZE) || 10
Expand Down Expand Up @@ -97,7 +97,7 @@ class RocketChatDriver
# data.roomid
# return promise
@logger.info "Preparing Meteor Subscriptions.."
msgsub = @asteroid.subscribe _msgsubtopic, data.roomid, _msgsublimit
msgsub = @asteroid.subscribe _msgsubtopic, data.roomid, true
@logger.info "Subscribing to Room: #{data.roomid}"
return msgsub.ready

Expand All @@ -117,7 +117,7 @@ class RocketChatDriver
# console.log('changed:', JSON.stringify(changedMsg, null, 2));
if changedMsg.args?
@logger.info "Message received with ID " + id
receiveMessageCallback changedMsg.args[1]
receiveMessageCallback changedMsg.args[0]

callMethod: (name, args = []) =>
@logger.info "Calling: #{name}, #{args.join(', ')}"
Expand Down

0 comments on commit 0847f85

Please sign in to comment.