Skip to content

Commit 48adb95

Browse files
authored
Merge pull request crossoverJie#163 from crossoverJie/upgrade-pb
Upgrade to protocol3
2 parents d8933c5 + 7928c23 commit 48adb95

File tree

17 files changed

+116
-1730
lines changed

17 files changed

+116
-1730
lines changed

cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/impl/ClientImpl.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.crossoverjie.cim.common.exception.CIMException;
1111
import com.crossoverjie.cim.common.kit.HeartBeatHandler;
1212
import com.crossoverjie.cim.common.pojo.CIMUserInfo;
13-
import com.crossoverjie.cim.common.protocol.CIMRequestProto;
13+
import com.crossoverjie.cim.common.protocol.Request;
1414
import com.crossoverjie.cim.route.api.vo.req.ChatReqVO;
1515
import com.crossoverjie.cim.route.api.vo.req.LoginReqVO;
1616
import com.crossoverjie.cim.route.api.vo.req.P2PReqVO;
@@ -58,7 +58,7 @@ public class ClientImpl extends ClientState implements Client {
5858
@Getter
5959
private static ClientImpl client;
6060
@Getter
61-
private final CIMRequestProto.CIMReqProtocol heartBeatPacket;
61+
private final Request heartBeatPacket;
6262

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

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

82-
heartBeatPacket = CIMRequestProto.CIMReqProtocol.newBuilder()
82+
heartBeatPacket = Request.newBuilder()
8383
.setRequestId(this.conf.getAuth().getUserId())
8484
.setReqMsg("ping")
8585
.setType(Constants.CommandType.PING)
@@ -174,7 +174,7 @@ private void doConnectServer(CIMServerResVO cimServer, CompletableFuture<Boolean
174174
* Send login cmd to server
175175
*/
176176
private void loginServer() {
177-
CIMRequestProto.CIMReqProtocol login = CIMRequestProto.CIMReqProtocol.newBuilder()
177+
Request login = Request.newBuilder()
178178
.setRequestId(this.conf.getAuth().getUserId())
179179
.setReqMsg(this.conf.getAuth().getUserName())
180180
.setType(Constants.CommandType.LOGIN)

cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/CIMClientHandle.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.crossoverjie.cim.client.sdk.ClientState;
44
import com.crossoverjie.cim.client.sdk.impl.ClientImpl;
55
import com.crossoverjie.cim.common.constant.Constants;
6-
import com.crossoverjie.cim.common.protocol.CIMResponseProto;
6+
import com.crossoverjie.cim.common.protocol.Response;
77
import com.crossoverjie.cim.common.util.NettyAttrUtil;
88
import io.netty.channel.ChannelFutureListener;
99
import io.netty.channel.ChannelHandler;
@@ -15,7 +15,7 @@
1515

1616
@ChannelHandler.Sharable
1717
@Slf4j
18-
public class CIMClientHandle extends SimpleChannelInboundHandler<CIMResponseProto.CIMResProtocol> {
18+
public class CIMClientHandle extends SimpleChannelInboundHandler<Response> {
1919

2020
@Override
2121
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
@@ -57,7 +57,7 @@ public void channelInactive(ChannelHandlerContext ctx) {
5757
}
5858

5959
@Override
60-
protected void channelRead0(ChannelHandlerContext ctx, CIMResponseProto.CIMResProtocol msg) {
60+
protected void channelRead0(ChannelHandlerContext ctx, Response msg) {
6161

6262

6363
if (msg.getType() == Constants.CommandType.PING) {

cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/CIMClientHandleInitializer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.crossoverjie.cim.client.sdk.io;
22

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

2121
// google Protobuf
2222
.addLast(new ProtobufVarint32FrameDecoder())
23-
.addLast(new ProtobufDecoder(CIMResponseProto.CIMResProtocol.getDefaultInstance()))
23+
.addLast(new ProtobufDecoder(Response.getDefaultInstance()))
2424
.addLast(new ProtobufVarint32LengthFieldPrepender())
2525
.addLast(new ProtobufEncoder())
2626
.addLast(cimClientHandle)

cim-common/pom.xml

+30
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,34 @@
8787
<artifactId>fastjson</artifactId>
8888
</dependency>
8989
</dependencies>
90+
91+
<build>
92+
<extensions>
93+
<extension>
94+
<groupId>kr.motd.maven</groupId>
95+
<artifactId>os-maven-plugin</artifactId>
96+
<version>1.5.0.Final</version>
97+
</extension>
98+
</extensions>
99+
<plugins>
100+
<plugin>
101+
<groupId>org.xolstice.maven.plugins</groupId>
102+
<artifactId>protobuf-maven-plugin</artifactId>
103+
<version>0.5.1</version>
104+
<configuration>
105+
<protocArtifact>com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}</protocArtifact>
106+
<pluginId>grpc-java</pluginId>
107+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.19.0:exe:${os.detected.classifier}</pluginArtifact>
108+
</configuration>
109+
<executions>
110+
<execution>
111+
<goals>
112+
<goal>compile</goal>
113+
<goal>compile-custom</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
</plugins>
119+
</build>
90120
</project>

0 commit comments

Comments
 (0)