Class: UDPProxy::Client

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/udp_proxy/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_ip, client_port, server) ⇒ Client

Returns a new instance of Client.



6
7
8
9
# File 'lib/udp_proxy/client.rb', line 6

def initialize(client_ip, client_port, server)
  @client_ip, @client_port = client_ip, client_port
  @server = server
end

Instance Attribute Details

#client_ipObject

Returns the value of attribute client_ip.



4
5
6
# File 'lib/udp_proxy/client.rb', line 4

def client_ip
  @client_ip
end

#client_portObject

Returns the value of attribute client_port.



4
5
6
# File 'lib/udp_proxy/client.rb', line 4

def client_port
  @client_port
end

Instance Method Details

#receive_data(data) ⇒ Object



11
12
13
14
# File 'lib/udp_proxy/client.rb', line 11

def receive_data(data)
  port, ip = Socket.unpack_sockaddr_in(get_peername)
  @server.send_datagram(data, client_ip, client_port)
end