Class: MessagePack::RPC::Client
- Inherits:
-
Object
- Object
- MessagePack::RPC::Client
show all
- Includes:
- LoopUtil
- Defined in:
- lib/msgpack/rpc.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from LoopUtil
#run, #start_timer, #stop
Constructor Details
#initialize(host, port, loop = Loop.new) ⇒ Client
Returns a new instance of Client.
353
354
355
356
357
358
359
360
361
362
363
|
# File 'lib/msgpack/rpc.rb', line 353
def initialize(host, port, loop = Loop.new)
@loop = loop
@host = host
@port = port
@rsock = RevSocket.connect(host, port)
@s = ClientSession.new(loop)
@rsock.session = @s
loop.attach(@rsock)
@timer = Timer.new(1, true) { @s.step_timeout }
loop.attach(@timer)
end
|
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
364
365
366
|
# File 'lib/msgpack/rpc.rb', line 364
def host
@host
end
|
#loop ⇒ Object
Returns the value of attribute loop.
364
365
366
|
# File 'lib/msgpack/rpc.rb', line 364
def loop
@loop
end
|
#port ⇒ Object
Returns the value of attribute port.
364
365
366
|
# File 'lib/msgpack/rpc.rb', line 364
def port
@port
end
|
Instance Method Details
#call(method, *args) ⇒ Object
380
381
382
|
# File 'lib/msgpack/rpc.rb', line 380
def call(method, *args)
@s.call(method, *args)
end
|
#callback(method, *args, &block) ⇒ Object
376
377
378
|
# File 'lib/msgpack/rpc.rb', line 376
def callback(method, *args, &block)
@s.callback(method, *args, &block)
end
|
#close ⇒ Object
366
367
368
369
370
|
# File 'lib/msgpack/rpc.rb', line 366
def close
@timer.detach
@rsock.detach
@s.close
end
|
#notify(method, *args) ⇒ Object
384
385
386
|
# File 'lib/msgpack/rpc.rb', line 384
def notify(method, *args)
@s.notify(method, *args)
end
|
#send(method, *args) ⇒ Object
372
373
374
|
# File 'lib/msgpack/rpc.rb', line 372
def send(method, *args)
@s.send(method, *args)
end
|
#timeout ⇒ Object
388
389
390
|
# File 'lib/msgpack/rpc.rb', line 388
def timeout
@s.timeout
end
|
#timeout=(time) ⇒ Object
392
393
394
|
# File 'lib/msgpack/rpc.rb', line 392
def timeout=(time)
@s.timeout = time
end
|