Class: GameMachine::Clients::TcpClient

Inherits:
Object
  • Object
show all
Defined in:
server/lib/game_machine/clients/tcp_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ TcpClient


8
9
10
11
12
# File 'server/lib/game_machine/clients/tcp_client.rb', line 8

def initialize(host,port)
  @host = host
  @port = port
  @socket = TCPSocket.open(@host,@port)
end

Instance Method Details

#receive_messageObject


19
20
21
# File 'server/lib/game_machine/clients/tcp_client.rb', line 19

def receive_message
  @socket.recvfrom(1024)[0]
end

#send_message(message) ⇒ Object


14
15
16
17
# File 'server/lib/game_machine/clients/tcp_client.rb', line 14

def send_message(message)
  @socket.send(message,0)
  #@socket.send(String.from_java_bytes(message))
end