fix
parent
d54335ed93
commit
56e3a60a38
|
@ -10,3 +10,4 @@ serverlogic/src/main/java/com/ljsd/jieling/protocols
|
|||
out
|
||||
build
|
||||
out
|
||||
tmp/
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
@ -112,6 +113,8 @@ public class GameApplication {
|
|||
serverConfig = serverConfigTmp;
|
||||
KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum());
|
||||
ActivityLogic.getInstance().checkActiviyStatus();
|
||||
|
||||
// ProtocolsManager.ps = new PrintStream("tmp/login.txt");
|
||||
try {
|
||||
LOGGER.info("main->CoreApplication start...");
|
||||
ISessionFactory sessionFactory = new ISessionFactory();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.network.server;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.ljsd.GameApplication;
|
||||
|
@ -20,6 +21,7 @@ import com.ljsd.jieling.logic.dao.PlayerManager;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.netty.handler.GameMessageHandler;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocol.ProtocolsAbstract;
|
||||
|
@ -31,7 +33,10 @@ import com.ljsd.jieling.util.TimeUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -45,9 +50,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
public class ProtocolsManager implements ProtocolsAbstract {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolsManager.class);
|
||||
|
||||
private static ProtocolsManager instance = new ProtocolsManager();
|
||||
|
||||
public static PrintStream ps= null;// 创建文件输出流
|
||||
private Map<Integer, BaseHandler> handlers = new HashMap<>();
|
||||
|
||||
private ProtocolsManager() {
|
||||
|
@ -94,15 +98,18 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
}
|
||||
iSession.setHeartBreatNums(heartBreatNums);
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
@Override
|
||||
public void processMessage(GameSession gameSession, Object obj) throws InvalidProtocolBufferException {
|
||||
public void processMessage(GameSession gameSession, Object obj) {
|
||||
|
||||
if (!GameApplication.start) {
|
||||
return;
|
||||
}
|
||||
final ISession session = (ISession) gameSession;
|
||||
PacketNetData packetNetData = new PacketNetData((byte[])obj);
|
||||
|
||||
PacketNetData packetNetData = new PacketNetData((byte[]) obj);
|
||||
// int msgId = packetNetData.getMsgId();
|
||||
// MessageTypeProto.MessageType messageType = MessageTypeProto.MessageType.valueOf(msgId);
|
||||
// ps.println(messageType + "=" + gson.toJson(obj));
|
||||
if (packetNetData.getMsgId()==1000){
|
||||
dealHeartBeat(session);
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,8 @@ package network.client;
|
|||
|
||||
import com.ljsd.jieling.netty.cocdex.ByteBufDecoder;
|
||||
import com.ljsd.jieling.netty.cocdex.ByteBufEncoder;
|
||||
import com.ljsd.jieling.netty.cocdex.TeaDecoder;
|
||||
import com.ljsd.jieling.netty.cocdex.TeaEncoder;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
|
@ -17,8 +19,8 @@ public class NettyTCPClientInitializer extends ChannelInitializer<SocketChannel>
|
|||
protected void initChannel(SocketChannel ch) throws Exception {
|
||||
|
||||
ChannelPipeline p = ch.pipeline();
|
||||
p.addLast(new ByteBufDecoder());
|
||||
p.addLast(new ByteBufEncoder());
|
||||
p.addLast(new TeaDecoder());
|
||||
p.addLast(new TeaEncoder());
|
||||
p.addLast(new NettyTCPClientHandler());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue