Class: FayeAuthExt

Inherits:
Object
  • Object
show all
Defined in:
lib/goshrine_bot/faye_auth_ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(user_id, token) ⇒ FayeAuthExt

Returns a new instance of FayeAuthExt.



2
3
4
5
# File 'lib/goshrine_bot/faye_auth_ext.rb', line 2

def initialize(user_id, token)
  @user_id = user_id
  @token = token
end

Instance Method Details

#outgoing(message, callback) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/goshrine_bot/faye_auth_ext.rb', line 7

def outgoing(message, callback)
  # Add ext field if it's not present
  message['ext'] ||= {}

  # Set the auth token
  message['ext']['authToken'] = "#{@user_id}:#{@token}"

  # Carry on and send the message to the server
  callback.call(message)
end