Merge branch 'master' of 60.1.1.230:backend/jieling_server
commit
68a9e3e38e
|
@ -0,0 +1,93 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DrawHeroHandler extends BaseHandler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DrawHeroHandler.class);
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.DRAW_HERO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
int userId = netData.getUserId();
|
||||
int token = netData.getToken();
|
||||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
HeroInfoProto.DrawHeroRequest request
|
||||
= HeroInfoProto.DrawHeroRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,request.getType(),request.getStr());
|
||||
|
||||
|
||||
List<CommonProto.Hero> heroList = new ArrayList<>();
|
||||
CommonProto.Hero hero1 = CommonProto.Hero.newBuilder()
|
||||
.setId("aaa")
|
||||
.setHeroId(1)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero2 = CommonProto.Hero.newBuilder()
|
||||
.setId("bbb")
|
||||
.setHeroId(2)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero3 = CommonProto.Hero.newBuilder()
|
||||
.setId("ccc")
|
||||
.setHeroId(3)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
heroList.add(hero1);
|
||||
heroList.add(hero2);
|
||||
heroList.add(hero3);
|
||||
|
||||
HeroInfoProto.DrawHeroResponse build
|
||||
= HeroInfoProto.DrawHeroResponse.newBuilder()
|
||||
.addAllHeroList(heroList)
|
||||
.build();
|
||||
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.DRAW_HERO_RESPONSE_VALUE, build, true);
|
||||
LOGGER.info("back to client!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.config.SCHero;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
@ -26,11 +25,21 @@ public class GetAllHeroHandler extends BaseHandler {
|
|||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] packetData = netData.parseClientProtoNetData();
|
||||
int uid = iSession.getUid();
|
||||
int userId = netData.getUserId();
|
||||
int token = netData.getToken();
|
||||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
HeroInfoProto.GetHeroListInfoRequest getHeroInfoRequest
|
||||
= HeroInfoProto.GetHeroListInfoRequest.parseFrom(message);
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,getHeroInfoRequest.getNum(),getHeroInfoRequest.getStr());
|
||||
|
||||
// // SCHero scHero = SCHero.getsCHero().get(1);
|
||||
|
||||
List<CommonProto.Hero> heroList = new ArrayList<>();
|
||||
// SCHero scHero = SCHero.getsCHero().get(1);
|
||||
CommonProto.Hero hero = CommonProto.Hero.newBuilder()
|
||||
CommonProto.Hero hero1 = CommonProto.Hero.newBuilder()
|
||||
.setId("aaa")
|
||||
.setHeroId(1)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
|
@ -40,15 +49,48 @@ public class GetAllHeroHandler extends BaseHandler {
|
|||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.addAllEquipList(new ArrayList<>())
|
||||
.addAllSkillList(new ArrayList<>())
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero2 = CommonProto.Hero.newBuilder()
|
||||
.setId("bbb")
|
||||
.setHeroId(2)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
heroList.add(hero);
|
||||
HeroInfoProto.GetHeroInfoResponse build = HeroInfoProto.GetHeroInfoResponse.newBuilder().addAllHeroList(heroList).build();
|
||||
//HeroInfoProto.HeroInfo.GetHeroInfoResponse build = HeroInfoProto.HeroInfo.GetHeroInfoResponse.newBuilder().setHeroList(hero).build();
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_HEROINFO_RESPONSE_VALUE, build, true);
|
||||
LOGGER.info("back to client!");
|
||||
CommonProto.Hero hero3 = CommonProto.Hero.newBuilder()
|
||||
.setId("ccc")
|
||||
.setHeroId(3)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
heroList.add(hero1);
|
||||
heroList.add(hero2);
|
||||
heroList.add(hero3);
|
||||
|
||||
HeroInfoProto.GetHeroListInfoResponse build
|
||||
= HeroInfoProto.GetHeroListInfoResponse.newBuilder()
|
||||
.addAllHeroList(heroList)
|
||||
.build();
|
||||
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_HEROINFO_RESPONSE_VALUE, build, true);
|
||||
LOGGER.info("back to client!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,17 @@ package com.ljsd.jieling.handler;
|
|||
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
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 com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class GetAllItemHandler extends BaseHandler {
|
||||
|
||||
|
@ -26,9 +31,39 @@ public class GetAllItemHandler extends BaseHandler {
|
|||
int msgIndex = netData.getIndex();
|
||||
PlayerInfoProto.GetItemInfoRequest getItemInfoRequest
|
||||
= PlayerInfoProto.GetItemInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,getItemInfoRequest.getNum(),getItemInfoRequest.getStr());
|
||||
|
||||
List<CommonProto.Item> itemList = new ArrayList<>();
|
||||
CommonProto.Item item1 = CommonProto.Item.newBuilder()
|
||||
.setItemId(1)
|
||||
.setItemNum(111)
|
||||
.build();
|
||||
CommonProto.Item item2 = CommonProto.Item.newBuilder()
|
||||
.setItemId(2)
|
||||
.setItemNum(222)
|
||||
.build();
|
||||
CommonProto.Item item3 = CommonProto.Item.newBuilder()
|
||||
.setItemId(3)
|
||||
.setItemNum(333)
|
||||
.build();
|
||||
|
||||
|
||||
itemList.add(item1);
|
||||
itemList.add(item2);
|
||||
itemList.add(item3);
|
||||
|
||||
// User user = UserManager.getUserForLogin(userId);
|
||||
// List<CommonProto.Item> itemList = ItemUtil.getAllItem(user);
|
||||
PlayerInfoProto.GetItemInfoResponse getItemInfoResponse = PlayerInfoProto.GetItemInfoResponse.newBuilder()
|
||||
.addAllItemlist(itemList)
|
||||
.build();
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_ITEMINFO_RESPONSE_VALUE, getItemInfoResponse, true);
|
||||
LOGGER.info("back to client!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,10 @@ import com.ljsd.jieling.config.SItem;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ItemManager extends MongoBase {
|
||||
private Map<Integer, Item> itemMap;
|
||||
private Map<Integer, Item> itemMap = new ConcurrentHashMap<>();
|
||||
|
||||
public ItemManager() {
|
||||
itemMap = new HashMap();
|
||||
|
|
|
@ -14,6 +14,7 @@ public class CBean2Proto {
|
|||
.newBuilder()
|
||||
.setUid(uid)
|
||||
.setNickName(playerManager.getNickName())
|
||||
.setLevel(playerManager.getLevel())
|
||||
.setExp(playerManager.getExp())
|
||||
.setVipLevel(playerManager.getVipLevel())
|
||||
.setFamilyId(playerManager.getFamilyId())
|
||||
|
|
|
@ -5,9 +5,12 @@ import com.ljsd.jieling.logic.dao.Item;
|
|||
import com.ljsd.jieling.logic.dao.ItemManager;
|
||||
import com.ljsd.jieling.logic.dao.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemUtil {
|
||||
|
@ -55,4 +58,17 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<CommonProto.Item > getAllItem(User user){
|
||||
List<CommonProto.Item > itemList = new ArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
Map<Integer, Item> itemMap = itemManager.getItemMap();
|
||||
if (itemMap.size() !=0 ){
|
||||
for (Map.Entry<Integer, Item> entry :itemMap.entrySet()){
|
||||
itemList.add(CBean2Proto.getItem(entry.getValue()));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ spring.redis.expireTime = -1
|
|||
#spring.data.mongodb.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/ysj_wx_1
|
||||
#spring.data.mongodb2.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/develop_ysj_wx_1
|
||||
#mongodb2 develop
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/ysj_msy
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_msy
|
||||
mongodb.options.maxWaitTime = 120000
|
||||
mongodb.options.connectTimeout = 1000
|
||||
mongodb.options.socketTimeout = 0
|
||||
|
|
|
@ -176,21 +176,7 @@ public class ExcelUtils {
|
|||
Cell cell = row.getCell(j);
|
||||
if (cell == null){
|
||||
Cell cell1 = row4.getCell(j);
|
||||
if (cell1==null){
|
||||
String in = getIn(row2.getCell(j).toString());
|
||||
if (info.length() == 0){
|
||||
info = info.append(in);
|
||||
}else{
|
||||
info.append("\t").append(in);
|
||||
}
|
||||
}else{
|
||||
cellData = getCellFormatValue(cell1);
|
||||
if (info.length() == 0){
|
||||
info = info.append(cellData);
|
||||
}else{
|
||||
info.append("\t").append(cellData);
|
||||
}
|
||||
}
|
||||
info = getStringBuilder(row2, info, j, cell1);
|
||||
}else{
|
||||
if (getCellFormatValue(row1.getCell(j)).toString().isEmpty()){
|
||||
continue;
|
||||
|
@ -215,6 +201,26 @@ public class ExcelUtils {
|
|||
out.close();
|
||||
}
|
||||
|
||||
private static StringBuilder getStringBuilder(Row row2, StringBuilder info, int j, Cell cell1) {
|
||||
Object cellData;
|
||||
if (cell1==null){
|
||||
String in = getIn(row2.getCell(j).toString());
|
||||
if (info.length() == 0){
|
||||
info = info.append(in);
|
||||
}else{
|
||||
info.append("\t").append(in);
|
||||
}
|
||||
}else{
|
||||
cellData = getCellFormatValue(cell1);
|
||||
if (info.length() == 0){
|
||||
info = info.append(cellData);
|
||||
}else{
|
||||
info.append("\t").append(cellData);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private static String getIn(String row2) {
|
||||
String str = "";
|
||||
switch (row2) {
|
||||
|
|
|
@ -46,8 +46,8 @@ public class NettyClient {
|
|||
|
||||
}
|
||||
|
||||
public static HeroInfoProto.GetHeroInfoRequest getHero(){
|
||||
return HeroInfoProto.GetHeroInfoRequest.newBuilder().setNum(1).setStr("111").build();
|
||||
public static HeroInfoProto.GetHeroListInfoRequest getHero(){
|
||||
return HeroInfoProto.GetHeroListInfoRequest.newBuilder().setNum(1).setStr("111").build();
|
||||
}
|
||||
|
||||
private static byte[] makeFinalMessage(MessageLite request, int msgNum) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
|||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
@ -113,10 +114,10 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
|
|||
byte[] packetData = packetNetData.parseServerProtoNetData();
|
||||
|
||||
if(msgId == GET_HEROINFO_RESPONSE_VALUE){
|
||||
HeroInfoProto.GetHeroInfoResponse getHeroInfoResponse = HeroInfoProto.GetHeroInfoResponse.parseFrom(packetData);
|
||||
int heroListCount = getHeroInfoResponse.getHeroListCount();
|
||||
HeroInfoProto.GetHeroListInfoResponse getHeroInfoResponse = HeroInfoProto.GetHeroListInfoResponse.parseFrom(packetData);
|
||||
// int heroListCount = getHeroInfoResponse.getHeroListCount();
|
||||
//int heroListCount = getHeroInfoResponse.getHeroListCount();
|
||||
System.out.println("--->>>>" + heroListCount);
|
||||
// System.out.println("--->>>>" + heroListCount);
|
||||
}
|
||||
|
||||
System.out.println("back hartbeat id : "+msgId);
|
||||
|
|
Loading…
Reference in New Issue