在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Gottox/socket.io-java-client开源软件地址:https://github.com/Gottox/socket.io-java-client开源编程语言:Java 97.3%开源软件介绍:Socket.IO-Client for Javasocket.io-java-client is an easy to use implementation of socket.io for Java. It uses Weberknecht as transport backend, but it's easy to write your own transport. See description below. An XHR-Transport is included, too. But it's not functional in its current state. The API is inspired by java-socket.io.client. Features:
Status: Connecting with Websocket is production ready. XHR is in beta. How to useUsing socket.io-java-client is quite simple. But lets see: Checkout and compile the project: git clone git://github.com/Gottox/socket.io-java-client.git
cd socket.io-java-client
ant jar
mv jar/socketio.jar /path/to/your/libs/project If you're using ant, change your build.xml to include socketio.jar. If you're eclipse, add the jar to your project buildpath. Afterwards, you'll be able to use this library: SocketIO socket = new SocketIO("http://127.0.0.1:3001/");
socket.connect(new IOCallback() {
@Override
public void onMessage(JSONObject json, IOAcknowledge ack) {
try {
System.out.println("Server said:" + json.toString(2));
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onMessage(String data, IOAcknowledge ack) {
System.out.println("Server said: " + data);
}
@Override
public void onError(SocketIOException socketIOException) {
System.out.println("an Error occured");
socketIOException.printStackTrace();
}
@Override
public void onDisconnect() {
System.out.println("Connection terminated.");
}
@Override
public void onConnect() {
System.out.println("Connection established");
}
@Override
public void on(String event, IOAcknowledge ack, Object... args) {
System.out.println("Server triggered event '" + event + "'");
}
});
// This line is cached until the connection is establisched.
socket.send("Hello Server!"); For further informations, read the Javadoc. Checkout
Both repositories are synchronized and up to date. Buildingto build a jar-file:
You'll find the socket.io-jar in jar/socketio.jar BugsPlease report any bugs feature requests to the Github issue tracker FrameworksThis Library was designed with portability in mind.
TestingThere comes a JUnit test suite with socket.io-java-client. Currently it's tested with Eclipse. You need node installed in PATH.
TODO
License - the boring stuff...This library is distributed under MIT Licence. Sounds so interesting...You'll find further documentation at the Socket.io-java-client Github Wiki |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论