当前位置: 首页>>代码示例>>Java>>正文


Java SocketHints类代码示例

本文整理汇总了Java中com.badlogic.gdx.net.SocketHints的典型用法代码示例。如果您正苦于以下问题:Java SocketHints类的具体用法?Java SocketHints怎么用?Java SocketHints使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SocketHints类属于com.badlogic.gdx.net包,在下文中一共展示了SocketHints类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NetJavaSocketImpl

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
public NetJavaSocketImpl (Protocol protocol, String host, int port, SocketHints hints) {
	try {
		// create the socket
		socket = new java.net.Socket();
		applyHints(hints); // better to call BEFORE socket is connected!

		// and connect...
		InetSocketAddress address = new InetSocketAddress(host, port);
		if (hints != null) {
			socket.connect(address, hints.connectTimeout);
		} else {
			socket.connect(address);
		}
	} catch (Exception e) {
		throw new GdxRuntimeException("Error making a socket connection to " + host + ":" + port, e);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:NetJavaSocketImpl.java

示例2: applyHints

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
private void applyHints (SocketHints hints) {
	if (hints != null) {
		try {
			socket.setPerformancePreferences(hints.performancePrefConnectionTime, hints.performancePrefLatency,
				hints.performancePrefBandwidth);
			socket.setTrafficClass(hints.trafficClass);
			socket.setTcpNoDelay(hints.tcpNoDelay);
			socket.setKeepAlive(hints.keepAlive);
			socket.setSendBufferSize(hints.sendBufferSize);
			socket.setReceiveBufferSize(hints.receiveBufferSize);
			socket.setSoLinger(hints.linger, hints.lingerDuration);
			socket.setSoTimeout(hints.socketTimeout);
		} catch (Exception e) {
			throw new GdxRuntimeException("Error setting socket hints.", e);
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:NetJavaSocketImpl.java

示例3: CardshifterNonGWTClient

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
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();
}
 
开发者ID:Cardshifter,项目名称:Cardshifter,代码行数:20,代码来源:CardshifterNonGWTClient.java

示例4: ClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
public ClientSocket(Net.Protocol protocol, String host, int port, SocketHints hints) {
	try {
		// create the socket
		socket = new java.net.Socket();
		applyHints(hints);  // better to call BEFORE socket is connected!

		// and connect...
		InetSocketAddress address = new InetSocketAddress(host, port);
		if (hints != null) {
			socket.connect(address, hints.connectTimeout);
		} else {
			socket.connect(address);
		}
	} catch (Exception e) {
		throw new GdxRuntimeException("Error making a socket connection to " + host + ":" + port, e);
	}
}
 
开发者ID:Olloth,项目名称:LibGDXServer,代码行数:18,代码来源:ClientSocket.java

示例5: applyHints

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
private void applyHints(SocketHints hints) {
	if (hints != null) {
		try {
			socket.setPerformancePreferences(hints.performancePrefConnectionTime,
					hints.performancePrefLatency,
					hints.performancePrefBandwidth);
			socket.setTrafficClass(hints.trafficClass);
			socket.setTcpNoDelay(hints.tcpNoDelay);
			socket.setKeepAlive(hints.keepAlive);
			socket.setSendBufferSize(hints.sendBufferSize);
			socket.setReceiveBufferSize(hints.receiveBufferSize);
			socket.setSoLinger(hints.linger, hints.lingerDuration);
		} catch (Exception e) {
			throw new GdxRuntimeException("Error setting socket hints.", e);
		}
	}
}
 
开发者ID:Olloth,项目名称:LibGDXServer,代码行数:18,代码来源:ClientSocket.java

示例6: connect

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
public boolean connect() {

        if (socket != null) {
            if (socket.isConnected())
                return true;
        }

        try {
            SocketHints hints = new SocketHints();
            socket = Gdx.net.newClientSocket(Net.Protocol.TCP, serverAddress, serverPort, hints);

            os = socket.getOutputStream();
            bos = new BufferedOutputStream(os, BUFFER_SIZE);
            dos = new DataOutputStream(bos);
            in = socket.getInputStream();
            bis = new BufferedInputStream(in, BUFFER_SIZE);
            dis = new DataInputStream(bis);

            dos.writeUTF(CONNECT);
            dos.flush();

            String response = dis.readUTF();
            log.debug("got server message: " + response);

            if (response.equals(CONNECTED)) {
                return true;
            }
        } catch (Exception e) {
            log.error("an error occured", e);
        }
        return false;
    }
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:33,代码来源:FileBrowserClint.java

示例7: init

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
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);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:34,代码来源:LocalMultiplayer.java

示例8: accept

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
@Override
public Socket accept (SocketHints hints) {
	try {
		return new NetJavaSocketImpl(server.accept(), hints);
	} catch (Exception e) {
		throw new GdxRuntimeException("Error accepting socket.", e);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:9,代码来源:NetJavaServerSocketImpl.java

示例9: accept

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
@Override
public Socket accept(SocketHints hints) {
	try {
		return new ClientSocket(server.accept(), hints);
	} catch (Exception e) {
		throw new GdxRuntimeException("Error accepting socket.", e);
	}
}
 
开发者ID:Olloth,项目名称:LibGDXServer,代码行数:9,代码来源:ServerApplicationSocket.java

示例10: newClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) {
	return nativeNet.newClientSocket(protocol, host, port, hints);
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:4,代码来源:JavityNet.java

示例11: newClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
	return new NetJavaSocketImpl(protocol, host, port, hints);
}
 
开发者ID:Arcnor,项目名称:gdx-backend-jglfw,代码行数:4,代码来源:JglfwNet.java

示例12: newClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
@Override
public Socket newClientSocket(final Protocol protocol, final String host, final int port, final SocketHints hints) {
    return net.newClientSocket(protocol, host, port, hints);
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:5,代码来源:ExtendedNet.java

示例13: newClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
	throw new UnsupportedOperationException("Not implemented");
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:5,代码来源:GwtNet.java

示例14: newClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
	return new NetJavaSocketImpl(protocol, host, port, hints);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:5,代码来源:HeadlessNet.java

示例15: newClientSocket

import com.badlogic.gdx.net.SocketHints; //导入依赖的package包/类
@Override
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) {
	return new ClientSocket(protocol, host, port, hints);
}
 
开发者ID:Olloth,项目名称:LibGDXServer,代码行数:5,代码来源:ServerNet.java


注:本文中的com.badlogic.gdx.net.SocketHints类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。