Class: MTProto::RPC::Ping
- Inherits:
-
Object
- Object
- MTProto::RPC::Ping
- Defined in:
- lib/mtproto/rpc/ping.rb
Instance Method Summary collapse
- #call(ping_id = nil) ⇒ Object
- #call_sync(ping_id = nil) ⇒ Object
-
#initialize(client) ⇒ Ping
constructor
A new instance of Ping.
Constructor Details
#initialize(client) ⇒ Ping
Returns a new instance of Ping.
9 10 11 |
# File 'lib/mtproto/rpc/ping.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#call(ping_id = nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/mtproto/rpc/ping.rb', line 13 def call(ping_id = nil) ping_id ||= rand(2**63) body = Type::RPC::Ping.build(ping_id) @client.rpc.call(body) end |
#call_sync(ping_id = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mtproto/rpc/ping.rb', line 20 def call_sync(ping_id = nil) ping_id ||= rand(2**63) body = Type::RPC::Ping.build(ping_id) response_body = @client.rpc.call_sync(body) pong = Type::RPC::Pong.parse(response_body) raise PingMismatchError unless pong[:ping_id] == ping_id true end |