本文整理汇总了Java中com.badlogic.gdx.net.NetJavaSocketImpl类的典型用法代码示例。如果您正苦于以下问题:Java NetJavaSocketImpl类的具体用法?Java NetJavaSocketImpl怎么用?Java NetJavaSocketImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetJavaSocketImpl类属于com.badlogic.gdx.net包,在下文中一共展示了NetJavaSocketImpl类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: extractJavaSocket
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
public static Socket extractJavaSocket(com.badlogic.gdx.net.Socket gdxSocket) throws IOException {
if (gdxSocket instanceof NetJavaSocketImpl) {
try {
Field f = NetJavaSocketImpl.class.getDeclaredField("socket");
Socket javaSocket = (java.net.Socket) f.get(gdxSocket);
if (javaSocket != null) {
return javaSocket;
} else {
throw new Error();;
}
} catch (Exception e) {
throw new IOException("Failed to get java socket", e);
}
} else {
throw new IOException("libGDX socket is not a " + NetJavaSocketImpl.class.getSimpleName());
}
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:19,代码来源:ClientConnectionInitializer.java
示例2: initialConnect
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
private static void initialConnect(Socket javaSocket, NetJavaSocketImpl gdxSocket) throws Exception {
javaSocket.setSoTimeout(TIMEOUT);
DataInputStream dataInputStream = new DataInputStream(javaSocket.getInputStream());
byte b = dataInputStream.readByte();
DataOutputStream dataOutputStream = new DataOutputStream(javaSocket.getOutputStream());
dataOutputStream.writeInt(Branding.VERSION_MAJOR);
dataOutputStream.writeInt(Branding.VERSION_MINOR);
dataOutputStream.writeInt(Branding.VERSION_POINT);
dataOutputStream.writeInt(Branding.VERSION_BUILD);
dataOutputStream.writeUTF(Branding.VERSION_HASH);
switch (b) {
case 0:
connect(javaSocket, gdxSocket, dataOutputStream, dataInputStream);
return;
case 1:
ping(javaSocket, gdxSocket, dataOutputStream, dataInputStream);
return;
default:
throw new IOException("Unrecognised connection code " + b);
}
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:22,代码来源:ServerConnectionInitializer.java
示例3: extractJavaSocket
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
public static Socket extractJavaSocket(com.badlogic.gdx.net.Socket gdxSocket) throws IOException {
if (gdxSocket instanceof NetJavaSocketImpl) {
try {
Field f = NetJavaSocketImpl.class.getDeclaredField("socket");
f.setAccessible(true);
Socket javaSocket = (java.net.Socket) f.get(gdxSocket);
if (javaSocket != null) {
return javaSocket;
} else {
throw new NullPointerException();
}
} catch (Exception e) {
throw new IOException("Failed to get java socket", e);
}
} else {
throw new IOException("libGDX socket is not a " + NetJavaSocketImpl.class.getSimpleName());
}
}
开发者ID:RedTroop,项目名称:Cubes,代码行数:19,代码来源:ClientConnectionInitializer.java
示例4: ping
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
private static void ping(Socket javaSocket, NetJavaSocketImpl gdxSocket, DataOutputStream dataOutputStream, DataInputStream dataInputStream) throws Exception {
Log.debug(gdxSocket.getRemoteAddress() + " pinged the server");
List<ClientIdentifier> clients = Cubes.getServer().getAllClients();
dataOutputStream.writeInt(clients.size());
for (ClientIdentifier client : clients) {
dataOutputStream.writeUTF(client.getPlayer().username);
}
dataOutputStream.flush();
gdxSocket.dispose();
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:11,代码来源:ServerConnectionInitializer.java
示例5: Checker
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
private Checker(Socket javaSocket, NetJavaSocketImpl gdxSocket) {
this.javaSocket = javaSocket;
this.gdxSocket = gdxSocket;
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:5,代码来源:ServerConnectionInitializer.java
示例6: check
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
public static void check(com.badlogic.gdx.net.Socket gdxSocket) throws Exception {
Socket javaSocket = extractJavaSocket(gdxSocket);
NetJavaSocketImpl netJavaSocketImpl = (NetJavaSocketImpl) gdxSocket;
Executor.execute(new Checker(javaSocket, netJavaSocketImpl));
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:6,代码来源:ServerConnectionInitializer.java
示例7: connect
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的package包/类
private static void connect(Socket javaSocket, NetJavaSocketImpl gdxSocket, DataOutputStream dataOutputStream, DataInputStream dataInputStream) throws Exception {
javaSocket.setSoTimeout(0);
((ServerNetworking) Side.getNetworking()).accepted(gdxSocket);
}
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:5,代码来源:ServerConnectionInitializer.java
示例8: newClientSocket
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的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
示例9: newClientSocket
import com.badlogic.gdx.net.NetJavaSocketImpl; //导入依赖的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
注:本文中的com.badlogic.gdx.net.NetJavaSocketImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论