indication回复
parent
6d39b2db5a
commit
a5d006e619
|
@ -335,6 +335,12 @@ int mut,int#int,1
|
|||
103096 103187#103188
|
||||
103097 103189#103190
|
||||
103098 10309
|
||||
103099 103191#103192
|
||||
103100 103193#103194
|
||||
103101 103195#103196
|
||||
103102 103197#103198
|
||||
103103 103199#103200
|
||||
103104 103201#103202
|
||||
104001 104001#104002
|
||||
104002 104003#104004
|
||||
104003 104005#104006
|
||||
|
|
|
@ -33,6 +33,9 @@ int int int int mut,int#int,2 int
|
|||
9231 15 0 0 null 1
|
||||
1001 0 2 2 6#100002 2
|
||||
1002 10 2 2 2#2 2
|
||||
1 0 1 1 1#1000 2
|
||||
1 0 1 1 1#1800 2
|
||||
2 30 1 1 2#200|3#200|4#200|5#200 2
|
||||
3 0 1 1 1#3200 2
|
||||
4 25 1 1 2#350 2
|
||||
5 25 1 1 3#350|4#350 2
|
||||
17 0 2 2 6#201028 2
|
||||
|
|
|
@ -58,6 +58,9 @@ int int int int int mut,int#int,2
|
|||
103012 5 2 2 103096 null
|
||||
103013 5 2 2 103072 null
|
||||
103014 1 2 1 103098 null
|
||||
103015 5 2 2 103099 null
|
||||
103016 5 2 2 103101 null
|
||||
103017 5 2 2 103103 null
|
||||
0 0 0 0 0 null
|
||||
104001 5 2 2 104001 null
|
||||
104002 5 2 2 104011 null
|
||||
|
|
|
@ -610,6 +610,18 @@ int int int mut,int#int,2 mut,int#int,1 int mut,int#int,2
|
|||
103188 0 0 null null 1 103097
|
||||
103189 0 5 103#6#5 null 4 null
|
||||
103190 0 0 null null 4 null
|
||||
103191 0 0 null null 1 103100
|
||||
103192 0 0 null null 1 103100
|
||||
103193 0 34 3#15 null 4 null
|
||||
103194 0 0 null null 4 null
|
||||
103195 0 0 null null 1 103102
|
||||
103196 0 0 null null 1 103102
|
||||
103197 0 34 4#16 null 4 null
|
||||
103198 0 0 null null 4 null
|
||||
103199 0 0 null null 1 103104
|
||||
103200 0 0 null null 1 103104
|
||||
103201 0 34 5#17 null 4 null
|
||||
103202 0 0 null null 4 null
|
||||
104001 0 0 null null 1 104002
|
||||
104002 0 0 null null 1 104004
|
||||
104003 0 0 null null 1 104003
|
||||
|
|
|
@ -54,7 +54,6 @@ public class GameApplication {
|
|||
public static boolean start = false;
|
||||
|
||||
public static ServerConfig serverConfig;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
start = true;
|
||||
app = new SpringApplication(GameApplication.class);
|
||||
|
@ -100,7 +99,7 @@ public class GameApplication {
|
|||
if( null == serverConfigTmp ){
|
||||
serverConfigTmp = new ServerConfig();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long serverOenTime = TimeUtils.getAppointTime(5);
|
||||
long serverOenTime = TimeUtils.getAppointTime(0);
|
||||
String format = simpleDateFormat.format(serverOenTime);
|
||||
serverConfigTmp.setOpenTime(format);
|
||||
serverConfigTmp.setCacheOpenTime(serverOenTime);
|
||||
|
@ -115,9 +114,15 @@ public class GameApplication {
|
|||
serverConfig = serverConfigTmp;
|
||||
KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum());
|
||||
ActivityLogic.getInstance().checkActiviyStatus();
|
||||
// ProtocolsManager.ps = new PrintStream("tmp/login.txt");
|
||||
GlobalDataManaager.getInstance().whenServerStart();
|
||||
HeroLogic.getInstance().afterSet();
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setName("addShutdownHook");
|
||||
close();
|
||||
}
|
||||
});
|
||||
try {
|
||||
LOGGER.info("main->CoreApplication start...");
|
||||
ISessionFactory sessionFactory = new ISessionFactory();
|
||||
|
|
|
@ -79,7 +79,7 @@ public class GMRequestHandler extends BaseHandler{
|
|||
Mail mail = new Mail(uid,"GM","GM",prarm3,nowTime,30*24*60*60,"GM", Global.MAIL_TYPE_GM);
|
||||
cUser.getMailManager().addMail(mail);
|
||||
PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(1).build();
|
||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.SEND_RED_POINT_INDICATION_VALUE,redPointInfo,true);
|
||||
MessageUtil.sendIndicationMessage(iSession,1,MessageTypeProto.MessageType.SEND_RED_POINT_INDICATION_VALUE,redPointInfo,true);
|
||||
break;
|
||||
case GlobalGm.HERO_STAR:
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(cUser, new int[][]{{prarm1, 1}},BIReason.GM_REWARD);
|
||||
|
|
|
@ -541,7 +541,7 @@ public class CombatLogic {
|
|||
for(Integer uid:OnlineUserManager.orderAdventureUids){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||
if(sessionByUid!=null){
|
||||
MessageUtil.sendMessage(sessionByUid,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_FIND_INDICATION_VALUE,adventureBossFindIndication,true);
|
||||
MessageUtil.sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_FIND_INDICATION_VALUE,adventureBossFindIndication,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class FriendLogic {
|
|||
PlayerInfoProto.sendFriendInfoIndication sendFriendInfoIndication = PlayerInfoProto.sendFriendInfoIndication.newBuilder()
|
||||
.setFriends(CBean2Proto.getFriendInfo(inviteUid))
|
||||
.build();
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.SEND_FRIEND_INFO_INDICATION_VALUE, sendFriendInfoIndication, true);
|
||||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.SEND_FRIEND_INFO_INDICATION_VALUE, sendFriendInfoIndication, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ public class MissionEventDistributor {
|
|||
}
|
||||
builder.addUserMissionInfo(CommonProto.UserMissionInfo.newBuilder().setMissionId(missionStateChangeInfo.getMissionId()).setType(gameMisionType.getType()).setState(state).setProgress(progress));
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.MISSION_UPDATE_INDICATION_VALUE,builder.build(),true);
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.MISSION_UPDATE_INDICATION_VALUE,builder.build(),true);
|
||||
}
|
||||
|
||||
public static Map<GameMisionType, List<MissionStateChangeInfo>> onGameEvent(User user, GameEvent event, Object ... parm) throws Exception {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -36,7 +37,6 @@ public class PlayerLogic {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static class InnerClass{
|
||||
public final static PlayerLogic instance = new PlayerLogic();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.store;
|
|||
|
||||
import com.ljsd.jieling.config.SActivityRewardConfig;
|
||||
import com.ljsd.jieling.config.SRechargeCommodityConfig;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
|
@ -128,7 +129,12 @@ public class BuyGoodsLogic {
|
|||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||
if(sessionByUid!=null){
|
||||
PlayerInfoProto.BuyGoodsDropIndication.Builder builder = PlayerInfoProto.BuyGoodsDropIndication.newBuilder().setDrop(drop);
|
||||
MessageUtil.sendMessage(sessionByUid,1,MessageTypeProto.MessageType.BUY_GOODS_DROP_INDICATION_VALUE,builder.build(),true);
|
||||
MessageUtil.sendIndicationMessage(sessionByUid,1,MessageTypeProto.MessageType.BUY_GOODS_DROP_INDICATION_VALUE,builder.build(),true);
|
||||
try {
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,10 +38,7 @@ import org.springframework.stereotype.Component;
|
|||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -150,6 +147,10 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
//在线列表加入session
|
||||
OnlineUserManager.userOnline(session.getUid(),session);
|
||||
}
|
||||
if(packetNetData.getMsgId() == MessageTypeProto.MessageType.ACK_INDICATION_COMMAND_VALUE){
|
||||
ackIndication(session,packetNetData.getIndex());
|
||||
return;
|
||||
}
|
||||
//处理心跳
|
||||
if (packetNetData.getMsgId()==1000){
|
||||
dealHeartBeat(session);
|
||||
|
@ -242,6 +243,10 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
return 0;
|
||||
}
|
||||
|
||||
private void ackIndication(ISession iSession, int ackId) {
|
||||
iSession.clearIndication(ackId);
|
||||
}
|
||||
|
||||
private void dealHeartBeat(ISession session) {
|
||||
session.setHeartBreatNums(3);
|
||||
MessageUtil.sendHeartBeat(session);
|
||||
|
|
|
@ -1,19 +1,52 @@
|
|||
package com.ljsd.jieling.network.session;
|
||||
|
||||
import com.ljsd.jieling.netty.NettyGameSession;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ISession extends NettyGameSession {
|
||||
|
||||
private String id;
|
||||
private int token;
|
||||
private int index;
|
||||
private int index; //客戶端index
|
||||
private AtomicInteger indicationIndex= new AtomicInteger(1); //服務端index
|
||||
private boolean kick;
|
||||
private long loginTime;//BI用
|
||||
|
||||
|
||||
private ConcurrentHashMap<Integer, byte[]> indexToMessage = new ConcurrentHashMap();
|
||||
private ConcurrentHashMap<Integer, IndicationMsg> indexToIndication = new ConcurrentHashMap();
|
||||
|
||||
public static class IndicationMsg{
|
||||
private long create;
|
||||
private byte[] msg;
|
||||
private int retryTimes;
|
||||
|
||||
public long getCreate() {
|
||||
return create;
|
||||
}
|
||||
|
||||
public byte[] getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public int getRetryTimes() {
|
||||
return retryTimes;
|
||||
}
|
||||
|
||||
public void setRetryTimes(int retryTimes) {
|
||||
this.retryTimes = retryTimes;
|
||||
}
|
||||
|
||||
public IndicationMsg(long crateTime, byte[] msg) {
|
||||
this.create = crateTime;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
|
||||
private int heartBreatNums = 3;
|
||||
|
||||
|
@ -75,6 +108,14 @@ public class ISession extends NettyGameSession {
|
|||
this.indexToMessage.putIfAbsent(this.index,backMessage);
|
||||
}
|
||||
|
||||
public void putBackIndicationToMap(int index,byte[] backMessage){
|
||||
this.indexToIndication.putIfAbsent(index,new IndicationMsg(TimeUtils.now(),backMessage));
|
||||
}
|
||||
|
||||
public void clearIndication(int ackId){
|
||||
this.indexToIndication.remove(ackId);
|
||||
}
|
||||
|
||||
public byte[] getCacheMessage(int index){
|
||||
return this.indexToMessage.get(index);
|
||||
}
|
||||
|
@ -86,4 +127,19 @@ public class ISession extends NettyGameSession {
|
|||
public void setLoginTime(long loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, IndicationMsg> getIndexToIndication() {
|
||||
return indexToIndication;
|
||||
}
|
||||
|
||||
|
||||
public int getIndicationIndex() {
|
||||
return indicationIndex.getAndIncrement();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AtomicInteger a= new AtomicInteger(1);
|
||||
System.out.println(a.incrementAndGet());
|
||||
System.out.println(a.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.thread;
|
|||
|
||||
import com.ljsd.jieling.thread.task.MinuteTask;
|
||||
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
||||
import com.ljsd.jieling.thread.task.RetrySendIndicationThread;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
@ -68,6 +69,7 @@ public class ThreadManager {
|
|||
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
||||
scheduledExecutor.execute(new RetrySendIndicationThread("retry_send"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.ljsd.jieling.thread.task;
|
||||
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class RetrySendIndicationThread extends Thread{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MinuteTask.class);
|
||||
|
||||
|
||||
public RetrySendIndicationThread(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true){
|
||||
try {
|
||||
doWork();
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doWork() throws InterruptedException {
|
||||
Map<Integer, ISession> sessionMap = OnlineUserManager.sessionMap;
|
||||
if(sessionMap == null){
|
||||
return;
|
||||
}
|
||||
long now = TimeUtils.now();
|
||||
for(ISession session : sessionMap.values()){
|
||||
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
||||
for(ISession.IndicationMsg indicationMsg : indexToIndication.values()){
|
||||
long create = indicationMsg.getCreate();
|
||||
int retryTimes = indicationMsg.getRetryTimes()+1;
|
||||
if(now-create>retryTimes*200){
|
||||
MessageUtil.retrySendIndication(session,indicationMsg.getMsg());
|
||||
indicationMsg.setRetryTimes(retryTimes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import com.ljsd.jieling.netty.cocdex.Tea;
|
|||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -64,8 +65,25 @@ public class MessageUtil {
|
|||
session.write(byteBuf);
|
||||
}
|
||||
session.putBackMassageToMap(byteBuf);
|
||||
/* PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(1).build();
|
||||
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.SEND_RED_POINT_INDICATION_VALUE,redPointInfo,true);*/
|
||||
}
|
||||
|
||||
|
||||
public static void sendIndicationMessage(ISession session, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||
int indicationIndex = session.getIndicationIndex();
|
||||
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), indicationIndex, session.getIndex(), msgId, generatedMessage);
|
||||
if (flush) {
|
||||
session.writeAndFlush(byteBuf);
|
||||
} else {
|
||||
session.write(byteBuf);
|
||||
}
|
||||
session.putBackIndicationToMap(indicationIndex,byteBuf);
|
||||
}
|
||||
|
||||
public static void retrySendIndication( ISession session, byte[] byteBuf){
|
||||
session.writeAndFlush(byteBuf);
|
||||
}
|
||||
public static void sendHeartBeat(ISession session) {
|
||||
int now = (int)(System.currentTimeMillis()/1000);
|
||||
int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN
|
||||
|
|
Loading…
Reference in New Issue