协议号映射
parent
d33638ca65
commit
c8534de2de
|
@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.dao.UserManager;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.netty.PackageConstant;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.*;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
|
@ -60,7 +61,9 @@ public class MessageUtil {
|
|||
System.arraycopy(backMessage, 0, bytes, pos, backMessage.length);
|
||||
}
|
||||
int[] secretKey = Tea.KEY;
|
||||
return Tea.encrypt2(bytes, secretKey);
|
||||
byte[] bytes1 = Tea.encrypt2(bytes, secretKey);
|
||||
LOGGER.info("sendbyte"+bytes1.length);
|
||||
return bytes1;
|
||||
}
|
||||
|
||||
public static void sendMessage(int[] uids, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||
|
@ -140,6 +143,28 @@ public class MessageUtil {
|
|||
session.putBackIndicationToMap(indicationIndex,byteBuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 协议号 大于30000 自动进行协议号查找
|
||||
* @param generatedMessage
|
||||
*/
|
||||
public static void sendIndicationMessage(int uid, GeneratedMessage generatedMessage) {
|
||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||
if(null == session){
|
||||
return;
|
||||
}
|
||||
if(session.getFiveReady() == 0){
|
||||
return;
|
||||
}
|
||||
int indicationIndex = session.getIndicationIndex();
|
||||
int msgId = ProtocolsManager.getProtoIdBySimpleName(generatedMessage.getClass().getSimpleName());
|
||||
if(msgId==0){
|
||||
return;
|
||||
}
|
||||
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), indicationIndex,1, msgId, generatedMessage);
|
||||
session.write(byteBuf,true);
|
||||
session.putBackIndicationToMap(indicationIndex,byteBuf);
|
||||
}
|
||||
|
||||
public static void retrySendIndication( ISession session, byte[] byteBuf){
|
||||
session.writeAndFlush(byteBuf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue