Class: EpnsClient::Client
- Inherits:
-
Object
- Object
- EpnsClient::Client
- Defined in:
- lib/epns_client.rb
Instance Method Summary collapse
- #connect(url, req_body, blk) ⇒ Object
-
#initialize(opt, blk) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(opt, blk) ⇒ Client
Returns a new instance of Client.
75 76 77 |
# File 'lib/epns_client.rb', line 75 def initialize(opt, blk) connect("#{opt['data']['url']}:#{opt['data']['port']}", opt['data']['req_body'], blk) end |
Instance Method Details
#connect(url, req_body, blk) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/epns_client.rb', line 79 def connect(url, req_body, blk) ws = WebSocket::Client::Simple.connect url ws.on :message do |msg| blk.call(msg.data) end ws.on :open do ws.send req_body.to_json end ws.on :close do |e| puts e end ws.on :error do |e| puts e end end |