Commit 9a1af32a by yangll

屏蔽掉暂时没有使用的类

1 parent 2ba8f6f2
package cn.com.glsx;
import cn.com.glsx.notify.netty.NettyServer;
import com.glsx.plat.context.EnableRestAdmin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -31,8 +30,8 @@ public class Application {
SpringApplication.run(Application.class, args);
//启动NettyServer服务端
NettyServer nettyServer = new NettyServer();
nettyServer.run();
// NettyServer nettyServer = new NettyServer();
// nettyServer.run();
}
@PostConstruct
......
/*
package cn.com.glsx.notify.modules.controller;
import lombok.EqualsAndHashCode;
......@@ -30,9 +31,11 @@ public class WebSocketServer {
// concurrent包的线程安全Set,用来存放每个客户端对应的Session对象。
private static CopyOnWriteArraySet<Session> SessionSet = new CopyOnWriteArraySet<>();
/**
*/
/**
* 连接建立成功调用的方法
*/
*//*
@OnOpen
public void onOpen(Session session) {
SessionSet.add(session);
......@@ -47,9 +50,11 @@ public class WebSocketServer {
SendMessage(session, "连接成功");
}
/**
*/
/**
* 连接关闭调用的方法
*/
*//*
@OnClose
public void onClose(Session session) {
SessionSet.remove(session);
......@@ -59,35 +64,41 @@ public class WebSocketServer {
log.info("有连接关闭,当前连接数为:{}", cnt);
}
/**
*/
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息
*/
*//*
@OnMessage
public void onMessage(String message, Session session) {
log.info("来自客户端的消息:{}", message);
SendMessage(session, "收到消息,消息内容:" + message);
}
/**
*/
/**
* 出现错误
*
* @param session
* @param error
*/
*//*
@OnError
public void onError(Session session, Throwable error) {
log.error("发生错误:{},Session ID: {}", error.getMessage(), session.getId());
error.printStackTrace();
}
/**
*/
/**
* 发送消息,实践表明,每次浏览器刷新,session会发生变化。
*
* @param session
* @param message
*/
*//*
public static void SendMessage(Session session, String message) {
try {
session.getBasicRemote().sendText(message);
......@@ -97,12 +108,14 @@ public class WebSocketServer {
}
}
/**
*/
/**
* 群发消息
*
* @param message
* @throws IOException
*/
*//*
public static void BroadCastInfo(String message) throws IOException {
for (Session session : SessionSet) {
if (session.isOpen()) {
......@@ -111,13 +124,15 @@ public class WebSocketServer {
}
}
/**
*/
/**
* 指定Session发送消息
*
* @param sessionId
* @param message
* @throws IOException
*/
*//*
public static void SendMessage(String message, String sessionId) throws IOException {
Session session = null;
for (Session s : SessionSet) {
......@@ -137,3 +152,4 @@ public class WebSocketServer {
this.session.getBasicRemote().sendText(message);
}
}
*/
/*
package cn.com.glsx.notify.modules.kafka;
import cn.com.glsx.notify.modules.controller.WebSocketServer;
......@@ -11,9 +12,11 @@ import java.util.Optional;
import static cn.com.glsx.notify.modules.controller.WebSocketServer.SocketSet;
*/
/**
* @author payu
*/
*//*
@Slf4j
@Component
public class MessageConsumer {
......@@ -42,3 +45,4 @@ public class MessageConsumer {
}
}
*/
......@@ -73,7 +73,9 @@ public class MailService {
*/
public void sendAttachmentsMail(String to, String subject, String template, List<Map<String, String>> filepaths, Object... arg) throws Exception {
MessageTemplate mt = messageTemplateMapper.findByTemplate(template);
if (mt == null) return;
if (mt == null) {
return;
}
String content = MessageFormat.format(mt.getContent(), arg);
mailUtils.sendAttachmentMail(to, subject, content, filepaths);
......
......@@ -27,7 +27,9 @@ public class SmsService {
public void sendSms(String phone, String template, Object... arg) {
MessageTemplate mt = messageTemplateMapper.findByTemplate(template);
if (mt == null) return;
if (mt == null) {
return;
}
String content = MessageFormat.format(mt.getContent(), arg);
smsUtils.send(phone, content);
......
/*
package cn.com.glsx.notify.netty;
import io.netty.buffer.ByteBuf;
......@@ -17,4 +18,4 @@ public class MyByteEncoder extends MessageToByteEncoder<byte[]> {
//字节数组
out.writeBytes(bytes);
}
}
\ No newline at end of file
}*/
/*
package cn.com.glsx.notify.netty;
import cn.com.glsx.notify.modules.controller.WebSocketServer;
......@@ -11,21 +12,25 @@ public class NettyDataSvervice {
private static final ReentrantLock Lock = new ReentrantLock();
/**
*/
/**
* 将传送过来的数据进行解析,包括异或运算 (第一次服务器端给客户端发)
*
* @param receiveData
* @return
*/
*//*
public static String sendData(String receiveData) {
final ReentrantLock putLock = Lock;
log.info("接收数据" + receiveData);
putLock.lock();
try {
//此处需要读数据进行校验以及分包黏包处理,本文主要提供思路所以省略
/*
*/
/*
* 处理分包黏包、拆分、解析等
*/
*//*
//数据解析
parseData(receiveData);
try {
......@@ -40,10 +45,13 @@ public class NettyDataSvervice {
}
}
/**
*/
/**
* 数据入库处理
*/
*//*
public static void parseData(String receiveData) {
System.out.println("执行入库操作");
}
}
*/
/*
package cn.com.glsx.notify.netty;
import io.netty.channel.Channel;
......@@ -28,4 +29,4 @@ public class NettyInitializer extends ChannelInitializer {
channel.pipeline().addLast(new MyByteEncoder());
channel.pipeline().addLast(new NettyServerHandler());
}
}
\ No newline at end of file
}*/
/*
package cn.com.glsx.notify.netty;
import cn.com.glsx.notify.netty.utils.NettyByteAndStringUtils;
......@@ -32,3 +33,4 @@ public class NettySendThread implements Runnable {
ctx.writeAndFlush(sendData);
}
}
*/
/*
package cn.com.glsx.notify.netty;
import io.netty.bootstrap.ServerBootstrap;
......@@ -71,4 +72,4 @@ public class NettyServer {
workerGroup.shutdownGracefully();
}
}
}
\ No newline at end of file
}*/
/*
package cn.com.glsx.notify.netty;
import cn.com.glsx.notify.netty.utils.NettyByteAndStringUtils;
......@@ -25,9 +26,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
private static Lock lock_4 = new ReentrantLock();
/**
*/
/**
* 管理一个全局map,保存连接进服务端的通道数量
*/
*//*
private static final ConcurrentHashMap<ChannelId, ChannelHandlerContext> CHANNEL_MAP = new ConcurrentHashMap<>();
@Override //数据读取完毕
......@@ -38,13 +41,15 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
//ctx.writeAndFlush(Unpooled.copiedBuffer("hello, 客户端~(>^ω^<)喵1", CharsetUtil.UTF_8));
}
/**
*/
/**
* 处理异常, 一般是需要关闭通道
*
* @param ctx
* @param cause
* @throws Exception
*/
*//*
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
ctx.close();
......@@ -52,11 +57,13 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
}
/**
*/
/**
* @param ctx
* @DESCRIPTION: 有客户端连接服务器会触发此函数
* @return: void
*/
*//*
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
lock_1.lock();
......@@ -78,11 +85,13 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
}
}
/**
*/
/**
* @param ctx
* @DESCRIPTION: 有客户端终止连接服务器会触发此函数
* @return: void
*/
*//*
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
lock_2.lock();
......@@ -102,12 +111,14 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
}
/**
*/
/**
* 1. ChannelHandlerContext ctx:上下文对象, 含有 管道pipeline , 通道channel, 地址
* 2. Object msg: 就是客户端发送的数据 默认Object
* <p>
* 读取数据实际(这里我们可以读取客户端发送的消息)
*/
*//*
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
lock_3.lock();
......@@ -155,4 +166,4 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
lock_4.unlock();
}
}
}
\ No newline at end of file
}*/
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!