# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Item.java
back_recharge
mashiyu 2019-01-17 14:38:47 +08:00
commit aa52efc22b
12 changed files with 211 additions and 195 deletions

View File

@ -1,58 +1,57 @@
Id PiecesId PiecesCount Quality Profession ProfessionResourceId PropertyName Hp Attack PhysicalDefence MagicDefence Speed SkillId RankupConsumeMaterial Id PiecesId PiecesCount Profession PropertyName MaxRank Hp Attack PhysicalDefence MagicDefence Speed SkillId RankupConsumeMaterial
int int int int int int int float float float float float mut,int#int,2 mut,int#int,2 int int int int int int float float float float float mut,int#int,2 mut,int#int,2
1 2001 0 0 0 1203 1 2389 164 278 0 176 10100#10|10101#20 null 1 2001 0 1 1 10 2389 164 278 0 176 10100#10|10101#20 null
2 2002 0 0 0 1202 1 2277 155 260 0 158 10100#10|10101#20 null 2 2002 0 5 2 10 2277 155 260 0 158 10100#10|10101#20 null
3 2003 0 0 0 1202 1 2275 159 263 0 172 10100#10|10101#20 null 3 2003 0 2 3 10 2275 159 263 0 172 10100#10|10101#20 null
4 2004 0 0 0 1201 1 2269 183 0 277 132 10100#10|10101#20 null 4 2004 0 3 4 10 2269 183 0 277 132 10100#10|10101#20 null
5 2005 0 0 0 1203 1 2163 173 0 258 176 10100#10|10101#20 null 5 2005 0 4 5 10 2163 173 0 258 176 10100#10|10101#20 null
6 2006 0 0 0 1202 1 2165 174 0 261 176 10100#10|10101#20 null 6 2006 0 3 6 10 2165 174 0 261 176 10100#10|10101#20 null
7 2007 0 0 0 1201 2 2159 169 0 262 176 10100#10|10101#20 null 7 2007 0 0 2 10 2159 169 0 262 176 10100#10|10101#20 null
8 2008 0 0 0 1202 2 2020 206 0 222 132 10100#10|10101#20 null 8 2008 0 0 2 10 2020 206 0 222 132 10100#10|10101#20 null
9 2009 0 0 0 1203 2 1923 198 0 212 163 10100#10|10101#20 null 9 2009 0 0 2 10 1923 198 0 212 163 10100#10|10101#20 null
10 2010 0 0 0 1201 2 1925 200 0 208 132 10100#10|10101#20 null 10 2010 0 0 2 10 1925 200 0 208 132 10100#10|10101#20 null
11 2011 0 0 0 1201 2 1925 199 0 203 150 10100#10|10101#20 null 11 2011 0 0 2 10 1925 199 0 203 150 10100#10|10101#20 null
12 2012 0 0 0 1202 2 1763 251 201 0 150 10100#10|10101#20 null 12 2012 0 0 2 10 1763 251 201 0 150 10100#10|10101#20 null
13 2013 0 0 0 1202 3 1675 239 194 0 163 10100#10|10101#20 null 13 2013 0 0 3 10 1675 239 194 0 163 10100#10|10101#20 null
14 2014 0 0 0 1201 3 1684 235 197 0 185 10100#10|10101#20 null 14 2014 0 0 3 10 1684 235 197 0 185 10100#10|10101#20 null
15 2015 0 0 0 1203 3 1680 237 193 0 176 10100#10|10101#20 null 15 2015 0 0 3 10 1680 237 193 0 176 10100#10|10101#20 null
16 2016 0 0 0 1202 3 1513 293 167 0 154 10100#10|10101#20 null 16 2016 0 0 3 10 1513 293 167 0 154 10100#10|10101#20 null
17 2017 0 0 0 1201 3 1439 278 159 0 154 10100#10|10101#20 null 17 2017 0 0 3 10 1439 278 159 0 154 10100#10|10101#20 null
18 2018 0 0 0 1201 3 1439 278 159 0 154 10100#10|10101#20 null 18 2018 0 0 3 10 1439 278 159 0 154 10100#10|10101#20 null
19 2019 0 0 0 1201 4 1444 281 153 0 154 10100#10|10101#20 null 19 2019 0 0 4 10 1444 281 153 0 154 10100#10|10101#20 null
20 2020 0 0 0 1202 4 2277 159 261 0 154 10100#10|10101#20 null 20 2020 0 0 4 10 2277 159 261 0 154 10100#10|10101#20 null
21 2021 0 0 0 1201 4 1936 131 225 0 176 10100#10|10101#20 null 21 2021 0 0 4 10 1936 131 225 0 176 10100#10|10101#20 null
22 2022 0 0 0 1203 4 1637 168 0 178 163 10100#10|10101#20 null 22 2022 0 0 4 10 1637 168 0 178 163 10100#10|10101#20 null
23 2023 0 0 0 1201 4 1431 200 162 0 194 10100#10|10101#20 null 23 2023 0 0 4 10 1431 200 162 0 194 10100#10|10101#20 null
24 2024 0 0 0 1202 4 1220 239 133 0 154 10100#10|10101#20 null 24 2024 0 0 4 10 1220 239 133 0 154 10100#10|10101#20 null
25 2025 0 0 0 1203 4 1832 143 0 222 176 10100#10|10101#20 null 25 2025 0 0 4 10 1832 143 0 222 176 10100#10|10101#20 null
26 2026 0 0 0 1201 4 1934 136 226 0 176 10100#10|10101#20 null 26 2026 0 0 4 10 1934 136 226 0 176 10100#10|10101#20 null
27 2027 0 0 0 1201 4 1628 173 0 175 163 10100#10|10101#20 null 27 2027 0 0 4 10 1628 173 0 175 163 10100#10|10101#20 null
28 2028 0 0 0 1201 4 1428 209 165 0 194 10100#10|10101#20 null 28 2028 0 0 4 10 1428 209 165 0 194 10100#10|10101#20 null
29 1000 0 0 0 1201 4 1222 235 132 0 154 10100#10|10101#20 null 29 2029 0 0 4 10 1222 235 132 0 154 10100#10|10101#20 null
30 1000 0 0 0 1201 4 1834 149 0 224 176 10100#10|10101#20 null 30 2030 0 0 4 10 1834 149 0 224 176 10100#10|10101#20 null
31 1000 0 0 0 1201 4 1940 131 220 0 176 10100#10|10101#20 null 31 2031 0 0 4 10 1940 131 220 0 176 10100#10|10101#20 null
32 1000 0 0 0 1201 4 1632 165 0 177 163 10100#10|10101#20 null 32 2032 0 0 4 10 1632 165 0 177 163 10100#10|10101#20 null
33 1000 0 0 0 1201 4 1429 205 164 0 194 10100#10|10101#20 null 33 2033 0 0 4 10 1429 205 164 0 194 10100#10|10101#20 null
34 1000 0 0 0 1201 4 1221 242 135 0 154 10100#10|10101#20 null 34 2034 0 0 4 10 1221 242 135 0 154 10100#10|10101#20 null
35 1000 0 0 0 1201 4 1834 147 0 225 176 10100#10|10101#20 null 35 2035 0 0 4 10 1834 147 0 225 176 10100#10|10101#20 null
36 1000 0 0 0 1201 4 1934 136 217 0 176 10100#10|10101#20 null 36 2036 0 0 4 10 1934 136 217 0 176 10100#10|10101#20 null
37 1000 0 0 0 1201 4 1637 170 0 179 163 10100#10|10101#20 null 37 2037 0 0 4 10 1637 170 0 179 163 10100#10|10101#20 null
38 1000 0 0 0 1201 4 1427 201 170 0 194 10100#10|10101#20 null 38 2038 0 0 4 10 1427 201 170 0 194 10100#10|10101#20 null
39 1000 0 0 0 1201 4 1300 235 129 0 154 10100#10|10101#20 null 39 2039 0 0 4 10 1300 235 129 0 154 10100#10|10101#20 null
40 1000 0 0 0 1201 4 1948 147 0 219 176 10100#10|10101#20 null 40 2040 0 0 4 10 1948 147 0 219 176 10100#10|10101#20 null
41 1000 0 0 0 1201 4 1938 135 224 0 176 10100#10|10101#20 null 41 2041 0 0 4 10 1938 135 224 0 176 10100#10|10101#20 null
42 1000 0 0 0 1201 4 1636 174 0 179 163 10100#10|10101#20 null 42 2042 0 0 4 10 1636 174 0 179 163 10100#10|10101#20 null
43 1000 0 0 0 1201 4 1943 132 217 0 176 10100#10|10101#20 null 43 2043 0 0 4 10 1943 132 217 0 176 10100#10|10101#20 null
44 1000 0 0 0 1201 4 1627 166 0 181 163 10100#10|10101#20 null 44 2044 0 0 4 10 1627 166 0 181 163 10100#10|10101#20 null
45 1000 0 0 0 1202 4 1433 209 166 0 194 10100#10|10101#20 null 45 2045 0 0 4 10 1433 209 166 0 194 10100#10|10101#20 null
46 1000 0 0 0 1201 4 1228 241 131 0 154 10100#10|10101#20 null 46 2046 0 0 4 10 1228 241 131 0 154 10100#10|10101#20 null
47 1000 0 0 0 1201 4 1836 146 0 226 176 10100#10|10101#20 null 47 2047 0 0 4 10 1836 146 0 226 176 10100#10|10101#20 null
48 1000 0 0 0 1201 4 1939 141 223 0 176 10100#10|10101#20 null 48 2048 0 0 4 10 1939 141 223 0 176 10100#10|10101#20 null
49 1000 0 0 0 1201 4 1635 175 0 173 163 10100#10|10101#20 null 49 2049 0 0 4 10 1635 175 0 173 163 10100#10|10101#20 null
50 1000 0 0 0 1201 4 1424 208 166 0 194 10100#10|10101#20 null 50 2050 0 0 4 10 1424 208 166 0 194 10100#10|10101#20 null
51 1000 0 0 0 1201 4 1222 234 132 0 154 10100#10|10101#20 null 51 2051 0 0 4 10 1222 234 132 0 154 10100#10|10101#20 null
52 1000 0 0 0 1201 4 1834 140 0 220 176 10100#10|10101#20 null 52 2052 0 0 4 10 1834 140 0 220 176 10100#10|10101#20 null
53 1000 0 0 0 1201 4 1943 135 219 0 176 10100#10|10101#20 null 53 2053 0 0 4 10 1943 135 219 0 176 10100#10|10101#20 null
54 1000 0 0 0 1201 4 1630 169 0 176 163 10100#10|10101#20 null 54 2054 0 0 4 10 1630 169 0 176 163 10100#10|10101#20 null
55 1000 0 0 0 1201 4 1508 205 163 0 194 10100#10|10101#20 null 55 2055 0 0 4 10 1508 205 163 0 194 10100#10|10101#20 null
56 1000 0 0 0 1201 4 1297 242 137 0 154 10100#10|10101#20 null

View File

@ -16,23 +16,25 @@ public class SCHero implements BaseConfig{
private int piecesCount; private int piecesCount;
private int quality; private int propertyName; //角色属性
private int profession; private int profession; //角色职业
private int maxRank; private int maxRank; //角色最高星级
private float hp; private float hp;
private float attack; private float attack; //攻击力
private float pDefence; private float physicalDefence; //护甲
private float mDefence; private float magicDefence; //魔抗
private float speed; private float speed; //速度
private String skillList; private int[][] skillId;
private int[][] rankupConsumeMaterial;
@Override @Override
public void init() throws Exception { public void init() throws Exception {
@ -58,10 +60,6 @@ public class SCHero implements BaseConfig{
return piecesCount; return piecesCount;
} }
public int getQuality() {
return quality;
}
public int getProfession() { public int getProfession() {
return profession; return profession;
} }
@ -78,19 +76,27 @@ public class SCHero implements BaseConfig{
return attack; return attack;
} }
public float getpDefence() { public float getPhysicalDefence() {
return pDefence; return physicalDefence;
} }
public float getmDefence() { public float getMagicDefence() {
return mDefence; return magicDefence;
} }
public float getSpeed() { public float getSpeed() {
return speed; return speed;
} }
public String getSkillList() { public int getPropertyName() {
return skillList; return propertyName;
}
public int[][] getSkillId() {
return skillId;
}
public int[][] getRankupConsumeMaterial() {
return rankupConsumeMaterial;
} }
} }

View File

@ -180,7 +180,7 @@ public class STableManager {
break; break;
case "string": case "string":
case "stringt": case "stringt":
if (!"null".equalsIgnoreCase(prarms[i])) { if (!"null".equalsIgnoreCase(prarms[i]) || !"".equalsIgnoreCase(prarms[i])) {
field.set(obj, prarms[i]); field.set(obj, prarms[i]);
} }
break; break;

View File

@ -4,18 +4,24 @@ import com.ljsd.common.mogodb.MongoBase;
public class Item extends MongoBase { public class Item extends MongoBase {
private int itemId; private int itemId;
private int itemNum; private int itemNum;
private int itemType;
private int itemQuality;
private boolean isStacking;
private int endingTime; private int endingTime;
public Item(){
}
public Item(int itemId,int itemNum){
this.itemId = itemId;
this.itemNum = itemNum;
this.endingTime = (int)(System.currentTimeMillis()/1000);
}
public int getItemId() { public int getItemId() {
return itemId; return itemId;
@ -35,33 +41,6 @@ public class Item extends MongoBase {
this.itemNum = itemNum; this.itemNum = itemNum;
} }
public int getItemType() {
return itemType;
}
public void setItemType(int itemType) throws Exception {
updateString("itemType", itemType);
this.itemType = itemType;
}
public int getItemQuality() {
return itemQuality;
}
public void setItemQuality(int itemQuality) throws Exception {
updateString("itemQuality", itemQuality);
this.itemQuality = itemQuality;
}
public boolean isStacking() {
return isStacking;
}
public void setStacking(boolean stacking) throws Exception {
updateString("stacking", stacking);
isStacking = stacking;
}
public int getEndingTime() { public int getEndingTime() {
return endingTime; return endingTime;
} }

View File

@ -33,18 +33,12 @@ public class ItemManager extends MongoBase {
public void removeItem(Integer key) { public void removeItem(Integer key) {
itemMap.remove(key); itemMap.remove(key);
removeString(getMongoKey() + ".itemMap." + key);
} }
public Item newItem(int itemId, int itemNum) throws Exception { public Item newItem(int itemId, int itemNum) throws Exception {
SItem sItem = SItem.getsItemMap().get(itemId); Item item = new Item(itemId,itemNum);
Item item = new Item(); addItem(item);
item.setItemId(itemId);
item.setItemNum(itemNum);
item.setItemType(sItem.getItemType());
item.setItemQuality(sItem.getQuantity());
int endTime = (int)(System.currentTimeMillis()/1000);
item.setEndingTime(endTime);
item.setStacking( sItem.isStacking());
return item; return item;
} }

View File

@ -0,0 +1,36 @@
package com.ljsd.jieling.logic.dao;
import java.util.Date;
public class Mail {
private String id;
private int roleUid; //所属玩家的UID
private boolean isRead;//是,否已读,未读,附件未领取
private String head; //标题
private Date sendDate;//发送的日期
private long sendTime; //发送时间
private String mailItemList;//获取所有的附件
private int effectiveTime;//有效日期
private int isDraw;//附件状态 是 否领取1和0
private String content;//邮件内容
private long readtime;//读邮件时间
private String sendName;//发送者名字
private int senderUid;
private long recvTime;
private int mailType; //邮件类型 1:系统邮件 2:idip 业务邮件
}

View File

@ -4,6 +4,7 @@ import com.ljsd.jieling.config.SItem;
import com.ljsd.jieling.logic.dao.Item; import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.ItemManager; import com.ljsd.jieling.logic.dao.ItemManager;
import com.ljsd.jieling.logic.dao.User; import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -21,15 +22,36 @@ public class ItemUtil {
public static void addItem(User user, Map<Integer, Integer> itemMap) throws Exception { public static void addItem(User user, Map<Integer, Integer> itemMap) throws Exception {
ItemManager itemManager = user.getItemManager(); ItemManager itemManager = user.getItemManager();
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) { for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
SItem sItem = SItem.getsItemMap().get(entry.getKey());
Item item = itemManager.getItem(entry.getKey()); Item item = itemManager.getItem(entry.getKey());
if (item == null){ if (item == null){
item = itemManager.newItem(entry.getKey(), entry.getValue()); item = itemManager.newItem(entry.getKey(), entry.getValue());
}else{ }else{
if (item.isStacking()){ if(sItem.isStacking()){
item.setItemNum(item.getItemNum() + entry.getValue()); item.setItemNum(item.getItemNum() + entry.getValue());
} }
} }
itemManager.addItem(item); }
//todo 为了测试 日后要删掉
UserManager.ljsdMongoTemplate.lastUpdate();
}
public static void useItem(User user,Map<Integer,Integer> useItemMap) throws Exception{
if(useItemMap.isEmpty()){
return;
}
ItemManager itemManager = user.getItemManager();
for (Map.Entry<Integer, Integer> userItem : useItemMap.entrySet()) {
Item myItem = itemManager.getItem(userItem.getKey());
if( null == myItem){
continue;
}
int needCount = userItem.getValue();
if(myItem.getItemNum()<=needCount){
itemManager.removeItem(userItem.getKey());
}else{
myItem.setItemNum( myItem.getItemNum() - needCount);
}
} }
} }

View File

@ -13,5 +13,6 @@ repositories {
dependencies { dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'junit', name: 'junit', version: '4.12'
compile project(":serverlogic")
compile("org.apache.poi:poi-ooxml:3.12") compile("org.apache.poi:poi-ooxml:3.12")
} }

View File

@ -63,7 +63,7 @@ public class ExcelUtils {
// } // }
if (row != null) { if (row != null) {
StringBuilder info = new StringBuilder(); StringBuilder info = new StringBuilder();
int colnum = row.getLastCellNum(); int colnum = row2.getLastCellNum();
for (int j = 1; j < colnum; j++) { for (int j = 1; j < colnum; j++) {
int cellFormatValue = (int) getCellFormatValue(row1.getCell(j)); int cellFormatValue = (int) getCellFormatValue(row1.getCell(j));
if (cellFormatValue == 3){ if (cellFormatValue == 3){
@ -87,18 +87,22 @@ public class ExcelUtils {
info.append("\t").append(cellData); info.append("\t").append(cellData);
} }
} }
} }else{
if (getCellFormatValue(row1.getCell(j)).toString().isEmpty()){ if (getCellFormatValue(row1.getCell(j)).toString().isEmpty()){
continue; continue;
} }
//文件名 //文件名
cellData = getCellFormatValue(cell); cellData = getCellFormatValue(cell);
if ("".equals(cellData.toString())){
cellData = getIn(row2.getCell(j).toString());
}
if (info.length() == 0){ if (info.length() == 0){
info = info.append(cellData); info = info.append(cellData);
}else{ }else{
info.append("\t").append(cellData); info.append("\t").append(cellData);
} }
} }
}
out.write(info.toString()); out.write(info.toString());
out.write("\r\n"); out.write("\r\n");
} }
@ -114,6 +118,7 @@ public class ExcelUtils {
str = "false"; str = "false";
break; break;
case "int": case "int":
case "float":
str = "0"; str = "0";
break; break;
case "string": case "string":

View File

@ -1,8 +1,9 @@
package com.ljsd.jieling.network.client; package network.client;
import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.*;
import com.ljsd.jieling.netty.cocdex.PacketNetData; import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.network.NettyProperties; import com.ljsd.jieling.protocols.GMCommandProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto; import com.ljsd.jieling.protocols.PlayerInfoProto;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -11,21 +12,15 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.List;
@Configuration
@EnableAutoConfiguration
@EnableConfigurationProperties(NettyProperties.class)
@ComponentScan
public class NettyClient { public class NettyClient {
private static final Logger LOGGER = LoggerFactory.getLogger(NettyClient.class); private static final Logger LOGGER = LoggerFactory.getLogger(NettyClient.class);
private static int uid = 10000001;
private static int msgIndex = 1;
private static int token=543242;
public static void main(String[] args) throws InterruptedException, InvalidProtocolBufferException { public static void main(String[] args) throws InterruptedException, InvalidProtocolBufferException {
EventLoopGroup group = new NioEventLoopGroup(1); EventLoopGroup group = new NioEventLoopGroup(1);
@ -39,28 +34,33 @@ public class NettyClient {
Channel ch = b.connect("127.0.0.1",18090).sync().channel(); Channel ch = b.connect("127.0.0.1",18090).sync().channel();
NettyTCPClientHandler handler = ch.pipeline().get(NettyTCPClientHandler.class); NettyTCPClientHandler handler = ch.pipeline().get(NettyTCPClientHandler.class);
/*------------------------------------------测试类型-------------------------------------------------------*/ //------------------------------------------测试类型-------------------------------------------------------
// GameProto.GameMessage gameMessage = new NettyClient().sendLoginMessageTest();//登陆请求 // GameProto.GameMessage gameMessage = new NettyClient().sendLoginMessageTest();//登陆请求
PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest gameMessage = new NettyClient().sendRegisterMessageTest();//注册请求 PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest gameMessage = new NettyClient().sendRegisterMessageTest();//注册请求
LOGGER.info(gameMessage.toString()); LOGGER.info(gameMessage.toString());
/*---------------------------------------------------------------------------------------------------------*/ //---------------------------------------------------------------------------------------------------------
List<PacketNetData> result = handler.sendRequest_jieling(gameMessage); handler.sendRequest_jieling(makeFinalMessage(gameMessage, MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE));
handler.sendRequest_jieling(makeFinalMessage(gmRequest(), MessageTypeProto.MessageType.GM_COMMAND_VALUE));
// while (true){ }
// Thread.sleep(5000);
// List<PacketNetData> result = handler.sendRequest_jieling(gameMessage);
//
//// List<PacketNetData> result = handler.sendHeartBeat_jieling();
// LOGGER.info("send to server...");
// }
// ch.close();
// } private static byte[] makeFinalMessage(MessageLite request, int msgNum) {
// finally { byte[] messageData = request.toByteArray();
// group.shutdownGracefully(); byte[] packetData = new byte[messageData.length + 16];
// } Tea.intToByte(packetData, 0, uid); //uid
Tea.intToByte(packetData, 4, token); //token
Tea.intToByte(packetData, 8,msgNum); //msgId
Tea.intToByte(packetData, 12, msgIndex); // msgIndex
System.arraycopy(messageData, 0, packetData, 16, messageData.length);
int[] secretKey = Tea.KEY;
byte[] finalData = Tea.encrypt2(packetData, secretKey);
return finalData;
}
public static GMCommandProto.GMCommand gmRequest(){
return GMCommandProto.GMCommand.newBuilder().setCommand("10000001#0#1#100").build();
} }

View File

@ -1,9 +1,8 @@
package com.ljsd.jieling.network.client; package network.client;
import com.google.protobuf.MessageLite; import com.google.protobuf.MessageLite;
import com.ljsd.jieling.netty.cocdex.PacketNetData; import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.netty.cocdex.Tea; import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
@ -65,23 +64,8 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
} }
public List<PacketNetData> sendRequest_jieling(MessageLite request) { public void sendRequest_jieling( byte[] finalMessage) {
byte[] finalMessage = makeFinalMessage(request);
channel.writeAndFlush(finalMessage); channel.writeAndFlush(finalMessage);
ArrayList<PacketNetData> msgs = new ArrayList<PacketNetData>();
// try {
// Thread.sleep(1000);
// for (PacketNetData gameMessage1: answer){
// gameMessage1 = answer.take();
// msgs.add(gameMessage1);
// }
// } catch (InterruptedException e) {
// LOGGER.error("sendRequest->msg={}", e.getMessage(), e);
// }
return msgs;
} }
@ -96,21 +80,6 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
} }
private byte[] makeFinalMessage(MessageLite request) {
byte[] messageData = request.toByteArray();
byte[] packetData = new byte[messageData.length + 16];
Tea.intToByte(packetData, 0, 10000001);
Tea.intToByte(packetData, 4, 543242);
Tea.intToByte(packetData, 8, 10600);
Tea.intToByte(packetData, 12, 1);
System.arraycopy(messageData, 0, packetData, 16, messageData.length);
int[] secretKey = Tea.KEY;
byte[] finalData = Tea.encrypt2(packetData, secretKey);
return finalData;
}
private byte[] makeHeartBeatMessage() { private byte[] makeHeartBeatMessage() {
byte[] packetData = new byte[12]; byte[] packetData = new byte[12];
Tea.intToByte(packetData, 0, 10000001); Tea.intToByte(packetData, 0, 10000001);
@ -136,9 +105,14 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
int userId = packetNetData.getUserId(); int userId = packetNetData.getUserId();
int token = packetNetData.getToken(); int token = packetNetData.getToken();
int msgId = packetNetData.getMsgId(); int msgId = packetNetData.getMsgId();
byte[] packetData = packetNetData.getPacketData();
System.out.println("back hartbeat id : "+msgId); System.out.println("back hartbeat id : "+msgId);
//System.out.println(JsonFormat.printToString());
// int msgIndex = packetNetData.getIndex(); // int msgIndex = packetNetData.getIndex();
// int resultCode = packetNetData.getResult(); // int resultCode = packetNetData.getResult();
// byte[] backmessage = packetNetData.parseServerProtoNetData(); // byte[] backmessage = packetNetData.parseServerProtoNetData();

View File

@ -1,4 +1,4 @@
package com.ljsd.jieling.network.client; package network.client;
import com.ljsd.jieling.netty.cocdex.ByteBufDecoder; import com.ljsd.jieling.netty.cocdex.ByteBufDecoder;
import com.ljsd.jieling.netty.cocdex.ByteBufEncoder; import com.ljsd.jieling.netty.cocdex.ByteBufEncoder;