Skip to content

Commit

Permalink
Use callback mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Lo-A-Foe committed May 30, 2016
1 parent 5f42bc4 commit a4ca3a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class Client extends EventEmitter
if @users[u].email == email
return @users[u]

getUserDirectMessageChannel: (userID) ->
getUserDirectMessageChannel: (userID, callback) ->
# check if channel already exists
channel = @self.id + "__" + userID
channel = @findChannelByName(channel)
Expand All @@ -237,8 +237,8 @@ class Client extends EventEmitter
# channel obviously doesn't exist, let's create it
channel = @createDirectChannel(userID)
if !channel
return null
return channel
if callback? then callback(null)
if callback? then callback(channel)

getAllChannels: ->
@channels
Expand All @@ -256,7 +256,7 @@ class Client extends EventEmitter
user_id: userID
@_apiCall 'POST', @channelRoute('/create_direct'), postData, (data, headers) =>
@logger.debug 'Created Direct Channel.'
return data.id
return data

findChannelByName: (name) ->
for c of @channel_details
Expand Down

0 comments on commit a4ca3a5

Please sign in to comment.