本文整理汇总了Java中com.corundumstudio.socketio.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于com.corundumstudio.socketio包,在下文中一共展示了Configuration类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.corundumstudio.socketio.Configuration; //导入依赖的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();
}
示例2: start
import com.corundumstudio.socketio.Configuration; //导入依赖的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();
}
示例3: getServerFor
import com.corundumstudio.socketio.Configuration; //导入依赖的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;
}
}
示例4: init
import com.corundumstudio.socketio.Configuration; //导入依赖的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();
}
示例5: start
import com.corundumstudio.socketio.Configuration; //导入依赖的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;
}
}
示例6: getServerConfiguration
import com.corundumstudio.socketio.Configuration; //导入依赖的package包/类
/**
* @return
*/
private Configuration getServerConfiguration() {
LOGGER.info(i18nMessages.getString("server.generating.server.configuration"));
Configuration config = new Configuration();
config.setHostname(host);
config.setPort(port);
return config;
}
示例7: start
import com.corundumstudio.socketio.Configuration; //导入依赖的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();
}
示例8: ArsnovaSocketioServerImpl
import com.corundumstudio.socketio.Configuration; //导入依赖的package包/类
public ArsnovaSocketioServerImpl() {
config = new Configuration();
}