本文整理汇总了Java中com.corundumstudio.socketio.SocketIOServer类的典型用法代码示例。如果您正苦于以下问题:Java SocketIOServer类的具体用法?Java SocketIOServer怎么用?Java SocketIOServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketIOServer类属于com.corundumstudio.socketio包,在下文中一共展示了SocketIOServer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
public static void start() throws InterruptedException {
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(9092);
final SocketIOServer server = new SocketIOServer(config);
server.addEventListener("chatevent", ChatObject.class, new DataListener<ChatObject>() {
@Override
public void onData(SocketIOClient client, ChatObject data, AckRequest ackRequest) {
server.getBroadcastOperations().sendEvent("chatevent", data);
}
});
server.start();
Thread.sleep(Integer.MAX_VALUE);
server.stop();
}
开发者ID:ScreenBasedSimulator,项目名称:ScreenBasedSimulator,代码行数:21,代码来源:EventChatLauncher.java
示例2: start
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
public static void start() throws InterruptedException, UnsupportedEncodingException {
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(9092);
config.setMaxFramePayloadLength(1024 * 1024);
config.setMaxHttpContentLength(1024 * 1024);
final SocketIOServer server = new SocketIOServer(config);
server.addEventListener("msg", byte[].class, new DataListener<byte[]>() {
@Override
public void onData(SocketIOClient client, byte[] data, AckRequest ackRequest) {
client.sendEvent("msg", data);
}
});
server.start();
Thread.sleep(Integer.MAX_VALUE);
server.stop();
}
开发者ID:ScreenBasedSimulator,项目名称:ScreenBasedSimulator,代码行数:24,代码来源:BinaryEventLauncher.java
示例3: getServerFor
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
@NotNull
private static SocketIOServer getServerFor(@NotNull String hostname, int port) {
String key = hostname + ":" + port;
if (servers.containsKey(key)) {
return servers.get(key);
} else {
Configuration config = new Configuration();
config.setHostname(hostname);
config.setPort(port);
SocketIOServer server = new SocketIOServer(config);
final SocketIOServer socketIOServer = servers.putIfAbsent(key, server);
if (socketIOServer == null) {
// server.start();
}
return server;
}
}
开发者ID:sillelien,项目名称:dollar,代码行数:20,代码来源:SocketURIHandler.java
示例4: restartMinicap
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
/**
* 重启minicap,通过通知某一个客户端minicap下线通知。使得其重新发起屏幕启动请求
*/
public void restartMinicap() {
// 连续收到两次的重启请求才去执行重启启动。
if (deviceEntity.getMinicapEntity().getStatus() == Status.RUNNING
&& restartRequestCount >= 1) {
logger.warn("[" + deviceEntity.getSerialNumber()
+ "]minicap退出,正在重启minicap");
Set<UUID> uuids = ClientCollection.getClients(deviceEntity
.getSerialNumber());
if (uuids != null && uuids.size() > 0) {
SocketIOServer server = WebsocketServer.getServer();
Iterator<UUID> it = uuids.iterator();
while (it.hasNext()) {
SocketIOClient client = server.getClient(uuids.iterator()
.next());
if (client != null && client.isChannelOpen()) {
client.sendEvent("screen.restart_screen_"
+ deviceEntity.getSerialNumber(),
deviceEntity.getSerialNumber());
deviceEntity.getMinicapEntity()
.setStatus(Status.CLOSED);
return;
}
}
}
restartRequestCount = 0;
}
restartRequestCount++;
}
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:32,代码来源:MinicapManager.java
示例5: init
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
public void init(){
Configuration config = new Configuration();
config.setHostname("127.0.0.1");
config.setPort(port);
server = new SocketIOServer(config);
server.addListeners(new SioChatListener(server));
server.start();
}
开发者ID:xuxueli,项目名称:xxl-push,代码行数:11,代码来源:SioChatServer.java
示例6: start
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
/**
*
*/
public void start() {
// Iniciando controle do mouse
mouse = new MouseControll();
// Server configuration
Configuration config = getServerConfiguration();
// Server initialization
server = new SocketIOServer(config);
// Add server listeners
server = setServerListeners(server);
// Star server
LOGGER.info(i18nMessages.getString("server.initializing"));
try {
server.start();
serverInfo = new ServerInfo(
server.getConfiguration().getHostname(),
server.getConfiguration().getPort());
callback.serverStarted(serverInfo);
running = true;
} catch (Exception ex) {
callback.error(ex.getMessage());
running = false;
}
}
开发者ID:rodrigogs,项目名称:mouseless-server,代码行数:35,代码来源:Server.java
示例7: getServer
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
public static SocketIOServer getServer() {
return server;
}
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:4,代码来源:WebsocketServer.java
示例8: SioChatListener
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
public SioChatListener(SocketIOServer server) {
this.server = server;
}
开发者ID:xuxueli,项目名称:xxl-push,代码行数:4,代码来源:SioChatListener.java
示例9: start
import com.corundumstudio.socketio.SocketIOServer; //导入依赖的package包/类
public static void start() throws InterruptedException {
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(9092);
final SocketIOServer server = new SocketIOServer(config);
server.addEventListener("ackevent1", ChatObject.class, new DataListener<ChatObject>() {
@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>(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();
}
开发者ID:ScreenBasedSimulator,项目名称:ScreenBasedSimulator,代码行数:45,代码来源:AckChatLauncher.java
注:本文中的com.corundumstudio.socketio.SocketIOServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论