Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to protocol3 #163

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.crossoverjie.cim.common.exception.CIMException;
import com.crossoverjie.cim.common.kit.HeartBeatHandler;
import com.crossoverjie.cim.common.pojo.CIMUserInfo;
import com.crossoverjie.cim.common.protocol.CIMRequestProto;
import com.crossoverjie.cim.common.protocol.Request;
import com.crossoverjie.cim.route.api.vo.req.ChatReqVO;
import com.crossoverjie.cim.route.api.vo.req.LoginReqVO;
import com.crossoverjie.cim.route.api.vo.req.P2PReqVO;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class ClientImpl extends ClientState implements Client {
@Getter
private static ClientImpl client;
@Getter
private final CIMRequestProto.CIMReqProtocol heartBeatPacket;
private final Request heartBeatPacket;

// Client connected server info
private CIMServerResVO serverInfo;
Expand All @@ -79,7 +79,7 @@ public ClientImpl(ClientConfigurationData conf) {

routeManager = new RouteManager(conf.getRouteUrl(), conf.getOkHttpClient(), conf.getEvent());

heartBeatPacket = CIMRequestProto.CIMReqProtocol.newBuilder()
heartBeatPacket = Request.newBuilder()
.setRequestId(this.conf.getAuth().getUserId())
.setReqMsg("ping")
.setType(Constants.CommandType.PING)
Expand Down Expand Up @@ -174,7 +174,7 @@ private void doConnectServer(CIMServerResVO cimServer, CompletableFuture<Boolean
* Send login cmd to server
*/
private void loginServer() {
CIMRequestProto.CIMReqProtocol login = CIMRequestProto.CIMReqProtocol.newBuilder()
Request login = Request.newBuilder()
.setRequestId(this.conf.getAuth().getUserId())
.setReqMsg(this.conf.getAuth().getUserName())
.setType(Constants.CommandType.LOGIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.crossoverjie.cim.client.sdk.ClientState;
import com.crossoverjie.cim.client.sdk.impl.ClientImpl;
import com.crossoverjie.cim.common.constant.Constants;
import com.crossoverjie.cim.common.protocol.CIMResponseProto;
import com.crossoverjie.cim.common.protocol.Response;
import com.crossoverjie.cim.common.util.NettyAttrUtil;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
Expand All @@ -15,7 +15,7 @@

@ChannelHandler.Sharable
@Slf4j
public class CIMClientHandle extends SimpleChannelInboundHandler<CIMResponseProto.CIMResProtocol> {
public class CIMClientHandle extends SimpleChannelInboundHandler<Response> {

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
Expand Down Expand Up @@ -57,7 +57,7 @@ public void channelInactive(ChannelHandlerContext ctx) {
}

@Override
protected void channelRead0(ChannelHandlerContext ctx, CIMResponseProto.CIMResProtocol msg) {
protected void channelRead0(ChannelHandlerContext ctx, Response msg) {


if (msg.getType() == Constants.CommandType.PING) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.crossoverjie.cim.client.sdk.io;

import com.crossoverjie.cim.common.protocol.CIMResponseProto;
import com.crossoverjie.cim.common.protocol.Response;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
Expand All @@ -20,7 +20,7 @@ protected void initChannel(Channel ch) {

// google Protobuf
.addLast(new ProtobufVarint32FrameDecoder())
.addLast(new ProtobufDecoder(CIMResponseProto.CIMResProtocol.getDefaultInstance()))
.addLast(new ProtobufDecoder(Response.getDefaultInstance()))
.addLast(new ProtobufVarint32LengthFieldPrepender())
.addLast(new ProtobufEncoder())
.addLast(cimClientHandle)
Expand Down
30 changes: 30 additions & 0 deletions cim-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,34 @@
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.19.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading