Class: MessagePack::RPC::UDPClientTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/msgpack/rpc/transport/udp.rb

Defined Under Namespace

Classes: ClientSocket

Instance Method Summary collapse

Constructor Details

#initialize(session, address) ⇒ UDPClientTransport

Returns a new instance of UDPClientTransport.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/msgpack/rpc/transport/udp.rb', line 63

def initialize(session, address)
	io = UDPSocket.new
	io.connect(*address)

	begin
		@sock = ClientSocket.new(io, session)
	rescue
		io.close
		raise
	end

	begin
		session.loop.attach(@sock)
	rescue
		@sock.close
		raise
	end
end

Instance Method Details

#closeObject

ClientTransport interface



88
89
90
91
# File 'lib/msgpack/rpc/transport/udp.rb', line 88

def close
	@sock.detach if @sock.attached?
	@sock.close
end

#send_data(data) ⇒ Object

ClientTransport interface



83
84
85
# File 'lib/msgpack/rpc/transport/udp.rb', line 83

def send_data(data)
	@sock.send_data(data)
end