rename package

master
wanglong 2021-11-13 11:56:53 +08:00
parent 8e6f35ae2a
commit 99b50ab2d2
46 changed files with 148 additions and 151 deletions

View File

@ -8,12 +8,11 @@
* TCP协议服务端开发
## 代码仓库
* Gitee仓库地址[https://gitee.com/yezhihao/netmc/tree/master](https://gitee.com/yezhihao/netmc/tree/master)
* Github仓库地址[https://github.com/yezhihao/netmc/tree/master](https://github.com/yezhihao/netmc/tree/master)
* Gitee仓库地址[http://115.29.108.160:3000/TripartiteOpenSource/netmc](http://115.29.108.160:3000/TripartiteOpenSource/netmc)
* Github仓库地址[http://115.29.108.160:3000/TripartiteOpenSource/netmc](http://115.29.108.160:3000/TripartiteOpenSource/netmc)
## 下载方式
* Gitee下载命令`git clone https://gitee.com/yezhihao/netmc -b master`
* Github下载命令`git clone https://github.com/yezhihao/netmc -b master`
* Git下载命令`git clone http://115.29.108.160:3000/TripartiteOpenSource/netmc.git -b master`
## 项目结构
```sh
@ -72,10 +71,4 @@ public class JT808Endpoint {
详细的例子请参考Test目录
使用该组件的项目:[https://gitee.com/yezhihao/jt808-server/tree/master](https://gitee.com/yezhihao/jt808-server/tree/master)
项目会不定期进行更新建议star和watch一份您的支持是我最大的动力。
如有任何疑问或者BUG请联系我非常感谢。
技术交流QQ群[906230542]
当前项目是Fork [剑器近](https://gitee.com/yezhihao) 的 [netmc](https://gitee.com/yezhihao/netmc?_from=gitee_search)

17
pom.xml
View File

@ -177,11 +177,13 @@
<distributionManagement>
<repository>
<id>nexus-release</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
<name>Nexus Release Repository</name>
<url>http://113.250.52.44:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<id>nexus-snapshots</id>
<name>Nexus Release Repository</name>
<url>http://113.250.52.44:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</profile>
@ -189,13 +191,16 @@
<repositories>
<repository>
<id>central</id>
<name>Maven Central</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<id>deployer</id>
<name>deployer</name>
<url>http://113.250.52.44:8081/repository/maven-public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@ -1,13 +1,13 @@
package io.github.yezhihao.netmc;
package com.dust.tripartite.netmc;
import io.github.yezhihao.netmc.codec.Delimiter;
import io.github.yezhihao.netmc.codec.LengthField;
import io.github.yezhihao.netmc.codec.MessageDecoder;
import io.github.yezhihao.netmc.codec.MessageEncoder;
import io.github.yezhihao.netmc.core.HandlerInterceptor;
import io.github.yezhihao.netmc.core.HandlerMapping;
import io.github.yezhihao.netmc.session.SessionListener;
import io.github.yezhihao.netmc.session.SessionManager;
import com.dust.tripartite.netmc.codec.LengthField;
import com.dust.tripartite.netmc.codec.MessageEncoder;
import com.dust.tripartite.netmc.core.HandlerInterceptor;
import com.dust.tripartite.netmc.core.HandlerMapping;
import com.dust.tripartite.netmc.session.SessionListener;
import com.dust.tripartite.netmc.codec.Delimiter;
import com.dust.tripartite.netmc.codec.MessageDecoder;
import com.dust.tripartite.netmc.session.SessionManager;
import io.netty.channel.ChannelInboundHandlerAdapter;
/**

View File

@ -1,9 +1,9 @@
package io.github.yezhihao.netmc;
package com.dust.tripartite.netmc;
import io.github.yezhihao.netmc.codec.DelimiterBasedFrameDecoder;
import io.github.yezhihao.netmc.codec.LengthFieldAndDelimiterFrameDecoder;
import io.github.yezhihao.netmc.codec.MessageDecoderWrapper;
import io.github.yezhihao.netmc.codec.MessageEncoderWrapper;
import com.dust.tripartite.netmc.codec.DelimiterBasedFrameDecoder;
import com.dust.tripartite.netmc.codec.LengthFieldAndDelimiterFrameDecoder;
import com.dust.tripartite.netmc.codec.MessageDecoderWrapper;
import com.dust.tripartite.netmc.codec.MessageEncoderWrapper;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author yezhihao
@ -28,7 +29,7 @@ import java.util.concurrent.TimeUnit;
public class TCPServer {
private static final Logger log = LoggerFactory.getLogger(TCPServer.class);
private volatile boolean isRunning = false;
private final AtomicBoolean isRunning = new AtomicBoolean(false);
private EventLoopGroup bossGroup = null;
private EventLoopGroup workerGroup = null;
@ -83,29 +84,27 @@ public class TCPServer {
return new LengthFieldAndDelimiterFrameDecoder(config.maxFrameLength, config.lengthField, config.delimiter);
}
public synchronized void start() {
if (this.isRunning) {
public void start() {
if (!isRunning.compareAndSet(false, true)) {
log.warn("==={}已经启动, port={}===", name, config.port);
return;
}
this.isRunning = true;
new Thread(() -> startInternal()).start();
new Thread(this::startInternal).start();
}
public synchronized void stop() {
if (!this.isRunning) {
public void stop() {
if (!isRunning.compareAndSet(true, false)) {
log.warn("==={}已经停止, port={}===", name, config.port);
return;
}
this.isRunning = false;
Future future = this.bossGroup.shutdownGracefully();
if (!future.isSuccess())
Future<?> future = this.bossGroup.shutdownGracefully();
if (!future.isSuccess()) {
log.warn("bossGroup 无法正常停止", future.cause());
}
future = this.workerGroup.shutdownGracefully();
if (!future.isSuccess())
if (!future.isSuccess()) {
log.warn("workerGroup 无法正常停止", future.cause());
}
log.warn("==={}已经停止, port={}===", name, config.port);
}
}

View File

@ -1,12 +1,12 @@
package io.github.yezhihao.netmc;
package com.dust.tripartite.netmc;
import io.github.yezhihao.netmc.core.HandlerInterceptor;
import io.github.yezhihao.netmc.core.HandlerMapping;
import io.github.yezhihao.netmc.core.handler.Handler;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import io.github.yezhihao.netmc.session.SessionListener;
import io.github.yezhihao.netmc.session.SessionManager;
import com.dust.tripartite.netmc.core.HandlerInterceptor;
import com.dust.tripartite.netmc.core.HandlerMapping;
import com.dust.tripartite.netmc.core.handler.Handler;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.session.Session;
import com.dust.tripartite.netmc.session.SessionListener;
import com.dust.tripartite.netmc.session.SessionManager;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
public class Delimiter {
protected byte[] value;

View File

@ -1,11 +1,11 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.util.internal.ObjectUtil;
import io.github.yezhihao.netmc.util.ByteBufUtils;
import com.dust.tripartite.netmc.util.ByteBufUtils;
import java.util.List;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import static io.netty.util.internal.ObjectUtil.checkPositive;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;

View File

@ -1,12 +1,12 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import com.dust.tripartite.netmc.util.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.util.internal.ObjectUtil;
import io.github.yezhihao.netmc.util.ByteBufUtils;
import java.util.List;

View File

@ -1,6 +1,6 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.session.Session;
import io.netty.buffer.ByteBuf;
/**

View File

@ -1,6 +1,6 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.session.Session;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandler;

View File

@ -1,6 +1,6 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.session.Session;
import io.netty.buffer.ByteBuf;
/**

View File

@ -1,6 +1,6 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.session.Session;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;

View File

@ -1,10 +1,10 @@
package io.github.yezhihao.netmc.core;
package com.dust.tripartite.netmc.core;
import io.github.yezhihao.netmc.core.annotation.AsyncBatch;
import io.github.yezhihao.netmc.core.annotation.Mapping;
import io.github.yezhihao.netmc.core.handler.AsyncBatchHandler;
import io.github.yezhihao.netmc.core.handler.Handler;
import io.github.yezhihao.netmc.core.handler.SimpleHandler;
import com.dust.tripartite.netmc.core.annotation.AsyncBatch;
import com.dust.tripartite.netmc.core.annotation.Mapping;
import com.dust.tripartite.netmc.core.handler.AsyncBatchHandler;
import com.dust.tripartite.netmc.core.handler.Handler;
import com.dust.tripartite.netmc.core.handler.SimpleHandler;
import java.lang.reflect.Method;
import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package io.github.yezhihao.netmc.core;
package com.dust.tripartite.netmc.core;
import io.github.yezhihao.netmc.core.annotation.Endpoint;
import io.github.yezhihao.netmc.util.ClassUtils;
import com.dust.tripartite.netmc.util.ClassUtils;
import com.dust.tripartite.netmc.core.annotation.Endpoint;
import java.util.List;

View File

@ -1,7 +1,7 @@
package io.github.yezhihao.netmc.core;
package com.dust.tripartite.netmc.core;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.session.Session;
/**
*

View File

@ -1,6 +1,6 @@
package io.github.yezhihao.netmc.core;
package com.dust.tripartite.netmc.core;
import io.github.yezhihao.netmc.core.handler.Handler;
import com.dust.tripartite.netmc.core.handler.Handler;
/**
*

View File

@ -1,6 +1,6 @@
package io.github.yezhihao.netmc.core;
package com.dust.tripartite.netmc.core;
import io.github.yezhihao.netmc.core.annotation.Endpoint;
import com.dust.tripartite.netmc.core.annotation.Endpoint;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.core.annotation;
package com.dust.tripartite.netmc.core.annotation;
import java.lang.annotation.*;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.core.annotation;
package com.dust.tripartite.netmc.core.annotation;
import java.lang.annotation.*;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.core.annotation;
package com.dust.tripartite.netmc.core.annotation;
import java.lang.annotation.*;

View File

@ -1,9 +1,9 @@
package io.github.yezhihao.netmc.core.handler;
package com.dust.tripartite.netmc.core.handler;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import io.github.yezhihao.netmc.util.BasicThreadFactory;
import io.github.yezhihao.netmc.util.VirtualList;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.session.Session;
import com.dust.tripartite.netmc.util.BasicThreadFactory;
import com.dust.tripartite.netmc.util.VirtualList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,7 +1,7 @@
package io.github.yezhihao.netmc.core.handler;
package com.dust.tripartite.netmc.core.handler;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.session.Session;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
import java.lang.reflect.Method;

View File

@ -1,7 +1,7 @@
package io.github.yezhihao.netmc.core.handler;
package com.dust.tripartite.netmc.core.handler;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.session.Session;
import java.lang.reflect.Method;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.core.model;
package com.dust.tripartite.netmc.core.model;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.core.model;
package com.dust.tripartite.netmc.core.model;
/**
* @author yezhihao

View File

@ -1,7 +1,7 @@
package io.github.yezhihao.netmc.session;
package com.dust.tripartite.netmc.session;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.core.model.Response;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.core.model.Response;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.session;
package com.dust.tripartite.netmc.session;
/**
* @author yezhihao

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.session;
package com.dust.tripartite.netmc.session;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import java.util.AbstractCollection;
import java.util.Collection;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import java.util.AbstractList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import java.util.AbstractMap;
import java.util.Map;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import java.util.AbstractSet;
import java.util.Iterator;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import io.netty.buffer.ByteBuf;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.util;
package com.dust.tripartite.netmc.util;
import java.io.Serializable;
import java.util.*;

View File

@ -1,10 +1,10 @@
package io.github.yezhihao.netmc;
package com.dust.tripartite.netmc;
import io.github.yezhihao.netmc.core.DefaultHandlerMapping;
import io.github.yezhihao.netmc.endpoint.MyHandlerInterceptor;
import io.github.yezhihao.netmc.codec.MyMessageDecoder;
import io.github.yezhihao.netmc.codec.MyMessageEncoder;
import io.github.yezhihao.netmc.session.SessionManager;
import com.dust.tripartite.netmc.codec.MyMessageDecoder;
import com.dust.tripartite.netmc.codec.MyMessageEncoder;
import com.dust.tripartite.netmc.core.DefaultHandlerMapping;
import com.dust.tripartite.netmc.endpoint.MyHandlerInterceptor;
import com.dust.tripartite.netmc.session.SessionManager;
import java.nio.charset.StandardCharsets;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc;
package com.dust.tripartite.netmc;
import io.netty.buffer.ByteBufUtil;

View File

@ -1,8 +1,8 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.github.yezhihao.netmc.model.MyHeader;
import io.github.yezhihao.netmc.model.MyMessage;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.model.MyHeader;
import com.dust.tripartite.netmc.model.MyMessage;
import com.dust.tripartite.netmc.session.Session;
import io.netty.buffer.ByteBuf;
import java.nio.charset.StandardCharsets;

View File

@ -1,8 +1,8 @@
package io.github.yezhihao.netmc.codec;
package com.dust.tripartite.netmc.codec;
import io.github.yezhihao.netmc.model.MyHeader;
import io.github.yezhihao.netmc.model.MyMessage;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.model.MyHeader;
import com.dust.tripartite.netmc.model.MyMessage;
import com.dust.tripartite.netmc.session.Session;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

View File

@ -0,0 +1,15 @@
package com.dust.tripartite.netmc.endpoint;
import com.dust.tripartite.netmc.core.annotation.Endpoint;
import com.dust.tripartite.netmc.core.annotation.Mapping;
import com.dust.tripartite.netmc.model.MyMessage;
import com.dust.tripartite.netmc.session.Session;
@Endpoint
public class MyEndpoint {
@Mapping(types = 1, desc = "注册")
public void register(MyMessage request, Session session) {
System.out.println(request);
}
}

View File

@ -1,9 +1,9 @@
package io.github.yezhihao.netmc.endpoint;
package com.dust.tripartite.netmc.endpoint;
import io.github.yezhihao.netmc.core.HandlerInterceptor;
import io.github.yezhihao.netmc.model.MyHeader;
import io.github.yezhihao.netmc.model.MyMessage;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.core.HandlerInterceptor;
import com.dust.tripartite.netmc.model.MyHeader;
import com.dust.tripartite.netmc.model.MyMessage;
import com.dust.tripartite.netmc.session.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,4 +1,4 @@
package io.github.yezhihao.netmc.model;
package com.dust.tripartite.netmc.model;
public class MyHeader {

View File

@ -1,7 +1,7 @@
package io.github.yezhihao.netmc.model;
package com.dust.tripartite.netmc.model;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import com.dust.tripartite.netmc.core.model.Message;
import com.dust.tripartite.netmc.session.Session;
public class MyMessage implements Message {

View File

@ -1,15 +0,0 @@
package io.github.yezhihao.netmc.endpoint;
import io.github.yezhihao.netmc.core.annotation.Endpoint;
import io.github.yezhihao.netmc.core.annotation.Mapping;
import io.github.yezhihao.netmc.model.MyMessage;
import io.github.yezhihao.netmc.session.Session;
@Endpoint
public class MyEndpoint {
@Mapping(types = 1, desc = "注册")
public void register(MyMessage request, Session session) {
System.out.println(request);
}
}