Class: MotionPusherClient

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-pusher/motion-pusher-client.rb

Instance Method Summary collapse

Constructor Details

#initialize(delegate) ⇒ MotionPusherClient

Returns a new instance of MotionPusherClient.



2
3
4
5
6
7
8
9
10
11
# File 'lib/motion-pusher/motion-pusher-client.rb', line 2

def initialize(delegate)
  self.client = PTPusher.pusherWithKey(
    self.config['key'],
    delegate: delegate,
    encrypted: true
  )
  if self.config['authorization_url']
    self.client.authorizationURL = NSURL.URLWithString(self.config['authorization_url'])
  end
end

Instance Method Details

#configObject



34
35
36
# File 'lib/motion-pusher/motion-pusher-client.rb', line 34

def config
  @config ||= NSBundle.mainBundle.objectForInfoDictionaryKey('MotionPusher')
end

#connectObject



13
14
15
# File 'lib/motion-pusher/motion-pusher-client.rb', line 13

def connect
  client.connect
end

#subscribe_to(channel) ⇒ Object



17
18
19
# File 'lib/motion-pusher/motion-pusher-client.rb', line 17

def subscribe_to(channel)
  client.subscribeToChannelNamed(channel)
end

#subscribe_to_presence(channel) ⇒ Object



25
26
27
# File 'lib/motion-pusher/motion-pusher-client.rb', line 25

def subscribe_to_presence(channel)
  client.subscribeToPresenceChannelNamed(channel)
end

#subscribe_to_private(channel) ⇒ Object



21
22
23
# File 'lib/motion-pusher/motion-pusher-client.rb', line 21

def subscribe_to_private(channel)
  client.subscribeToPrivateChannelNamed(channel)
end

#unsubscribe_from(channel) ⇒ Object



29
30
31
32
# File 'lib/motion-pusher/motion-pusher-client.rb', line 29

def unsubscribe_from(channel)
  channel = self.client.channelNamed(channel) if channel.is_a? String
  channel.unsubscribe if channel
end