29 changed files with 457 additions and 27 deletions
@ -0,0 +1,28 @@
|
||||
package net.sopod.soim.client.handler.cmd; |
||||
|
||||
import com.google.inject.Inject; |
||||
import com.google.inject.Singleton; |
||||
import net.sopod.soim.client.cmd.handler.NonArgsHandler; |
||||
import net.sopod.soim.client.logger.Logger; |
||||
import net.sopod.soim.client.session.SoImSession; |
||||
|
||||
/** |
||||
* MeHandler |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 15:49 |
||||
*/ |
||||
@Singleton |
||||
public class MeHandler extends NonArgsHandler { |
||||
|
||||
@Inject |
||||
private SoImSession soImSession; |
||||
|
||||
@Override |
||||
public void handle() { |
||||
Long uid = soImSession.getUid(); |
||||
String account = soImSession.getAccount(); |
||||
Logger.info("me: " + uid + "|" + account); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,22 @@
|
||||
package net.sopod.soim.client.protocol; |
||||
|
||||
import io.netty.channel.ChannelHandlerContext; |
||||
import io.netty.channel.SimpleChannelInboundHandler; |
||||
import net.sopod.soim.data.serialize.ImMessage; |
||||
|
||||
/** |
||||
* ImMessageInboundHandler |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 17:51 |
||||
*/ |
||||
public class ImMessageInboundHandler extends SimpleChannelInboundHandler<ImMessage> { |
||||
|
||||
@Override |
||||
protected void channelRead0(ChannelHandlerContext channelHandlerContext, ImMessage imMessage) throws Exception { |
||||
// 请求序列号,complete 对应 CompletableFuture
|
||||
int serialNo = imMessage.getSerialNo(); |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,28 @@
|
||||
package net.sopod.soim.client.protocol; |
||||
|
||||
import io.netty.channel.ChannelHandlerContext; |
||||
import io.netty.channel.ChannelOutboundHandlerAdapter; |
||||
import io.netty.channel.ChannelPromise; |
||||
import net.sopod.soim.data.serialize.ImMessage; |
||||
|
||||
/** |
||||
* ImMessageOutboundHandler |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 17:53 |
||||
*/ |
||||
public class ImMessageOutboundHandler extends ChannelOutboundHandlerAdapter { |
||||
|
||||
@Override |
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { |
||||
if (!(msg instanceof ImMessage)) { |
||||
return; |
||||
} |
||||
ImMessage imMessage = (ImMessage) msg; |
||||
imMessage.setSerialNo(10086); |
||||
// queue.add something..., 调用的地方,通过阻塞方式 FastThreadLocal 获取一个 CompletableFuture
|
||||
|
||||
super.write(ctx, msg, promise); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,10 @@
|
||||
package net.sopod.soim.client.protocol; |
||||
|
||||
/** |
||||
* ImMessageRegistry |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 17:32 |
||||
*/ |
||||
public class ImMessageRegistry { |
||||
} |
||||
@ -0,0 +1,18 @@
|
||||
package net.sopod.soim.client.protocol; |
||||
|
||||
/** |
||||
* MessageQueueHolder |
||||
* 发送一条消息产生一个序列号,在队列中等待响应消息 |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 17:29 |
||||
*/ |
||||
public class MessageQueueHolder { |
||||
|
||||
|
||||
|
||||
public void a() { |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,32 @@
|
||||
package net.sopod.soim.common.dubbo; |
||||
|
||||
import net.sopod.soim.common.dubbo.exception.SoimException; |
||||
import org.apache.dubbo.rpc.Invocation; |
||||
import org.apache.dubbo.rpc.Invoker; |
||||
import org.apache.dubbo.rpc.Result; |
||||
import org.apache.dubbo.rpc.filter.ExceptionFilter; |
||||
import org.apache.dubbo.rpc.service.GenericService; |
||||
|
||||
/** |
||||
* SoimExceptionFilter |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 11:08 |
||||
*/ |
||||
public class SoimExceptionFilter extends ExceptionFilter { |
||||
|
||||
private static final String exceptPack = SoimException.class.getPackageName(); |
||||
|
||||
@Override |
||||
public void onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) { |
||||
if (appResponse.hasException() && GenericService.class != invoker.getInterface()) { |
||||
// 是自定义异常直接返回
|
||||
if (appResponse.getException().getClass().getName() |
||||
.startsWith(exceptPack)) { |
||||
return; |
||||
} |
||||
} |
||||
super.onResponse(appResponse, invoker, invocation); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,33 @@
|
||||
package net.sopod.soim.common.dubbo.exception; |
||||
|
||||
/** |
||||
* DasException |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 12:02 |
||||
*/ |
||||
public class DasException extends SoimException { |
||||
|
||||
private static final long serialVersionUID = -533031075736547194L; |
||||
|
||||
public DasException() { |
||||
super(); |
||||
} |
||||
|
||||
public DasException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public DasException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public DasException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public DasException(String message, Throwable cause, boolean writableStackTrace) { |
||||
super(message, cause, writableStackTrace); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,33 @@
|
||||
package net.sopod.soim.common.dubbo.exception; |
||||
|
||||
/** |
||||
* LogicException |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 12:03 |
||||
*/ |
||||
public class LogicException extends SoimException { |
||||
|
||||
private static final long serialVersionUID = 8123008638375992724L; |
||||
|
||||
public LogicException() { |
||||
super(); |
||||
} |
||||
|
||||
public LogicException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public LogicException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public LogicException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public LogicException(String message, Throwable cause, boolean writableStackTrace) { |
||||
super(message, cause, writableStackTrace); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,34 @@
|
||||
package net.sopod.soim.common.dubbo.exception; |
||||
|
||||
/** |
||||
* 通用服务异常 |
||||
* 默认不生成堆栈信息,设置 writableStackTrace 为 true 则生成堆栈信息 |
||||
* |
||||
* @author 晚星 |
||||
* @date 2019/12/30 16:30 |
||||
*/ |
||||
public class ServiceException extends SoimException { |
||||
|
||||
private static final long serialVersionUID = 6555896535065406344L; |
||||
|
||||
public ServiceException() { |
||||
super(); |
||||
} |
||||
|
||||
public ServiceException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public ServiceException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public ServiceException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public ServiceException(String message, Throwable cause, boolean writableStackTrace) { |
||||
super(message, cause, writableStackTrace); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,39 @@
|
||||
package net.sopod.soim.common.dubbo.exception; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* SoimException |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 11:29 |
||||
*/ |
||||
public class SoimException extends RuntimeException implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 7148131411144540939L; |
||||
|
||||
public SoimException() {} |
||||
|
||||
public SoimException(String message) { |
||||
super(message, null, false, false); |
||||
} |
||||
|
||||
public SoimException(String message, Throwable cause) { |
||||
super(message, cause, false, false); |
||||
} |
||||
|
||||
public SoimException(Throwable cause) { |
||||
super(cause == null ? null : cause.getMessage(), cause, false, false); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param message 错误信息 |
||||
* @param cause 错误对象 |
||||
* @param writableStackTrace 是否启用堆栈追踪 |
||||
*/ |
||||
public SoimException(String message, Throwable cause , boolean writableStackTrace) { |
||||
super(message, cause, false, writableStackTrace); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,11 @@
|
||||
package net.sopod.soim.common.res; |
||||
|
||||
/** |
||||
* R |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 15:31 |
||||
*/ |
||||
public class R { |
||||
|
||||
} |
||||
@ -0,0 +1 @@
|
||||
soimExceptionFilter=net.sopod.soim.common.dubbo.SoimExceptionFilter |
||||
@ -0,0 +1,16 @@
|
||||
package net.sopod.soim.das.user.api.config; |
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.context.annotation.Import; |
||||
|
||||
/** |
||||
* ChatRabbitMQAutoConfiguration |
||||
* |
||||
* @author tmy |
||||
* @date 2022-06-02 10:01 |
||||
*/ |
||||
@ConditionalOnClass(name = "org.springframework.amqp.core.Queue") |
||||
@Import(ChatPersistentRabbitMQConfiguration.class) |
||||
public class ChatMQAutoConfiguration { |
||||
|
||||
} |
||||
@ -1 +1 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=net.sopod.soim.das.user.api.config.ChatRabbitMQAutoConfiguration |
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=net.sopod.soim.das.user.api.config.ChatMQAutoConfiguration |
||||
|
||||
Loading…
Reference in new issue