diff --git a/api/build.gradle b/api/build.gradle
index 167b402..77b6af6 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -34,7 +34,6 @@ ext {
nettyVersion = '4.1.10.Final'
}
dependencies {
- testCompile group: 'junit', name: 'junit', version: '4.12'
compile fileTree(include: '*.jar', dir: 'src/libs')
compile project(':service')
compile "io.netty:netty-all:${nettyVersion}"
diff --git a/api/src/main/resources/logback.xml b/api/src/main/resources/logback.xml
index 7f4908b..94dba82 100644
--- a/api/src/main/resources/logback.xml
+++ b/api/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
-
+
@@ -60,4 +60,4 @@
-
\ No newline at end of file
+
diff --git a/api/src/test/java/com/VenueServiceTest.java b/api/src/test/java/com/VenueServiceTest.java
deleted file mode 100644
index f834eb8..0000000
--- a/api/src/test/java/com/VenueServiceTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com;
-
-import com.sv.service.api.VenueService;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.annotation.Resource;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.NONE)
-public class VenueServiceTest {
-
- @Resource
- private VenueService venueService;
-
- @Test
- public void test(){
-// System.out.println(venueService.enterVenue(12,3));
- }
-}
diff --git a/api/src/test/java/com/test/netty/ClientTest.java b/api/src/test/java/com/test/netty/ClientTest.java
deleted file mode 100644
index 1793774..0000000
--- a/api/src/test/java/com/test/netty/ClientTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.test.netty;
-
-import com.test.netty.client.ClientThread;
-
-/**
- * 开启一个客户端,
- */
-public class ClientTest {
- public static void main(String[] args) {
- ClientThread instance = ClientThread.getInstance();
- instance.start();
- }
-}
\ No newline at end of file
diff --git a/api/src/test/java/com/test/netty/client/ClientHandler.java b/api/src/test/java/com/test/netty/client/ClientHandler.java
deleted file mode 100644
index edffdd2..0000000
--- a/api/src/test/java/com/test/netty/client/ClientHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.test.netty.client;
-
-import com.sv.netty.utils.JsonUtils;
-import com.test.netty.client.message.HeartBeat;
-import com.test.netty.client.message.MessageDTO;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
-import io.netty.handler.timeout.IdleState;
-import io.netty.handler.timeout.IdleStateEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * 客户端处理器
- *
- * @author ranfi
- */
-@ChannelHandler.Sharable
-public class ClientHandler extends SimpleChannelInboundHandler {
-
- private static Logger logger = LoggerFactory.getLogger(ClientHandler.class);
-
- /**
- * 当通道就绪就会触发
- * @param ctx
- * @throws Exception
- */
- @Override
- public void channelActive(ChannelHandlerContext ctx) throws Exception {
- super.channelActive(ctx);
- }
-
- /**
- * 当通道失效就会触发
- * @param ctx
- * @throws Exception
- */
- @Override
- public void channelInactive(ChannelHandlerContext ctx) throws Exception {
- super.channelInactive(ctx);
- }
-
- /**
- * 当通道有读取事件时触发
- * @param ctx
- * @param msg
- * @throws Exception
- */
- @Override
- public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
- logger.info("接收服务器响应msg:[" + msg + "]");
- // 安卓写,非netty 后台实现
- MessageDTO message = JsonUtils.decode(msg, MessageDTO.class);
- switch (message.getMessageType()){
- case LOAD:
- System.out.println("LOADING" + message.getMessage());
- break;
- default:
- System.out.println("default");
- }
-// MessageService.getInstance().execute(message);
- }
-
- /**
- * 心跳
- * @param ctx
- * @param evt
- */
- @Override
- public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
- if (IdleStateEvent.class.isAssignableFrom(evt.getClass())) {
- IdleStateEvent event = (IdleStateEvent) evt;
- if (event.state() == IdleState.ALL_IDLE) {
- ctx.writeAndFlush(getHbMessage());
- }
- }
- }
-
- /**
- * 封装心跳请求包
- * @throws Exception
- */
- private HeartBeat getHbMessage() {
- HeartBeat hb = new HeartBeat();
-// hb.setDeviceName("DeviceIdUtil.generateDeviceId(mContext)");
- hb.setDeviceName("shebeiweiyishibiehao");
- hb.setVenueId(32);
- hb.setDeviceType("ENTER");
- return hb;
- }
-
- /**
- * 处理异常
- * @param ctx
- * @param cause
- * @throws Exception
- */
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
- logger.error("ClientHandler exceptionCaught",cause);
- Channel channel = ctx.channel();
- if(channel.isActive()) {
- ctx.close();
- }
- }
-}
diff --git a/api/src/test/java/com/test/netty/client/ClientInitializer.java b/api/src/test/java/com/test/netty/client/ClientInitializer.java
deleted file mode 100644
index 810d623..0000000
--- a/api/src/test/java/com/test/netty/client/ClientInitializer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.test.netty.client;
-
-import com.test.netty.client.config.Constant;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.handler.codec.DelimiterBasedFrameDecoder;
-import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.timeout.IdleStateHandler;
-import io.netty.handler.timeout.ReadTimeoutHandler;
-
-
-public class ClientInitializer extends ChannelInitializer {
-
- private final static int TIME_HEART_BEAT = 20;
-
- public ClientThread.ReConnectHandler reConnectHandler;
- public ClientHandler dmClientHandler;
-
- public ClientInitializer(ClientThread.ReConnectHandler handler, ClientHandler dmClientHandler) {
- reConnectHandler = handler;
- this.dmClientHandler = dmClientHandler;
- }
-
-
- @Override
- protected void initChannel(SocketChannel ch) throws Exception {
- ChannelPipeline pipeline = ch.pipeline();
- pipeline.addLast("reconnect", reConnectHandler);
- pipeline.addLast(new DelimiterBasedFrameDecoder(2048,
- Unpooled.wrappedBuffer(Constant.DELIMITER_WORD.getBytes())));
- pipeline.addLast(new StringDecoder());
- pipeline.addLast(new MessageEncoder());
- pipeline.addLast(new IdleStateHandler(TIME_HEART_BEAT, TIME_HEART_BEAT,TIME_HEART_BEAT));
- pipeline.addLast(dmClientHandler);
- }
-
-}
diff --git a/api/src/test/java/com/test/netty/client/ClientThread.java b/api/src/test/java/com/test/netty/client/ClientThread.java
deleted file mode 100644
index 18ddfce..0000000
--- a/api/src/test/java/com/test/netty/client/ClientThread.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.test.netty.client;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.*;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioSocketChannel;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * 客户端通讯
- *
- * @author peakren
- * @date 07/12/2017 10:12 PM
- */
-public class ClientThread extends Thread{
-
- private static ClientThread instance;
-
- private volatile EventLoopGroup workerGroup;
- private volatile Bootstrap bootstrap;
- private volatile boolean closed = false;
- private String remoteHost;
- private int remotePort;
-
- private ChannelFuture future;
-
-
- public static ClientThread getInstance() {
- if (instance == null) {
- synchronized (ClientThread.class) {
- if (instance == null) {
- instance = new ClientThread("lmqhznn.goho.co", 26283);
- }
- }
- }
- return instance;
- }
-
- private ClientThread(String remoteHost, int remotePort) {
- this.remoteHost = remoteHost;
- this.remotePort = remotePort;
- }
-
- public void run() {
-
- closed = false;
- workerGroup = new NioEventLoopGroup();
- bootstrap = new Bootstrap();
- bootstrap.group(workerGroup);
- bootstrap.channel(NioSocketChannel.class);
- bootstrap.option(ChannelOption.TCP_NODELAY, true);
- bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
-
- ReConnectHandler reConnectHandler = new ReConnectHandler();
- ClientHandler dmClientHandler = new ClientHandler();
- ClientInitializer channelInitializer = new ClientInitializer(reConnectHandler, dmClientHandler);
-
- bootstrap.handler(channelInitializer);
- doConnect();
- }
-
- public void clearFuture(){
- future = null;
- }
-
- public void doConnect() {
- System.out.println("现在开始链接了");
- if (closed) {
- return;
- }
- System.out.println("连接 = " + remoteHost + " " + remotePort);
- future = bootstrap.connect(new InetSocketAddress(remoteHost, remotePort));
- future.addListener(new ChannelFutureListener() {
- public void operationComplete(ChannelFuture f) throws Exception {
- f.channel().eventLoop().schedule(new Runnable() {
- @Override
- public void run() {
- if (!f.isSuccess()) {
- doConnect();
- System.out.println("等待连接");
- } else {
- System.out.println("已连接");
- }
- }
- }, 2, TimeUnit.SECONDS);
-
-
- }
- });
-
- }
-
- public void close() {
- closed = true;
- workerGroup.shutdownGracefully();
- }
-
- public void restart() {
- close();
- run();
- }
-
- @ChannelHandler.Sharable
- public class ReConnectHandler extends ChannelInboundHandlerAdapter {
-
-
- @Override
- public void channelInactive(ChannelHandlerContext ctx) {
- System.out.println("ReConnectHandler inactive");
- ctx.channel().eventLoop().schedule(new Runnable() {
- @Override
- public void run() {
- doConnect();
- }
- }, 1, TimeUnit.SECONDS);
- }
- }
-
-
-}
diff --git a/api/src/test/java/com/test/netty/client/MessageEncoder.java b/api/src/test/java/com/test/netty/client/MessageEncoder.java
deleted file mode 100644
index 3fd6e9e..0000000
--- a/api/src/test/java/com/test/netty/client/MessageEncoder.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.test.netty.client;
-
-import com.sv.netty.config.Constant;
-import com.sv.netty.netty.message.HeartBeat;
-import com.sv.netty.utils.JsonUtils;
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
-
-import java.nio.charset.Charset;
-
-/**
- * 自定义编码器, 1个字节固定头+4个字节长度+内容
- */
-public class MessageEncoder extends MessageToByteEncoder {
-
- Charset charset = Charset.forName("UTF-8");
- /**
- * 安卓打印日志,本地不需要
- */
- private final static String TAG = "MessageEncoder";
-
- @Override
- protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
- String message = JsonUtils.encode(msg);
- message = message + Constant.DELIMITER_WORD;
- byte[] content = message.getBytes(charset.name());
- out.writeBytes(content); //发送消息内容
- }
-
- public static void main(String[] args) {
- String hello = "{\"deviceType\":\"ENTER\",\"deviceName\":\"MGX5T17907001718\",\"venueId\":41}";
- HeartBeat hb = JsonUtils.decode(hello,HeartBeat.class);
- System.out.println(hb);
- }
-}
-
diff --git a/api/src/test/java/com/test/netty/client/config/Constant.java b/api/src/test/java/com/test/netty/client/config/Constant.java
deleted file mode 100644
index 5f1cf4c..0000000
--- a/api/src/test/java/com/test/netty/client/config/Constant.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.test.netty.client.config;
-
-public class Constant {
-
- public final static String DELIMITER_WORD = "$_$";
-
-}
diff --git a/api/src/test/java/com/test/netty/client/message/HeartBeat.java b/api/src/test/java/com/test/netty/client/message/HeartBeat.java
deleted file mode 100644
index 025e411..0000000
--- a/api/src/test/java/com/test/netty/client/message/HeartBeat.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.test.netty.client.message;
-
-import com.google.gson.annotations.Expose;
-import java.io.Serializable;
-
-/**
- * 客户端心跳数据包
- * HeartBeat.java
- *
- * @author peakren
- * @date 07/12/2017 10:23 PM
- */
-public class HeartBeat implements Serializable {
-
- @Expose
- private Integer venueId; //场馆号
-
- @Expose
- private String deviceName; //设备号
-
- @Expose
- private String deviceType; //出入标志
-
- public Integer getVenueId() {
- return venueId;
- }
-
- public void setVenueId(Integer venueId) {
- this.venueId = venueId;
- }
-
- public String getDeviceName() {
- return deviceName;
- }
-
- public void setDeviceName(String deviceName) {
- this.deviceName = deviceName;
- }
-
- public String getDeviceType() {
- return deviceType;
- }
-
- public void setDeviceType(String deviceType) {
- this.deviceType = deviceType;
- }
-}
diff --git a/api/src/test/java/com/test/netty/client/message/MessageDTO.java b/api/src/test/java/com/test/netty/client/message/MessageDTO.java
deleted file mode 100644
index f8c2fea..0000000
--- a/api/src/test/java/com/test/netty/client/message/MessageDTO.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.test.netty.client.message;
-
-import java.io.Serializable;
-
-public class MessageDTO implements Serializable {
-
- private MessageType messageType;
- private String message;
-
- public MessageDTO(MessageType messageType, String message) {
- this.messageType = messageType;
- this.message = message;
- }
-
- public MessageType getMessageType() {
- return messageType;
- }
-
- public void setMessageType(MessageType messageType) {
- this.messageType = messageType;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-}
diff --git a/api/src/test/java/com/test/netty/client/message/MessageType.java b/api/src/test/java/com/test/netty/client/message/MessageType.java
deleted file mode 100644
index a461f38..0000000
--- a/api/src/test/java/com/test/netty/client/message/MessageType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.test.netty.client.message;
-
-public enum MessageType {
- LOAD("加载"),
- OPENDOOR("开门"),
- FAILED("开门校验失败");
-
- private String message;
- MessageType(String message) {
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-}
diff --git a/netty-pad/build.gradle b/netty-pad/build.gradle
index a24047a..81dd8ea 100644
--- a/netty-pad/build.gradle
+++ b/netty-pad/build.gradle
@@ -35,13 +35,9 @@ ext {
jacksonVersion = "2.5.0"
}
-
-[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
-
dependencies {
compile fileTree(include: '*.jar', dir: 'src/libs')
compile project(':service')
-
compile "io.netty:netty-all:${nettyVersion}"
compile 'mysql:mysql-connector-java:6.0.6'
diff --git a/netty-pad/src/main/resources/logback.xml b/netty-pad/src/main/resources/logback.xml
index e7fb94d..5db9344 100644
--- a/netty-pad/src/main/resources/logback.xml
+++ b/netty-pad/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
-
+
@@ -43,4 +43,4 @@
-
\ No newline at end of file
+
diff --git a/oms/src/main/resources/logback.xml b/oms/src/main/resources/logback.xml
index 64bbb83..bb526b5 100644
--- a/oms/src/main/resources/logback.xml
+++ b/oms/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
-
+
@@ -43,4 +43,4 @@
-
\ No newline at end of file
+