|
@ -40,6 +40,7 @@ class SocketHandler {
|
|
log.info('one user connection...');
|
|
log.info('one user connection...');
|
|
// 客户端注册
|
|
// 客户端注册
|
|
socket.on('login', function (data) {
|
|
socket.on('login', function (data) {
|
|
|
|
log.info("启用事件监听")
|
|
if (!data.userId) {
|
|
if (!data.userId) {
|
|
socketServer.sockets.emit('error', {message: 'Missing fields(s): userId.'});
|
|
socketServer.sockets.emit('error', {message: 'Missing fields(s): userId.'});
|
|
} else {
|
|
} else {
|
|
@ -310,6 +311,7 @@ class SocketHandler {
|
|
});
|
|
});
|
|
|
|
|
|
socket.on('error',function(errMsg){
|
|
socket.on('error',function(errMsg){
|
|
|
|
log.info("error"+errMsg);
|
|
let client = clientCache.findBySocket(socket);
|
|
let client = clientCache.findBySocket(socket);
|
|
if (client) {
|
|
if (client) {
|
|
//修改居民在线状态
|
|
//修改居民在线状态
|
|
@ -345,16 +347,40 @@ class SocketHandler {
|
|
|
|
|
|
// 客户端断开
|
|
// 客户端断开
|
|
socket.on('disconnect', function (soc) {
|
|
socket.on('disconnect', function (soc) {
|
|
|
|
log.info("客户端断开:"+soc);
|
|
let patientClient = clientCache.findBySocket(socket);
|
|
let patientClient = clientCache.findBySocket(socket);
|
|
|
|
log.info("客户端断开patientClient:");
|
|
if (patientClient) {
|
|
if (patientClient) {
|
|
//修改居民在线状态
|
|
|
|
// users.changUserRedisLoginStatus(original_login_userid,client.clientType,0);
|
|
|
|
|
|
|
|
//通知会话的其他成员离线消息
|
|
|
|
|
|
log.info('User ' + patientClient.userId + ' login');
|
|
|
|
if(!patientClient.clientType||patientClient.clientType=="patient"||patientClient.clientType=="patient_system"){//新增居民微信端外层-登陆类型-20191012-huangnwenjie
|
|
|
|
let participants = new Participants();
|
|
|
|
participants.changUserRedisLoginStatus(patientClient.userId,patientClient.clientType,0,patientClient.sessionId);
|
|
|
|
socket.emit('ack', {});
|
|
|
|
}else if("pc_patient"===patientClient.clientType || "pc_patient_system"===patientClient.clientType){////新增居民PC外层-登陆类型-20191012-huangnwenjie
|
|
|
|
//修改居民在线状态
|
|
|
|
let participants = new Participants();
|
|
|
|
participants.changUserRedisLoginStatus(patientClient.userId,patientClient.clientType,0,patientClient.sessionId);
|
|
|
|
socket.emit('ack', {});
|
|
|
|
//MDT 登陆类型已迁移到上面的分支-20191012-huangnwenjie
|
|
|
|
// }else if("pcim_doctor"===data.clientType){ 登
|
|
|
|
// //用于pcim 消息通知
|
|
|
|
// let pcdoctorClient = new PcDoctorClient(socket, socketServer);
|
|
|
|
// pcdoctorClient.userId = data.userId;
|
|
|
|
// pcdoctorClient.password = data.password;
|
|
|
|
// pcdoctorClient.clientType = data.clientType;
|
|
|
|
// pcdoctorClient.sessionId = "";
|
|
|
|
// clientCache.addClient(pcdoctorClient);
|
|
|
|
// socket.emit('ack', {});
|
|
|
|
}else{
|
|
|
|
//修改医生在线状态
|
|
|
|
let participants = new Participants();
|
|
|
|
participants.changUserRedisLoginStatus(patientClient.userId,patientClient.clientType,0,patientClient.sessionId);
|
|
|
|
}
|
|
|
|
/* //通知会话的其他成员离线消息
|
|
if(patientClient.sessionId != "system"){
|
|
if(patientClient.sessionId != "system"){
|
|
let participants = new Participants();
|
|
let participants = new Participants();
|
|
participants.emitSessionUsers(patientClient.sessionId,patientClient.userId,"offline");
|
|
participants.emitSessionUsers(patientClient.sessionId,patientClient.userId,"offline");
|
|
}
|
|
|
|
|
|
}*/
|
|
log.info("User disconnect: ", patientClient.userId);
|
|
log.info("User disconnect: ", patientClient.userId);
|
|
clientCache.removeByUserSocket(socket);
|
|
clientCache.removeByUserSocket(socket);
|
|
}
|
|
}
|