com.badlogic.gdx.net.SocketHints Java Examples

The following examples show how to use com.badlogic.gdx.net.SocketHints. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LobbyScreen.java    From riiablo with Apache License 2.0 6 votes vote down vote up
private void connect() {
  new Thread(new Runnable() {
    @Override
    public void run() {
      try {
        socket = Gdx.net.newClientSocket(Net.Protocol.TCP, Riiablo.client.getRealm(), 6113, new SocketHints());
        in = IOUtils.buffer(new InputStreamReader(socket.getInputStream()));
        out = new PrintWriter(socket.getOutputStream(), true);
      } catch (Throwable t) {
        Gdx.app.error(TAG, t.getMessage());
        taChatOutput.appendText(t.getMessage());
        taChatOutput.appendText("\n");
      }
    }
  }).start();
}
 
Example #2
Source File: CardshifterNonGWTClient.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
public CardshifterNonGWTClient(CardshifterPlatform platform, String host, int port,
     CardshifterMessageHandler handler, LoginMessage loginMessage) {
    socket = Gdx.net.newClientSocket(Net.Protocol.TCP, host, port, new SocketHints());
    output = socket.getOutputStream();
    input = socket.getInputStream();
    transformer = new ByteTransformer(new GdxLogger(), new GdxReflection());
    this.handler = handler;
    try {
        output.write("{ \"command\": \"serial\", \"type\": \"1\" }".getBytes());
        output.flush();
        Gdx.app.log("Client", "Sent serial type");
        platform.setupLogging();
        send(loginMessage);
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    new Thread(this).start();
}
 
Example #3
Source File: LocalMultiplayer.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public void init() {
    if (initialized)
        return;
    invitesWindow = new InvitesWindow();
    playersWindow = new InvitesWindow();
    initialized = true;
    try {
        socket = Gdx.net.newClientSocket(Net.Protocol.TCP, "localhost", 1337, new SocketHints());
    } catch (Exception e) {
        return;
    }

    new Thread(new Runnable() {
        @Override public void run() {
            final BufferedReader r = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true) {
                try {
                    final String msg = r.readLine();
                    Gdx.app.postRunnable(new Runnable() {
                        @Override public void run() {
                            ClientServerMessage message = ClientServerMessage.json.fromJson(ClientServerMessage.class, msg);
                            receive(message);
                        }
                    });
                } catch (IOException ignored) {
                    System.out.println(ignored.getMessage());
                }
            }
        }
    }).start();
    sendToServer(ClientServerMessage.Type.loadPlayersToInvite);
    sendToServer(ClientServerMessage.Type.loadInvites);
}
 
Example #4
Source File: IOSMini2DxNet.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
	return new NetJavaSocketImpl(protocol, host, port, hints);
}