Sha256: f401144a526d279ea9409f97a7791bc3a8a2edecffa520b0ee6e1cfb43149f66

Contents?: true

Size: 761 Bytes

Versions: 6

Compression:

Stored size: 761 Bytes

Contents

module GameMachine
  module Clients
    class UdtClient

      def initialize(server)
        @host = Settings.servers.send(server).udt.host
        @port = Settings.servers.send(server).udt.port
      end

      def disconnect
        @socket.close
      end

      def connect
        address = JavaLib::InetSocketAddress.new(@host, @port)
        @socket = JavaLib::SocketUDT.new(JavaLib::TypeUDT::DATAGRAM)
        @socket.setBlocking(true)
        @socket.connect(address)
        @socket
      end

      def send_message(bytes)
        @socket.send(bytes)
      end

      def receive(timeout=0.100)
        array = Java::byte[4096].new
        res = @socket.receive(array)
        JavaLib::Arrays.copy_of_range(array,0,res)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
game_machine-1.0.4 lib/game_machine/clients/udt_client.rb
game_machine-1.0.2 lib/game_machine/clients/udt_client.rb
game_machine-0.0.11 lib/game_machine/clients/udt_client.rb
game_machine-0.0.10 lib/game_machine/clients/udt_client.rb
game_machine-0.0.9 lib/game_machine/clients/udt_client.rb
game_machine-0.0.8 lib/game_machine/clients/udt_client.rb