diff --git a/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/impl/ClientImpl.java b/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/impl/ClientImpl.java index 931405bb..9d4571b5 100644 --- a/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/impl/ClientImpl.java +++ b/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/impl/ClientImpl.java @@ -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; @@ -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; @@ -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) @@ -174,7 +174,7 @@ private void doConnectServer(CIMServerResVO cimServer, CompletableFuture { +public class CIMClientHandle extends SimpleChannelInboundHandler { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { @@ -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) { diff --git a/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/CIMClientHandleInitializer.java b/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/CIMClientHandleInitializer.java index c8ef03ad..fb50e4dc 100644 --- a/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/CIMClientHandleInitializer.java +++ b/cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/io/CIMClientHandleInitializer.java @@ -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; @@ -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) diff --git a/cim-common/pom.xml b/cim-common/pom.xml index b03b38ba..6158616b 100644 --- a/cim-common/pom.xml +++ b/cim-common/pom.xml @@ -87,4 +87,34 @@ fastjson + + + + + kr.motd.maven + os-maven-plugin + 1.5.0.Final + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.1 + + com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:1.19.0:exe:${os.detected.classifier} + + + + + compile + compile-custom + + + + + + \ No newline at end of file diff --git a/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/CIMRequestProto.java b/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/CIMRequestProto.java deleted file mode 100644 index 2b61c77a..00000000 --- a/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/CIMRequestProto.java +++ /dev/null @@ -1,811 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: BaseRequestProto.proto - -package com.crossoverjie.cim.common.protocol; - -public final class CIMRequestProto { - private CIMRequestProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface CIMReqProtocolOrBuilder extends - // @@protoc_insertion_point(interface_extends:protocol.CIMReqProtocol) - com.google.protobuf.MessageOrBuilder { - - /** - * required int64 requestId = 2; - */ - boolean hasRequestId(); - /** - * required int64 requestId = 2; - */ - long getRequestId(); - - /** - * required string reqMsg = 1; - */ - boolean hasReqMsg(); - /** - * required string reqMsg = 1; - */ - String getReqMsg(); - /** - * required string reqMsg = 1; - */ - com.google.protobuf.ByteString - getReqMsgBytes(); - - /** - * required int32 type = 3; - */ - boolean hasType(); - /** - * required int32 type = 3; - */ - int getType(); - } - /** - * Protobuf type {@code protocol.CIMReqProtocol} - */ - public static final class CIMReqProtocol extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:protocol.CIMReqProtocol) - CIMReqProtocolOrBuilder { - private static final long serialVersionUID = 0L; - // Use CIMReqProtocol.newBuilder() to construct. - private CIMReqProtocol(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private CIMReqProtocol() { - requestId_ = 0L; - reqMsg_ = ""; - type_ = 0; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private CIMReqProtocol( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000002; - reqMsg_ = bs; - break; - } - case 16: { - bitField0_ |= 0x00000001; - requestId_ = input.readInt64(); - break; - } - case 24: { - bitField0_ |= 0x00000004; - type_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return CIMRequestProto.internal_static_protocol_CIMReqProtocol_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return CIMRequestProto.internal_static_protocol_CIMReqProtocol_fieldAccessorTable - .ensureFieldAccessorsInitialized( - CIMReqProtocol.class, Builder.class); - } - - private int bitField0_; - public static final int REQUESTID_FIELD_NUMBER = 2; - private long requestId_; - /** - * required int64 requestId = 2; - */ - public boolean hasRequestId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int64 requestId = 2; - */ - public long getRequestId() { - return requestId_; - } - - public static final int REQMSG_FIELD_NUMBER = 1; - private volatile Object reqMsg_; - /** - * required string reqMsg = 1; - */ - public boolean hasReqMsg() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required string reqMsg = 1; - */ - public String getReqMsg() { - Object ref = reqMsg_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - reqMsg_ = s; - } - return s; - } - } - /** - * required string reqMsg = 1; - */ - public com.google.protobuf.ByteString - getReqMsgBytes() { - Object ref = reqMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - reqMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TYPE_FIELD_NUMBER = 3; - private int type_; - /** - * required int32 type = 3; - */ - public boolean hasType() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required int32 type = 3; - */ - public int getType() { - return type_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (!hasRequestId()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasReqMsg()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasType()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, reqMsg_); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt64(2, requestId_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt32(3, type_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, reqMsg_); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, requestId_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, type_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof CIMReqProtocol)) { - return super.equals(obj); - } - CIMReqProtocol other = (CIMReqProtocol) obj; - - boolean result = true; - result = result && (hasRequestId() == other.hasRequestId()); - if (hasRequestId()) { - result = result && (getRequestId() - == other.getRequestId()); - } - result = result && (hasReqMsg() == other.hasReqMsg()); - if (hasReqMsg()) { - result = result && getReqMsg() - .equals(other.getReqMsg()); - } - result = result && (hasType() == other.hasType()); - if (hasType()) { - result = result && (getType() - == other.getType()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasRequestId()) { - hash = (37 * hash) + REQUESTID_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getRequestId()); - } - if (hasReqMsg()) { - hash = (37 * hash) + REQMSG_FIELD_NUMBER; - hash = (53 * hash) + getReqMsg().hashCode(); - } - if (hasType()) { - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + getType(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static CIMReqProtocol parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static CIMReqProtocol parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static CIMReqProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static CIMReqProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static CIMReqProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static CIMReqProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static CIMReqProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static CIMReqProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static CIMReqProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static CIMReqProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static CIMReqProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static CIMReqProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(CIMReqProtocol prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code protocol.CIMReqProtocol} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:protocol.CIMReqProtocol) - CIMReqProtocolOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return CIMRequestProto.internal_static_protocol_CIMReqProtocol_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return CIMRequestProto.internal_static_protocol_CIMReqProtocol_fieldAccessorTable - .ensureFieldAccessorsInitialized( - CIMReqProtocol.class, Builder.class); - } - - // Construct using com.crossoverjie.cim.common.protocol.CIMRequestProto.CIMReqProtocol.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - requestId_ = 0L; - bitField0_ = (bitField0_ & ~0x00000001); - reqMsg_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - type_ = 0; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return CIMRequestProto.internal_static_protocol_CIMReqProtocol_descriptor; - } - - public CIMReqProtocol getDefaultInstanceForType() { - return CIMReqProtocol.getDefaultInstance(); - } - - public CIMReqProtocol build() { - CIMReqProtocol result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public CIMReqProtocol buildPartial() { - CIMReqProtocol result = new CIMReqProtocol(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.requestId_ = requestId_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.reqMsg_ = reqMsg_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.type_ = type_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof CIMReqProtocol) { - return mergeFrom((CIMReqProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(CIMReqProtocol other) { - if (other == CIMReqProtocol.getDefaultInstance()) return this; - if (other.hasRequestId()) { - setRequestId(other.getRequestId()); - } - if (other.hasReqMsg()) { - bitField0_ |= 0x00000002; - reqMsg_ = other.reqMsg_; - onChanged(); - } - if (other.hasType()) { - setType(other.getType()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - if (!hasRequestId()) { - return false; - } - if (!hasReqMsg()) { - return false; - } - if (!hasType()) { - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - CIMReqProtocol parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (CIMReqProtocol) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private long requestId_ ; - /** - * required int64 requestId = 2; - */ - public boolean hasRequestId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int64 requestId = 2; - */ - public long getRequestId() { - return requestId_; - } - /** - * required int64 requestId = 2; - */ - public Builder setRequestId(long value) { - bitField0_ |= 0x00000001; - requestId_ = value; - onChanged(); - return this; - } - /** - * required int64 requestId = 2; - */ - public Builder clearRequestId() { - bitField0_ = (bitField0_ & ~0x00000001); - requestId_ = 0L; - onChanged(); - return this; - } - - private Object reqMsg_ = ""; - /** - * required string reqMsg = 1; - */ - public boolean hasReqMsg() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required string reqMsg = 1; - */ - public String getReqMsg() { - Object ref = reqMsg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - reqMsg_ = s; - } - return s; - } else { - return (String) ref; - } - } - /** - * required string reqMsg = 1; - */ - public com.google.protobuf.ByteString - getReqMsgBytes() { - Object ref = reqMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - reqMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string reqMsg = 1; - */ - public Builder setReqMsg( - String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - reqMsg_ = value; - onChanged(); - return this; - } - /** - * required string reqMsg = 1; - */ - public Builder clearReqMsg() { - bitField0_ = (bitField0_ & ~0x00000002); - reqMsg_ = getDefaultInstance().getReqMsg(); - onChanged(); - return this; - } - /** - * required string reqMsg = 1; - */ - public Builder setReqMsgBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - reqMsg_ = value; - onChanged(); - return this; - } - - private int type_ ; - /** - * required int32 type = 3; - */ - public boolean hasType() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required int32 type = 3; - */ - public int getType() { - return type_; - } - /** - * required int32 type = 3; - */ - public Builder setType(int value) { - bitField0_ |= 0x00000004; - type_ = value; - onChanged(); - return this; - } - /** - * required int32 type = 3; - */ - public Builder clearType() { - bitField0_ = (bitField0_ & ~0x00000004); - type_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:protocol.CIMReqProtocol) - } - - // @@protoc_insertion_point(class_scope:protocol.CIMReqProtocol) - private static final CIMReqProtocol DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new CIMReqProtocol(); - } - - public static CIMReqProtocol getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - @Deprecated public static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CIMReqProtocol parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new CIMReqProtocol(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public CIMReqProtocol getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_protocol_CIMReqProtocol_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_protocol_CIMReqProtocol_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - String[] descriptorData = { - "\n\026BaseRequestProto.proto\022\010protocol\"A\n\016CI" + - "MReqProtocol\022\021\n\trequestId\030\002 \002(\003\022\016\n\006reqMs" + - "g\030\001 \002(\t\022\014\n\004type\030\003 \002(\005B7\n$com.crossoverji" + - "e.cim.common.protocolB\017CIMRequestProto" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_protocol_CIMReqProtocol_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_protocol_CIMReqProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_protocol_CIMReqProtocol_descriptor, - new String[] { "RequestId", "ReqMsg", "Type", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/CIMResponseProto.java b/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/CIMResponseProto.java deleted file mode 100644 index 31bb4668..00000000 --- a/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/CIMResponseProto.java +++ /dev/null @@ -1,812 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: BaseResponseProto.proto - -package com.crossoverjie.cim.common.protocol; - -public final class CIMResponseProto { - private CIMResponseProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface CIMResProtocolOrBuilder extends - // @@protoc_insertion_point(interface_extends:protocol.CIMResProtocol) - com.google.protobuf.MessageOrBuilder { - - /** - * required int64 responseId = 2; - */ - boolean hasResponseId(); - /** - * required int64 responseId = 2; - */ - long getResponseId(); - - /** - * required string resMsg = 1; - */ - boolean hasResMsg(); - /** - * required string resMsg = 1; - */ - String getResMsg(); - /** - * required string resMsg = 1; - */ - com.google.protobuf.ByteString - getResMsgBytes(); - - /** - * required int32 type = 3; - */ - boolean hasType(); - /** - * required int32 type = 3; - */ - int getType(); - } - /** - * Protobuf type {@code protocol.CIMResProtocol} - */ - public static final class CIMResProtocol extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:protocol.CIMResProtocol) - CIMResProtocolOrBuilder { - private static final long serialVersionUID = 0L; - // Use CIMResProtocol.newBuilder() to construct. - private CIMResProtocol(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private CIMResProtocol() { - responseId_ = 0L; - resMsg_ = ""; - type_ = 0; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private CIMResProtocol( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000002; - resMsg_ = bs; - break; - } - case 16: { - bitField0_ |= 0x00000001; - responseId_ = input.readInt64(); - break; - } - case 24: { - bitField0_ |= 0x00000004; - type_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return CIMResponseProto.internal_static_protocol_CIMResProtocol_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return CIMResponseProto.internal_static_protocol_CIMResProtocol_fieldAccessorTable - .ensureFieldAccessorsInitialized( - CIMResProtocol.class, Builder.class); - } - - private int bitField0_; - public static final int RESPONSEID_FIELD_NUMBER = 2; - private long responseId_; - /** - * required int64 responseId = 2; - */ - public boolean hasResponseId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int64 responseId = 2; - */ - public long getResponseId() { - return responseId_; - } - - public static final int RESMSG_FIELD_NUMBER = 1; - private volatile Object resMsg_; - /** - * required string resMsg = 1; - */ - public boolean hasResMsg() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required string resMsg = 1; - */ - public String getResMsg() { - Object ref = resMsg_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - resMsg_ = s; - } - return s; - } - } - /** - * required string resMsg = 1; - */ - public com.google.protobuf.ByteString - getResMsgBytes() { - Object ref = resMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - resMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TYPE_FIELD_NUMBER = 3; - private int type_; - /** - * required int32 type = 3; - */ - public boolean hasType() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required int32 type = 3; - */ - public int getType() { - return type_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (!hasResponseId()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasResMsg()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasType()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, resMsg_); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt64(2, responseId_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt32(3, type_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, resMsg_); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, responseId_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, type_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof CIMResProtocol)) { - return super.equals(obj); - } - CIMResProtocol other = (CIMResProtocol) obj; - - boolean result = true; - result = result && (hasResponseId() == other.hasResponseId()); - if (hasResponseId()) { - result = result && (getResponseId() - == other.getResponseId()); - } - result = result && (hasResMsg() == other.hasResMsg()); - if (hasResMsg()) { - result = result && getResMsg() - .equals(other.getResMsg()); - } - result = result && (hasType() == other.hasType()); - if (hasType()) { - result = result && (getType() - == other.getType()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasResponseId()) { - hash = (37 * hash) + RESPONSEID_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getResponseId()); - } - if (hasResMsg()) { - hash = (37 * hash) + RESMSG_FIELD_NUMBER; - hash = (53 * hash) + getResMsg().hashCode(); - } - if (hasType()) { - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + getType(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static CIMResProtocol parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static CIMResProtocol parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static CIMResProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static CIMResProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static CIMResProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static CIMResProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static CIMResProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static CIMResProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static CIMResProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static CIMResProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static CIMResProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static CIMResProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(CIMResProtocol prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code protocol.CIMResProtocol} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:protocol.CIMResProtocol) - CIMResProtocolOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return CIMResponseProto.internal_static_protocol_CIMResProtocol_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return CIMResponseProto.internal_static_protocol_CIMResProtocol_fieldAccessorTable - .ensureFieldAccessorsInitialized( - CIMResProtocol.class, Builder.class); - } - - // Construct using com.crossoverjie.cim.common.protocol.CIMResponseProto.CIMResProtocol.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - responseId_ = 0L; - bitField0_ = (bitField0_ & ~0x00000001); - resMsg_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - type_ = 0; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return CIMResponseProto.internal_static_protocol_CIMResProtocol_descriptor; - } - - public CIMResProtocol getDefaultInstanceForType() { - return CIMResProtocol.getDefaultInstance(); - } - - public CIMResProtocol build() { - CIMResProtocol result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public CIMResProtocol buildPartial() { - CIMResProtocol result = new CIMResProtocol(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.responseId_ = responseId_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.resMsg_ = resMsg_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.type_ = type_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof CIMResProtocol) { - return mergeFrom((CIMResProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(CIMResProtocol other) { - if (other == CIMResProtocol.getDefaultInstance()) return this; - if (other.hasResponseId()) { - setResponseId(other.getResponseId()); - } - if (other.hasResMsg()) { - bitField0_ |= 0x00000002; - resMsg_ = other.resMsg_; - onChanged(); - } - if (other.hasType()) { - setType(other.getType()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - if (!hasResponseId()) { - return false; - } - if (!hasResMsg()) { - return false; - } - if (!hasType()) { - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - CIMResProtocol parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (CIMResProtocol) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private long responseId_ ; - /** - * required int64 responseId = 2; - */ - public boolean hasResponseId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int64 responseId = 2; - */ - public long getResponseId() { - return responseId_; - } - /** - * required int64 responseId = 2; - */ - public Builder setResponseId(long value) { - bitField0_ |= 0x00000001; - responseId_ = value; - onChanged(); - return this; - } - /** - * required int64 responseId = 2; - */ - public Builder clearResponseId() { - bitField0_ = (bitField0_ & ~0x00000001); - responseId_ = 0L; - onChanged(); - return this; - } - - private Object resMsg_ = ""; - /** - * required string resMsg = 1; - */ - public boolean hasResMsg() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required string resMsg = 1; - */ - public String getResMsg() { - Object ref = resMsg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - resMsg_ = s; - } - return s; - } else { - return (String) ref; - } - } - /** - * required string resMsg = 1; - */ - public com.google.protobuf.ByteString - getResMsgBytes() { - Object ref = resMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - resMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string resMsg = 1; - */ - public Builder setResMsg( - String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - resMsg_ = value; - onChanged(); - return this; - } - /** - * required string resMsg = 1; - */ - public Builder clearResMsg() { - bitField0_ = (bitField0_ & ~0x00000002); - resMsg_ = getDefaultInstance().getResMsg(); - onChanged(); - return this; - } - /** - * required string resMsg = 1; - */ - public Builder setResMsgBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - resMsg_ = value; - onChanged(); - return this; - } - - private int type_ ; - /** - * required int32 type = 3; - */ - public boolean hasType() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required int32 type = 3; - */ - public int getType() { - return type_; - } - /** - * required int32 type = 3; - */ - public Builder setType(int value) { - bitField0_ |= 0x00000004; - type_ = value; - onChanged(); - return this; - } - /** - * required int32 type = 3; - */ - public Builder clearType() { - bitField0_ = (bitField0_ & ~0x00000004); - type_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:protocol.CIMResProtocol) - } - - // @@protoc_insertion_point(class_scope:protocol.CIMResProtocol) - private static final CIMResProtocol DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new CIMResProtocol(); - } - - public static CIMResProtocol getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - @Deprecated public static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CIMResProtocol parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new CIMResProtocol(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public CIMResProtocol getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_protocol_CIMResProtocol_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_protocol_CIMResProtocol_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - String[] descriptorData = { - "\n\027BaseResponseProto.proto\022\010protocol\"B\n\016C" + - "IMResProtocol\022\022\n\nresponseId\030\002 \002(\003\022\016\n\006res" + - "Msg\030\001 \002(\t\022\014\n\004type\030\003 \002(\005B8\n$com.crossover" + - "jie.cim.common.protocolB\020CIMResponseProt" + - "o" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_protocol_CIMResProtocol_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_protocol_CIMResProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_protocol_CIMResProtocol_descriptor, - new String[] { "ResponseId", "ResMsg", "Type", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/ProtocolUtil.java b/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/ProtocolUtil.java deleted file mode 100644 index 7e811a92..00000000 --- a/cim-common/src/main/java/com/crossoverjie/cim/common/protocol/ProtocolUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.crossoverjie.cim.common.protocol; - -import com.google.protobuf.InvalidProtocolBufferException; - -/** - * Function: - * - * @author crossoverJie - * Date: 2018/8/1 12:24 - * @since JDK 1.8 - */ -public class ProtocolUtil { - - public static void main(String[] args) throws InvalidProtocolBufferException { - CIMRequestProto.CIMReqProtocol protocol = CIMRequestProto.CIMReqProtocol.newBuilder() - .setRequestId(123L) - .setReqMsg("你好啊") - .build(); - - byte[] encode = encode(protocol); - - CIMRequestProto.CIMReqProtocol parseFrom = decode(encode); - - System.out.println(protocol.toString()); - System.out.println(protocol.toString().equals(parseFrom.toString())); - } - - /** - * 编码 - * @param protocol - * @return - */ - public static byte[] encode(CIMRequestProto.CIMReqProtocol protocol){ - return protocol.toByteArray() ; - } - - /** - * 解码 - * @param bytes - * @return - * @throws InvalidProtocolBufferException - */ - public static CIMRequestProto.CIMReqProtocol decode(byte[] bytes) throws InvalidProtocolBufferException { - return CIMRequestProto.CIMReqProtocol.parseFrom(bytes); - } -} diff --git a/cim-common/src/main/proto/cim.proto b/cim-common/src/main/proto/cim.proto new file mode 100644 index 00000000..7b229cd2 --- /dev/null +++ b/cim-common/src/main/proto/cim.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package com.crossoverjie.cim.common.protocol; +option java_package = "com.crossoverjie.cim.common.protocol"; +option java_multiple_files = true; + +message Request{ + // todo source user info + int64 requestId = 2; + string reqMsg = 1; + int32 type = 3; +} + +message Response{ + int64 responseId = 2; + string resMsg = 1; + int32 type = 3; +} \ No newline at end of file diff --git a/cim-common/src/test/java/com/crossoverjie/cim/common/util/ProtocolTest.java b/cim-common/src/test/java/com/crossoverjie/cim/common/util/ProtocolTest.java new file mode 100644 index 00000000..5f87c01f --- /dev/null +++ b/cim-common/src/test/java/com/crossoverjie/cim/common/util/ProtocolTest.java @@ -0,0 +1,43 @@ +package com.crossoverjie.cim.common.util; + +import com.crossoverjie.cim.common.protocol.Request; +import com.google.protobuf.InvalidProtocolBufferException; +import org.junit.Test; + +public class ProtocolTest { + + @Test + public void testProtocol() throws InvalidProtocolBufferException { + Request protocol = Request.newBuilder() + .setRequestId(123L) + .setReqMsg("你好啊") + .setType(1) + .build(); + + byte[] encode = encode(protocol); + + Request parseFrom = decode(encode); + + System.out.println(protocol); + System.out.println(protocol.toString().equals(parseFrom.toString())); + } + + /** + * 编码 + * @param protocol + * @return + */ + public static byte[] encode(Request protocol){ + return protocol.toByteArray() ; + } + + /** + * 解码 + * @param bytes + * @return + * @throws InvalidProtocolBufferException + */ + public static Request decode(byte[] bytes) throws InvalidProtocolBufferException { + return Request.parseFrom(bytes); + } +} diff --git a/cim-server/src/main/java/com/crossoverjie/cim/server/CIMServerApplication.java b/cim-server/src/main/java/com/crossoverjie/cim/server/CIMServerApplication.java index df3c1143..a5f99505 100644 --- a/cim-server/src/main/java/com/crossoverjie/cim/server/CIMServerApplication.java +++ b/cim-server/src/main/java/com/crossoverjie/cim/server/CIMServerApplication.java @@ -2,7 +2,7 @@ import com.crossoverjie.cim.common.metastore.MetaStore; import com.crossoverjie.cim.server.config.AppConfiguration; -import com.crossoverjie.cim.server.kit.RegistryZK; +import com.crossoverjie.cim.server.kit.RegistryMetaStore; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -37,7 +37,7 @@ public static void main(String[] args) { @Override public void run(String... args) throws Exception { String addr = InetAddress.getLocalHost().getHostAddress(); - Thread thread = new Thread(new RegistryZK(metaStore, addr, appConfiguration.getCimServerPort(),httpPort)); + Thread thread = new Thread(new RegistryMetaStore(metaStore, addr, appConfiguration.getCimServerPort(),httpPort)); thread.setName("registry-zk"); thread.start() ; } diff --git a/cim-server/src/main/java/com/crossoverjie/cim/server/config/BeanConfig.java b/cim-server/src/main/java/com/crossoverjie/cim/server/config/BeanConfig.java index 63eedbf2..0acec955 100644 --- a/cim-server/src/main/java/com/crossoverjie/cim/server/config/BeanConfig.java +++ b/cim-server/src/main/java/com/crossoverjie/cim/server/config/BeanConfig.java @@ -3,20 +3,15 @@ import com.crossoverjie.cim.common.constant.Constants; import com.crossoverjie.cim.common.core.proxy.RpcProxyManager; import com.crossoverjie.cim.common.metastore.MetaStore; -import com.crossoverjie.cim.common.metastore.ZkConfiguration; import com.crossoverjie.cim.common.metastore.ZkMetaStoreImpl; -import com.crossoverjie.cim.common.protocol.CIMRequestProto; +import com.crossoverjie.cim.common.protocol.Request; import com.crossoverjie.cim.route.api.RouteApi; import jakarta.annotation.Resource; +import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; -import org.I0Itec.zkclient.ZkClient; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.concurrent.TimeUnit; - /** * Function: * @@ -45,7 +40,7 @@ public OkHttpClient okHttpClient() { } @Bean - public MetaStore metaStore() throws Exception { + public MetaStore metaStore() { return new ZkMetaStoreImpl(); } @@ -55,13 +50,12 @@ public MetaStore metaStore() throws Exception { * @return */ @Bean(value = "heartBeat") - public CIMRequestProto.CIMReqProtocol heartBeat() { - CIMRequestProto.CIMReqProtocol heart = CIMRequestProto.CIMReqProtocol.newBuilder() + public Request heartBeat() { + return Request.newBuilder() .setRequestId(0L) .setReqMsg("pong") .setType(Constants.CommandType.PING) .build(); - return heart; } @Bean diff --git a/cim-server/src/main/java/com/crossoverjie/cim/server/handle/CIMServerHandle.java b/cim-server/src/main/java/com/crossoverjie/cim/server/handle/CIMServerHandle.java index 0b01708e..f8896e9c 100644 --- a/cim-server/src/main/java/com/crossoverjie/cim/server/handle/CIMServerHandle.java +++ b/cim-server/src/main/java/com/crossoverjie/cim/server/handle/CIMServerHandle.java @@ -4,7 +4,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.common.util.NettyAttrUtil; import com.crossoverjie.cim.server.kit.RouteHandler; import com.crossoverjie.cim.server.kit.ServerHeartBeatHandlerImpl; @@ -28,7 +28,7 @@ */ @ChannelHandler.Sharable @Slf4j -public class CIMServerHandle extends SimpleChannelInboundHandler { +public class CIMServerHandle extends SimpleChannelInboundHandler { @@ -71,7 +71,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc @Override - protected void channelRead0(ChannelHandlerContext ctx, CIMRequestProto.CIMReqProtocol msg) throws Exception { + protected void channelRead0(ChannelHandlerContext ctx, Request msg) throws Exception { log.info("received msg=[{}]", msg.toString()); if (msg.getType() == Constants.CommandType.LOGIN) { @@ -85,8 +85,7 @@ protected void channelRead0(ChannelHandlerContext ctx, CIMRequestProto.CIMReqPro if (msg.getType() == Constants.CommandType.PING){ NettyAttrUtil.updateReaderTime(ctx.channel(),System.currentTimeMillis()); //向客户端响应 pong 消息 - CIMRequestProto.CIMReqProtocol heartBeat = SpringBeanFactory.getBean("heartBeat", - CIMRequestProto.CIMReqProtocol.class); + Request heartBeat = SpringBeanFactory.getBean("heartBeat", Request.class); ctx.writeAndFlush(heartBeat).addListeners((ChannelFutureListener) future -> { if (!future.isSuccess()) { log.error("IO error,close Channel"); diff --git a/cim-server/src/main/java/com/crossoverjie/cim/server/init/CIMServerInitializer.java b/cim-server/src/main/java/com/crossoverjie/cim/server/init/CIMServerInitializer.java index 0ca8d7f1..1d2aacfa 100644 --- a/cim-server/src/main/java/com/crossoverjie/cim/server/init/CIMServerInitializer.java +++ b/cim-server/src/main/java/com/crossoverjie/cim/server/init/CIMServerInitializer.java @@ -1,6 +1,6 @@ package com.crossoverjie.cim.server.init; -import com.crossoverjie.cim.common.protocol.CIMRequestProto; +import com.crossoverjie.cim.common.protocol.Request; import com.crossoverjie.cim.server.handle.CIMServerHandle; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; @@ -29,7 +29,7 @@ protected void initChannel(Channel ch) throws Exception { .addLast(new IdleStateHandler(11, 0, 0)) // google Protobuf 编解码 .addLast(new ProtobufVarint32FrameDecoder()) - .addLast(new ProtobufDecoder(CIMRequestProto.CIMReqProtocol.getDefaultInstance())) + .addLast(new ProtobufDecoder(Request.getDefaultInstance())) .addLast(new ProtobufVarint32LengthFieldPrepender()) .addLast(new ProtobufEncoder()) .addLast(cimServerHandle); diff --git a/cim-server/src/main/java/com/crossoverjie/cim/server/kit/RegistryZK.java b/cim-server/src/main/java/com/crossoverjie/cim/server/kit/RegistryMetaStore.java similarity index 90% rename from cim-server/src/main/java/com/crossoverjie/cim/server/kit/RegistryZK.java rename to cim-server/src/main/java/com/crossoverjie/cim/server/kit/RegistryMetaStore.java index 72d173bc..60b8825b 100644 --- a/cim-server/src/main/java/com/crossoverjie/cim/server/kit/RegistryZK.java +++ b/cim-server/src/main/java/com/crossoverjie/cim/server/kit/RegistryMetaStore.java @@ -17,7 +17,7 @@ * @since JDK 1.8 */ @Slf4j -public class RegistryZK implements Runnable { +public class RegistryMetaStore implements Runnable { private MetaStore metaStore; @@ -27,7 +27,7 @@ public class RegistryZK implements Runnable { private String ip; private int cimServerPort; private int httpPort; - public RegistryZK(MetaStore metaStore, String ip, int cimServerPort,int httpPort) { + public RegistryMetaStore(MetaStore metaStore, String ip, int cimServerPort, int httpPort) { this.ip = ip; this.cimServerPort = cimServerPort; this.httpPort = httpPort ; diff --git a/cim-server/src/main/java/com/crossoverjie/cim/server/server/CIMServer.java b/cim-server/src/main/java/com/crossoverjie/cim/server/server/CIMServer.java index f823dac7..6ea5848a 100644 --- a/cim-server/src/main/java/com/crossoverjie/cim/server/server/CIMServer.java +++ b/cim-server/src/main/java/com/crossoverjie/cim/server/server/CIMServer.java @@ -1,7 +1,7 @@ package com.crossoverjie.cim.server.server; import com.crossoverjie.cim.common.constant.Constants; -import com.crossoverjie.cim.common.protocol.CIMRequestProto; +import com.crossoverjie.cim.common.protocol.Request; import com.crossoverjie.cim.server.api.vo.req.SendMsgReqVO; import com.crossoverjie.cim.server.init.CIMServerInitializer; import com.crossoverjie.cim.server.util.SessionSocketHolder; @@ -86,7 +86,7 @@ public void sendMsg(SendMsgReqVO sendMsgReqVO){ log.error("client {} offline!", sendMsgReqVO.getUserId()); return; } - CIMRequestProto.CIMReqProtocol protocol = CIMRequestProto.CIMReqProtocol.newBuilder() + Request protocol = Request.newBuilder() .setRequestId(sendMsgReqVO.getUserId()) .setReqMsg(sendMsgReqVO.getMsg()) .setType(Constants.CommandType.MSG) diff --git a/protocol/BaseRequestProto.proto b/protocol/BaseRequestProto.proto deleted file mode 100644 index 56e1a568..00000000 --- a/protocol/BaseRequestProto.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto2"; - -package protocol; - -option java_package = "com.crossoverjie.cim.common.protocol"; -option java_outer_classname = "CIMRequestProto"; - -message CIMReqProtocol { - // todo source user info - required int64 requestId = 2; - required string reqMsg = 1; - required int32 type = 3; - -} - diff --git a/protocol/BaseResponseProto.proto b/protocol/BaseResponseProto.proto deleted file mode 100644 index b9bc6d16..00000000 --- a/protocol/BaseResponseProto.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto2"; - -package protocol; - -option java_package = "com.crossoverjie.cim.common.protocol"; -option java_outer_classname = "CIMResponseProto"; - -message CIMResProtocol { - required int64 responseId = 2; - required string resMsg = 1; - required int32 type = 3; - -}