资源简介
客户端为SocketIO
服务器端为Java Netty
WebChat聊天不错的选择
代码片段和文件信息
package com.corundumstudio.socketio.demo;
import com.corundumstudio.socketio.AckCallback;
import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.VoidAckCallback;
import com.corundumstudio.socketio.listener.DataListener;
public class AckChatLauncher {
public static void main(String[] args) throws InterruptedException {
Configuration config = new Configuration();
config.setHostname(“localhost“);
config.setPort(9092);
final SocketIOServer server = new SocketIOServer(config);
server.addEventListener(“ackevent1“ Chatobject.class new DataListenerject>() {
@Override
public void onData(final SocketIOClient client Chatobject data final AckRequest ackRequest) {
// check is ack requested by client
// but it‘s not required check
if (ackRequest.isAckRequested()) {
// send ack response with data to client
ackRequest.sendAckData(“client message was delivered to server!“ “yeah!“);
}
// send message back to client with ack callback WITH data
Chatobject ackChatobjectData = new Chatobject(data.getUserName() “message with ack data“);
client.sendEvent(“ackevent2“ new AckCallback(String.class) {
@Override
public void onSuccess(String result) {
System.out.println(“ack from client: “ + client.getSessionId() + “ data: “ + result);
}
} ackChatobjectData);
Chatobject ackChatobjectData1 = new Chatobject(data.getUserName() “message with void ack“);
client.sendEvent(“ackevent3“ new VoidAckCallback() {
protected void onSuccess() {
System.out.println(“void ack from: “ + client.getSessionId());
}
} ackChatobjectData1);
}
});
server.start();
Thread.sleep(Integer.MAX_VALUE);
server.stop();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-02-19 06:47 netty-socketio-demo-master\
文件 52 2015-02-19 06:47 netty-socketio-demo-master\.gitignore
文件 1442 2015-02-19 06:47 netty-socketio-demo-master\README.md
目录 0 2015-02-19 06:47 netty-socketio-demo-master\client\
文件 3355 2015-02-19 06:47 netty-socketio-demo-master\client\ack-index.html
文件 2723 2015-02-19 06:47 netty-socketio-demo-master\client\binary-event-index.html
文件 99896 2015-02-19 06:47 netty-socketio-demo-master\client\bootstrap.css
文件 2196 2015-02-19 06:47 netty-socketio-demo-master\client\event-index.html
文件 2865 2015-02-19 06:47 netty-socketio-demo-master\client\flashsocket-index.html
文件 2767 2015-02-19 06:47 netty-socketio-demo-master\client\index.html
目录 0 2015-02-19 06:47 netty-socketio-demo-master\client\js\
文件 94840 2015-02-19 06:47 netty-socketio-demo-master\client\js\jquery-1.7.2.min.js
文件 10215 2015-02-19 06:47 netty-socketio-demo-master\client\js\moment.min.js
目录 0 2015-02-19 06:47 netty-socketio-demo-master\client\js\socket.io\
文件 91999 2015-02-19 06:47 netty-socketio-demo-master\client\js\socket.io\socket.io.js
文件 4326 2015-02-19 06:47 netty-socketio-demo-master\client\namespace-index.html
文件 2164 2015-02-19 06:47 netty-socketio-demo-master\client\ssl-event-index.html
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\
文件 2159 2015-02-19 06:47 netty-socketio-demo-master\server\pom.xm
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\
目录 0 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\demo\
文件 2286 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\demo\AckChatLauncher.java
文件 1200 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\demo\BinaryEventLauncher.java
文件 893 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\demo\ChatLauncher.java
文件 610 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\demo\Chatob
文件 1017 2015-02-19 06:47 netty-socketio-demo-master\server\src\main\java\com\corundumstudio\socketio\demo\EventChatLauncher.java
............此处省略4个文件信息
- 上一篇:计算机网络_DV算法的实现与设计
- 下一篇:人机拿火柴游戏java代码
相关资源
- netty服务端及客户端,支持HTTP和WEBS
- nodejs-socketio-chat源码
- c++客户端和javaNetty服务器端tcp通讯
-
netty-all-4.1.5.Final完整pom.xm
l文件配置 - netty做服务端支持ssl协议实现websocke
- 《Netty实战》《Netty权威指南》第二版
- netty各种(《Netty 4.x 用户指南》中文
- netty服务端客户端
- netty http服务器
- 网页聊天室源码(WebChat)
- java 文件传输(netty)
- netty+websocket 客服聊天室
- netty echo服务器.jar可直接运行
- jar包直接当做web服务,netty负责http协
- netty-all-4.1.28.Final.jar
- android+netty 入门级
- socket框架nettydemo
评论
共有 条评论