1.去掉socket的注释
This commit is contained in:
parent
055c69d6f3
commit
d520a2053c
|
@ -1,70 +1,70 @@
|
||||||
//package org.aohe.web;
|
package org.aohe.web;
|
||||||
//
|
|
||||||
//
|
|
||||||
//import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
//import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
//import cn.hutool.log.StaticLog;
|
import cn.hutool.log.StaticLog;
|
||||||
//import org.aohe.result.R;
|
import org.aohe.result.R;
|
||||||
//import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
//import org.java_websocket.handshake.ClientHandshake;
|
import org.java_websocket.handshake.ClientHandshake;
|
||||||
//import org.java_websocket.server.WebSocketServer;
|
import org.java_websocket.server.WebSocketServer;
|
||||||
//
|
|
||||||
//import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
//import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
//
|
|
||||||
//import static org.aohe.control.Operational.selectOperational;
|
import static org.aohe.control.Operational.selectOperational;
|
||||||
//
|
|
||||||
//public class SocketServer extends WebSocketServer {
|
public class SocketServer extends WebSocketServer {
|
||||||
//
|
|
||||||
// private static final Log log = LogFactory.get();
|
private static final Log log = LogFactory.get();
|
||||||
//
|
|
||||||
// public SocketServer(int port) throws UnknownHostException {
|
public SocketServer(int port) throws UnknownHostException {
|
||||||
// super(new InetSocketAddress(port));
|
super(new InetSocketAddress(port));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public SocketServer(InetSocketAddress address) {
|
public SocketServer(InetSocketAddress address) {
|
||||||
// super(address);
|
super(address);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||||
// //conn.send("Welcome to the server!"); // This method sends a message to the new client
|
//conn.send("Welcome to the server!"); // This method sends a message to the new client
|
||||||
// //broadcast("new connection: " + handshake.getResourceDescriptor()); // This method sends a message to all clients connected
|
//broadcast("new connection: " + handshake.getResourceDescriptor()); // This method sends a message to all clients connected
|
||||||
// //System.out.println(conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!");
|
//System.out.println(conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!");
|
||||||
// StaticLog.info("ws用户已连接");
|
StaticLog.info("ws用户已连接");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||||
// StaticLog.info("ws用户关闭连接");
|
StaticLog.info("ws用户关闭连接");
|
||||||
// //这里执行关闭扫描仪连接
|
//这里执行关闭扫描仪连接
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onMessage(WebSocket conn, String message) {
|
public void onMessage(WebSocket conn, String message) {
|
||||||
// StaticLog.info("用户发送了数据:\n"+message);
|
StaticLog.info("用户发送了数据:\n"+message);
|
||||||
// conn.send(selectOperational(message));
|
conn.send(selectOperational(message));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onError(WebSocket conn, Exception ex) {
|
public void onError(WebSocket conn, Exception ex) {
|
||||||
// ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
// if (conn != null) {
|
if (conn != null) {
|
||||||
// conn.send(R.fail("error").toJsonStr());
|
conn.send(R.fail("error").toJsonStr());
|
||||||
// //绑定不到就退出
|
//绑定不到就退出
|
||||||
// //System.exit(0);
|
//System.exit(0);
|
||||||
// // some errors like port binding failed may not be assignable to a specific
|
// some errors like port binding failed may not be assignable to a specific
|
||||||
// // websocket
|
// websocket
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onStart() {
|
public void onStart() {
|
||||||
// System.out.println("Server started!");
|
System.out.println("Server started!");
|
||||||
// setConnectionLostTimeout(0);
|
setConnectionLostTimeout(0);
|
||||||
// setConnectionLostTimeout(100);
|
setConnectionLostTimeout(100);
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//}
|
}
|
||||||
|
|
Loading…
Reference in New Issue