|
|
@ -1,5 +1,12 @@ |
|
|
|
package com.fr.design.login.socketio; |
|
|
|
package com.fr.design.login.socketio; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.cbb.websocket.core.WebSocketAckRequest; |
|
|
|
|
|
|
|
import com.fr.cbb.websocket.core.WebSocketClientProvider; |
|
|
|
|
|
|
|
import com.fr.cbb.websocket.core.WebSocketConfiguration; |
|
|
|
|
|
|
|
import com.fr.cbb.websocket.core.WebSocketServerFactory; |
|
|
|
|
|
|
|
import com.fr.cbb.websocket.core.WebSocketServerProvider; |
|
|
|
|
|
|
|
import com.fr.cbb.websocket.holder.EventHolder; |
|
|
|
|
|
|
|
import com.fr.cbb.websocket.listener.SocketDataListener; |
|
|
|
import com.fr.concurrent.NamedThreadFactory; |
|
|
|
import com.fr.concurrent.NamedThreadFactory; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.login.DesignerLoginType; |
|
|
|
import com.fr.design.login.DesignerLoginType; |
|
|
@ -7,11 +14,6 @@ import com.fr.design.login.bean.BBSAccountLogin; |
|
|
|
import com.fr.design.upm.event.CertificateEvent; |
|
|
|
import com.fr.design.upm.event.CertificateEvent; |
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.third.socketio.AckRequest; |
|
|
|
|
|
|
|
import com.fr.third.socketio.Configuration; |
|
|
|
|
|
|
|
import com.fr.third.socketio.SocketIOClient; |
|
|
|
|
|
|
|
import com.fr.third.socketio.SocketIOServer; |
|
|
|
|
|
|
|
import com.fr.third.socketio.listener.DataListener; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URLDecoder; |
|
|
|
import java.net.URLDecoder; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
@ -27,7 +29,7 @@ public class LoginAuthServer { |
|
|
|
|
|
|
|
|
|
|
|
private AtomicBoolean started = new AtomicBoolean(false); |
|
|
|
private AtomicBoolean started = new AtomicBoolean(false); |
|
|
|
|
|
|
|
|
|
|
|
private SocketIOServer server; |
|
|
|
private WebSocketServerProvider server; |
|
|
|
|
|
|
|
|
|
|
|
private static final String HOSTNAME = "localhost"; |
|
|
|
private static final String HOSTNAME = "localhost"; |
|
|
|
private static final int PORT = 41925; |
|
|
|
private static final int PORT = 41925; |
|
|
@ -46,10 +48,10 @@ public class LoginAuthServer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private LoginAuthServer() { |
|
|
|
private LoginAuthServer() { |
|
|
|
Configuration config = new Configuration(); |
|
|
|
WebSocketConfiguration config = new WebSocketConfiguration(); |
|
|
|
config.setHostname(HOSTNAME); |
|
|
|
config.setHostname(HOSTNAME); |
|
|
|
config.setPort(PORT); |
|
|
|
config.setPort(PORT); |
|
|
|
server = new SocketIOServer(config); |
|
|
|
server = WebSocketServerFactory.registerWebSocketServer(config); |
|
|
|
initEventListener(); |
|
|
|
initEventListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -87,9 +89,9 @@ public class LoginAuthServer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initEventListener() { |
|
|
|
private void initEventListener() { |
|
|
|
server.addEventListener("bbsAccountLogin", BBSAccountLogin.class, new DataListener<BBSAccountLogin>() { |
|
|
|
server.addEventListener(EventHolder.build("bbsAccountLogin", BBSAccountLogin.class, new SocketDataListener<BBSAccountLogin>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onData(SocketIOClient client, BBSAccountLogin data, AckRequest ackRequest) throws Exception { |
|
|
|
public void onData(WebSocketClientProvider client, BBSAccountLogin data, WebSocketAckRequest ackRequest) throws Exception { |
|
|
|
// 保存登录信息到.FineReport100配置中
|
|
|
|
// 保存登录信息到.FineReport100配置中
|
|
|
|
int uid = data.getUid(); |
|
|
|
int uid = data.getUid(); |
|
|
|
if (uid > 0) { |
|
|
|
if (uid > 0) { |
|
|
@ -106,6 +108,6 @@ public class LoginAuthServer { |
|
|
|
EventDispatcher.fire(CertificateEvent.LOGIN, username); |
|
|
|
EventDispatcher.fire(CertificateEvent.LOGIN, username); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|