作者 crossoverJie
提交者 GitHub

Merge pull request #2 from crossoverJie/dev-1.0.1

Google Protocol
正在显示 17 个修改的文件 包含 2444 行增加32 行删除
@@ -14,6 +14,11 @@ @@ -14,6 +14,11 @@
14 14
15 <dependencies> 15 <dependencies>
16 <dependency> 16 <dependency>
  17 + <groupId>com.google.protobuf</groupId>
  18 + <artifactId>protobuf-java</artifactId>
  19 + </dependency>
  20 +
  21 + <dependency>
17 <groupId>io.springfox</groupId> 22 <groupId>io.springfox</groupId>
18 <artifactId>springfox-swagger2</artifactId> 23 <artifactId>springfox-swagger2</artifactId>
19 <scope>compile</scope> 24 <scope>compile</scope>
  1 +// Generated by the protocol buffer compiler. DO NOT EDIT!
  2 +// source: BaseProtoc.proto
  3 +
  4 +package com.crossoverjie.netty.action.common.protocol;
  5 +
  6 +public final class BaseProto {
  7 + private BaseProto() {}
  8 + public static void registerAllExtensions(
  9 + com.google.protobuf.ExtensionRegistryLite registry) {
  10 + }
  11 +
  12 + public static void registerAllExtensions(
  13 + com.google.protobuf.ExtensionRegistry registry) {
  14 + registerAllExtensions(
  15 + (com.google.protobuf.ExtensionRegistryLite) registry);
  16 + }
  17 + public interface ProtocolOrBuilder extends
  18 + // @@protoc_insertion_point(interface_extends:protocol.Protocol)
  19 + com.google.protobuf.MessageOrBuilder {
  20 +
  21 + /**
  22 + * <code>required int32 header = 2;</code>
  23 + */
  24 + boolean hasHeader();
  25 + /**
  26 + * <code>required int32 header = 2;</code>
  27 + */
  28 + int getHeader();
  29 +
  30 + /**
  31 + * <code>required string msg = 1;</code>
  32 + */
  33 + boolean hasMsg();
  34 + /**
  35 + * <code>required string msg = 1;</code>
  36 + */
  37 + String getMsg();
  38 + /**
  39 + * <code>required string msg = 1;</code>
  40 + */
  41 + com.google.protobuf.ByteString
  42 + getMsgBytes();
  43 + }
  44 + /**
  45 + * Protobuf type {@code protocol.Protocol}
  46 + */
  47 + public static final class Protocol extends
  48 + com.google.protobuf.GeneratedMessageV3 implements
  49 + // @@protoc_insertion_point(message_implements:protocol.Protocol)
  50 + ProtocolOrBuilder {
  51 + private static final long serialVersionUID = 0L;
  52 + // Use Protocol.newBuilder() to construct.
  53 + private Protocol(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
  54 + super(builder);
  55 + }
  56 + private Protocol() {
  57 + header_ = 0;
  58 + msg_ = "";
  59 + }
  60 +
  61 + @Override
  62 + public final com.google.protobuf.UnknownFieldSet
  63 + getUnknownFields() {
  64 + return this.unknownFields;
  65 + }
  66 + private Protocol(
  67 + com.google.protobuf.CodedInputStream input,
  68 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  69 + throws com.google.protobuf.InvalidProtocolBufferException {
  70 + this();
  71 + if (extensionRegistry == null) {
  72 + throw new NullPointerException();
  73 + }
  74 + int mutable_bitField0_ = 0;
  75 + com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  76 + com.google.protobuf.UnknownFieldSet.newBuilder();
  77 + try {
  78 + boolean done = false;
  79 + while (!done) {
  80 + int tag = input.readTag();
  81 + switch (tag) {
  82 + case 0:
  83 + done = true;
  84 + break;
  85 + default: {
  86 + if (!parseUnknownField(
  87 + input, unknownFields, extensionRegistry, tag)) {
  88 + done = true;
  89 + }
  90 + break;
  91 + }
  92 + case 10: {
  93 + com.google.protobuf.ByteString bs = input.readBytes();
  94 + bitField0_ |= 0x00000002;
  95 + msg_ = bs;
  96 + break;
  97 + }
  98 + case 16: {
  99 + bitField0_ |= 0x00000001;
  100 + header_ = input.readInt32();
  101 + break;
  102 + }
  103 + }
  104 + }
  105 + } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  106 + throw e.setUnfinishedMessage(this);
  107 + } catch (java.io.IOException e) {
  108 + throw new com.google.protobuf.InvalidProtocolBufferException(
  109 + e).setUnfinishedMessage(this);
  110 + } finally {
  111 + this.unknownFields = unknownFields.build();
  112 + makeExtensionsImmutable();
  113 + }
  114 + }
  115 + public static final com.google.protobuf.Descriptors.Descriptor
  116 + getDescriptor() {
  117 + return BaseProto.internal_static_protocol_Protocol_descriptor;
  118 + }
  119 +
  120 + protected FieldAccessorTable
  121 + internalGetFieldAccessorTable() {
  122 + return BaseProto.internal_static_protocol_Protocol_fieldAccessorTable
  123 + .ensureFieldAccessorsInitialized(
  124 + Protocol.class, Builder.class);
  125 + }
  126 +
  127 + private int bitField0_;
  128 + public static final int HEADER_FIELD_NUMBER = 2;
  129 + private int header_;
  130 + /**
  131 + * <code>required int32 header = 2;</code>
  132 + */
  133 + public boolean hasHeader() {
  134 + return ((bitField0_ & 0x00000001) == 0x00000001);
  135 + }
  136 + /**
  137 + * <code>required int32 header = 2;</code>
  138 + */
  139 + public int getHeader() {
  140 + return header_;
  141 + }
  142 +
  143 + public static final int MSG_FIELD_NUMBER = 1;
  144 + private volatile Object msg_;
  145 + /**
  146 + * <code>required string msg = 1;</code>
  147 + */
  148 + public boolean hasMsg() {
  149 + return ((bitField0_ & 0x00000002) == 0x00000002);
  150 + }
  151 + /**
  152 + * <code>required string msg = 1;</code>
  153 + */
  154 + public String getMsg() {
  155 + Object ref = msg_;
  156 + if (ref instanceof String) {
  157 + return (String) ref;
  158 + } else {
  159 + com.google.protobuf.ByteString bs =
  160 + (com.google.protobuf.ByteString) ref;
  161 + String s = bs.toStringUtf8();
  162 + if (bs.isValidUtf8()) {
  163 + msg_ = s;
  164 + }
  165 + return s;
  166 + }
  167 + }
  168 + /**
  169 + * <code>required string msg = 1;</code>
  170 + */
  171 + public com.google.protobuf.ByteString
  172 + getMsgBytes() {
  173 + Object ref = msg_;
  174 + if (ref instanceof String) {
  175 + com.google.protobuf.ByteString b =
  176 + com.google.protobuf.ByteString.copyFromUtf8(
  177 + (String) ref);
  178 + msg_ = b;
  179 + return b;
  180 + } else {
  181 + return (com.google.protobuf.ByteString) ref;
  182 + }
  183 + }
  184 +
  185 + private byte memoizedIsInitialized = -1;
  186 + public final boolean isInitialized() {
  187 + byte isInitialized = memoizedIsInitialized;
  188 + if (isInitialized == 1) return true;
  189 + if (isInitialized == 0) return false;
  190 +
  191 + if (!hasHeader()) {
  192 + memoizedIsInitialized = 0;
  193 + return false;
  194 + }
  195 + if (!hasMsg()) {
  196 + memoizedIsInitialized = 0;
  197 + return false;
  198 + }
  199 + memoizedIsInitialized = 1;
  200 + return true;
  201 + }
  202 +
  203 + public void writeTo(com.google.protobuf.CodedOutputStream output)
  204 + throws java.io.IOException {
  205 + if (((bitField0_ & 0x00000002) == 0x00000002)) {
  206 + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, msg_);
  207 + }
  208 + if (((bitField0_ & 0x00000001) == 0x00000001)) {
  209 + output.writeInt32(2, header_);
  210 + }
  211 + unknownFields.writeTo(output);
  212 + }
  213 +
  214 + public int getSerializedSize() {
  215 + int size = memoizedSize;
  216 + if (size != -1) return size;
  217 +
  218 + size = 0;
  219 + if (((bitField0_ & 0x00000002) == 0x00000002)) {
  220 + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, msg_);
  221 + }
  222 + if (((bitField0_ & 0x00000001) == 0x00000001)) {
  223 + size += com.google.protobuf.CodedOutputStream
  224 + .computeInt32Size(2, header_);
  225 + }
  226 + size += unknownFields.getSerializedSize();
  227 + memoizedSize = size;
  228 + return size;
  229 + }
  230 +
  231 + @Override
  232 + public boolean equals(final Object obj) {
  233 + if (obj == this) {
  234 + return true;
  235 + }
  236 + if (!(obj instanceof Protocol)) {
  237 + return super.equals(obj);
  238 + }
  239 + Protocol other = (Protocol) obj;
  240 +
  241 + boolean result = true;
  242 + result = result && (hasHeader() == other.hasHeader());
  243 + if (hasHeader()) {
  244 + result = result && (getHeader()
  245 + == other.getHeader());
  246 + }
  247 + result = result && (hasMsg() == other.hasMsg());
  248 + if (hasMsg()) {
  249 + result = result && getMsg()
  250 + .equals(other.getMsg());
  251 + }
  252 + result = result && unknownFields.equals(other.unknownFields);
  253 + return result;
  254 + }
  255 +
  256 + @Override
  257 + public int hashCode() {
  258 + if (memoizedHashCode != 0) {
  259 + return memoizedHashCode;
  260 + }
  261 + int hash = 41;
  262 + hash = (19 * hash) + getDescriptor().hashCode();
  263 + if (hasHeader()) {
  264 + hash = (37 * hash) + HEADER_FIELD_NUMBER;
  265 + hash = (53 * hash) + getHeader();
  266 + }
  267 + if (hasMsg()) {
  268 + hash = (37 * hash) + MSG_FIELD_NUMBER;
  269 + hash = (53 * hash) + getMsg().hashCode();
  270 + }
  271 + hash = (29 * hash) + unknownFields.hashCode();
  272 + memoizedHashCode = hash;
  273 + return hash;
  274 + }
  275 +
  276 + public static Protocol parseFrom(
  277 + java.nio.ByteBuffer data)
  278 + throws com.google.protobuf.InvalidProtocolBufferException {
  279 + return PARSER.parseFrom(data);
  280 + }
  281 + public static Protocol parseFrom(
  282 + java.nio.ByteBuffer data,
  283 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  284 + throws com.google.protobuf.InvalidProtocolBufferException {
  285 + return PARSER.parseFrom(data, extensionRegistry);
  286 + }
  287 + public static Protocol parseFrom(
  288 + com.google.protobuf.ByteString data)
  289 + throws com.google.protobuf.InvalidProtocolBufferException {
  290 + return PARSER.parseFrom(data);
  291 + }
  292 + public static Protocol parseFrom(
  293 + com.google.protobuf.ByteString data,
  294 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  295 + throws com.google.protobuf.InvalidProtocolBufferException {
  296 + return PARSER.parseFrom(data, extensionRegistry);
  297 + }
  298 + public static Protocol parseFrom(byte[] data)
  299 + throws com.google.protobuf.InvalidProtocolBufferException {
  300 + return PARSER.parseFrom(data);
  301 + }
  302 + public static Protocol parseFrom(
  303 + byte[] data,
  304 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  305 + throws com.google.protobuf.InvalidProtocolBufferException {
  306 + return PARSER.parseFrom(data, extensionRegistry);
  307 + }
  308 + public static Protocol parseFrom(java.io.InputStream input)
  309 + throws java.io.IOException {
  310 + return com.google.protobuf.GeneratedMessageV3
  311 + .parseWithIOException(PARSER, input);
  312 + }
  313 + public static Protocol parseFrom(
  314 + java.io.InputStream input,
  315 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  316 + throws java.io.IOException {
  317 + return com.google.protobuf.GeneratedMessageV3
  318 + .parseWithIOException(PARSER, input, extensionRegistry);
  319 + }
  320 + public static Protocol parseDelimitedFrom(java.io.InputStream input)
  321 + throws java.io.IOException {
  322 + return com.google.protobuf.GeneratedMessageV3
  323 + .parseDelimitedWithIOException(PARSER, input);
  324 + }
  325 + public static Protocol parseDelimitedFrom(
  326 + java.io.InputStream input,
  327 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  328 + throws java.io.IOException {
  329 + return com.google.protobuf.GeneratedMessageV3
  330 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  331 + }
  332 + public static Protocol parseFrom(
  333 + com.google.protobuf.CodedInputStream input)
  334 + throws java.io.IOException {
  335 + return com.google.protobuf.GeneratedMessageV3
  336 + .parseWithIOException(PARSER, input);
  337 + }
  338 + public static Protocol parseFrom(
  339 + com.google.protobuf.CodedInputStream input,
  340 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  341 + throws java.io.IOException {
  342 + return com.google.protobuf.GeneratedMessageV3
  343 + .parseWithIOException(PARSER, input, extensionRegistry);
  344 + }
  345 +
  346 + public Builder newBuilderForType() { return newBuilder(); }
  347 + public static Builder newBuilder() {
  348 + return DEFAULT_INSTANCE.toBuilder();
  349 + }
  350 + public static Builder newBuilder(Protocol prototype) {
  351 + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  352 + }
  353 + public Builder toBuilder() {
  354 + return this == DEFAULT_INSTANCE
  355 + ? new Builder() : new Builder().mergeFrom(this);
  356 + }
  357 +
  358 + @Override
  359 + protected Builder newBuilderForType(
  360 + BuilderParent parent) {
  361 + Builder builder = new Builder(parent);
  362 + return builder;
  363 + }
  364 + /**
  365 + * Protobuf type {@code protocol.Protocol}
  366 + */
  367 + public static final class Builder extends
  368 + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
  369 + // @@protoc_insertion_point(builder_implements:protocol.Protocol)
  370 + ProtocolOrBuilder {
  371 + public static final com.google.protobuf.Descriptors.Descriptor
  372 + getDescriptor() {
  373 + return BaseProto.internal_static_protocol_Protocol_descriptor;
  374 + }
  375 +
  376 + protected FieldAccessorTable
  377 + internalGetFieldAccessorTable() {
  378 + return BaseProto.internal_static_protocol_Protocol_fieldAccessorTable
  379 + .ensureFieldAccessorsInitialized(
  380 + Protocol.class, Builder.class);
  381 + }
  382 +
  383 + // Construct using com.crossoverjie.netty.action.protocol.BaseProto.Protocol.newBuilder()
  384 + private Builder() {
  385 + maybeForceBuilderInitialization();
  386 + }
  387 +
  388 + private Builder(
  389 + BuilderParent parent) {
  390 + super(parent);
  391 + maybeForceBuilderInitialization();
  392 + }
  393 + private void maybeForceBuilderInitialization() {
  394 + if (com.google.protobuf.GeneratedMessageV3
  395 + .alwaysUseFieldBuilders) {
  396 + }
  397 + }
  398 + public Builder clear() {
  399 + super.clear();
  400 + header_ = 0;
  401 + bitField0_ = (bitField0_ & ~0x00000001);
  402 + msg_ = "";
  403 + bitField0_ = (bitField0_ & ~0x00000002);
  404 + return this;
  405 + }
  406 +
  407 + public com.google.protobuf.Descriptors.Descriptor
  408 + getDescriptorForType() {
  409 + return BaseProto.internal_static_protocol_Protocol_descriptor;
  410 + }
  411 +
  412 + public Protocol getDefaultInstanceForType() {
  413 + return Protocol.getDefaultInstance();
  414 + }
  415 +
  416 + public Protocol build() {
  417 + Protocol result = buildPartial();
  418 + if (!result.isInitialized()) {
  419 + throw newUninitializedMessageException(result);
  420 + }
  421 + return result;
  422 + }
  423 +
  424 + public Protocol buildPartial() {
  425 + Protocol result = new Protocol(this);
  426 + int from_bitField0_ = bitField0_;
  427 + int to_bitField0_ = 0;
  428 + if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
  429 + to_bitField0_ |= 0x00000001;
  430 + }
  431 + result.header_ = header_;
  432 + if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
  433 + to_bitField0_ |= 0x00000002;
  434 + }
  435 + result.msg_ = msg_;
  436 + result.bitField0_ = to_bitField0_;
  437 + onBuilt();
  438 + return result;
  439 + }
  440 +
  441 + public Builder clone() {
  442 + return (Builder) super.clone();
  443 + }
  444 + public Builder setField(
  445 + com.google.protobuf.Descriptors.FieldDescriptor field,
  446 + Object value) {
  447 + return (Builder) super.setField(field, value);
  448 + }
  449 + public Builder clearField(
  450 + com.google.protobuf.Descriptors.FieldDescriptor field) {
  451 + return (Builder) super.clearField(field);
  452 + }
  453 + public Builder clearOneof(
  454 + com.google.protobuf.Descriptors.OneofDescriptor oneof) {
  455 + return (Builder) super.clearOneof(oneof);
  456 + }
  457 + public Builder setRepeatedField(
  458 + com.google.protobuf.Descriptors.FieldDescriptor field,
  459 + int index, Object value) {
  460 + return (Builder) super.setRepeatedField(field, index, value);
  461 + }
  462 + public Builder addRepeatedField(
  463 + com.google.protobuf.Descriptors.FieldDescriptor field,
  464 + Object value) {
  465 + return (Builder) super.addRepeatedField(field, value);
  466 + }
  467 + public Builder mergeFrom(com.google.protobuf.Message other) {
  468 + if (other instanceof Protocol) {
  469 + return mergeFrom((Protocol)other);
  470 + } else {
  471 + super.mergeFrom(other);
  472 + return this;
  473 + }
  474 + }
  475 +
  476 + public Builder mergeFrom(Protocol other) {
  477 + if (other == Protocol.getDefaultInstance()) return this;
  478 + if (other.hasHeader()) {
  479 + setHeader(other.getHeader());
  480 + }
  481 + if (other.hasMsg()) {
  482 + bitField0_ |= 0x00000002;
  483 + msg_ = other.msg_;
  484 + onChanged();
  485 + }
  486 + this.mergeUnknownFields(other.unknownFields);
  487 + onChanged();
  488 + return this;
  489 + }
  490 +
  491 + public final boolean isInitialized() {
  492 + if (!hasHeader()) {
  493 + return false;
  494 + }
  495 + if (!hasMsg()) {
  496 + return false;
  497 + }
  498 + return true;
  499 + }
  500 +
  501 + public Builder mergeFrom(
  502 + com.google.protobuf.CodedInputStream input,
  503 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  504 + throws java.io.IOException {
  505 + Protocol parsedMessage = null;
  506 + try {
  507 + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
  508 + } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  509 + parsedMessage = (Protocol) e.getUnfinishedMessage();
  510 + throw e.unwrapIOException();
  511 + } finally {
  512 + if (parsedMessage != null) {
  513 + mergeFrom(parsedMessage);
  514 + }
  515 + }
  516 + return this;
  517 + }
  518 + private int bitField0_;
  519 +
  520 + private int header_ ;
  521 + /**
  522 + * <code>required int32 header = 2;</code>
  523 + */
  524 + public boolean hasHeader() {
  525 + return ((bitField0_ & 0x00000001) == 0x00000001);
  526 + }
  527 + /**
  528 + * <code>required int32 header = 2;</code>
  529 + */
  530 + public int getHeader() {
  531 + return header_;
  532 + }
  533 + /**
  534 + * <code>required int32 header = 2;</code>
  535 + */
  536 + public Builder setHeader(int value) {
  537 + bitField0_ |= 0x00000001;
  538 + header_ = value;
  539 + onChanged();
  540 + return this;
  541 + }
  542 + /**
  543 + * <code>required int32 header = 2;</code>
  544 + */
  545 + public Builder clearHeader() {
  546 + bitField0_ = (bitField0_ & ~0x00000001);
  547 + header_ = 0;
  548 + onChanged();
  549 + return this;
  550 + }
  551 +
  552 + private Object msg_ = "";
  553 + /**
  554 + * <code>required string msg = 1;</code>
  555 + */
  556 + public boolean hasMsg() {
  557 + return ((bitField0_ & 0x00000002) == 0x00000002);
  558 + }
  559 + /**
  560 + * <code>required string msg = 1;</code>
  561 + */
  562 + public String getMsg() {
  563 + Object ref = msg_;
  564 + if (!(ref instanceof String)) {
  565 + com.google.protobuf.ByteString bs =
  566 + (com.google.protobuf.ByteString) ref;
  567 + String s = bs.toStringUtf8();
  568 + if (bs.isValidUtf8()) {
  569 + msg_ = s;
  570 + }
  571 + return s;
  572 + } else {
  573 + return (String) ref;
  574 + }
  575 + }
  576 + /**
  577 + * <code>required string msg = 1;</code>
  578 + */
  579 + public com.google.protobuf.ByteString
  580 + getMsgBytes() {
  581 + Object ref = msg_;
  582 + if (ref instanceof String) {
  583 + com.google.protobuf.ByteString b =
  584 + com.google.protobuf.ByteString.copyFromUtf8(
  585 + (String) ref);
  586 + msg_ = b;
  587 + return b;
  588 + } else {
  589 + return (com.google.protobuf.ByteString) ref;
  590 + }
  591 + }
  592 + /**
  593 + * <code>required string msg = 1;</code>
  594 + */
  595 + public Builder setMsg(
  596 + String value) {
  597 + if (value == null) {
  598 + throw new NullPointerException();
  599 + }
  600 + bitField0_ |= 0x00000002;
  601 + msg_ = value;
  602 + onChanged();
  603 + return this;
  604 + }
  605 + /**
  606 + * <code>required string msg = 1;</code>
  607 + */
  608 + public Builder clearMsg() {
  609 + bitField0_ = (bitField0_ & ~0x00000002);
  610 + msg_ = getDefaultInstance().getMsg();
  611 + onChanged();
  612 + return this;
  613 + }
  614 + /**
  615 + * <code>required string msg = 1;</code>
  616 + */
  617 + public Builder setMsgBytes(
  618 + com.google.protobuf.ByteString value) {
  619 + if (value == null) {
  620 + throw new NullPointerException();
  621 + }
  622 + bitField0_ |= 0x00000002;
  623 + msg_ = value;
  624 + onChanged();
  625 + return this;
  626 + }
  627 + public final Builder setUnknownFields(
  628 + final com.google.protobuf.UnknownFieldSet unknownFields) {
  629 + return super.setUnknownFields(unknownFields);
  630 + }
  631 +
  632 + public final Builder mergeUnknownFields(
  633 + final com.google.protobuf.UnknownFieldSet unknownFields) {
  634 + return super.mergeUnknownFields(unknownFields);
  635 + }
  636 +
  637 +
  638 + // @@protoc_insertion_point(builder_scope:protocol.Protocol)
  639 + }
  640 +
  641 + // @@protoc_insertion_point(class_scope:protocol.Protocol)
  642 + private static final Protocol DEFAULT_INSTANCE;
  643 + static {
  644 + DEFAULT_INSTANCE = new Protocol();
  645 + }
  646 +
  647 + public static Protocol getDefaultInstance() {
  648 + return DEFAULT_INSTANCE;
  649 + }
  650 +
  651 + @Deprecated public static final com.google.protobuf.Parser<Protocol>
  652 + PARSER = new com.google.protobuf.AbstractParser<Protocol>() {
  653 + public Protocol parsePartialFrom(
  654 + com.google.protobuf.CodedInputStream input,
  655 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  656 + throws com.google.protobuf.InvalidProtocolBufferException {
  657 + return new Protocol(input, extensionRegistry);
  658 + }
  659 + };
  660 +
  661 + public static com.google.protobuf.Parser<Protocol> parser() {
  662 + return PARSER;
  663 + }
  664 +
  665 + @Override
  666 + public com.google.protobuf.Parser<Protocol> getParserForType() {
  667 + return PARSER;
  668 + }
  669 +
  670 + public Protocol getDefaultInstanceForType() {
  671 + return DEFAULT_INSTANCE;
  672 + }
  673 +
  674 + }
  675 +
  676 + private static final com.google.protobuf.Descriptors.Descriptor
  677 + internal_static_protocol_Protocol_descriptor;
  678 + private static final
  679 + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
  680 + internal_static_protocol_Protocol_fieldAccessorTable;
  681 +
  682 + public static com.google.protobuf.Descriptors.FileDescriptor
  683 + getDescriptor() {
  684 + return descriptor;
  685 + }
  686 + private static com.google.protobuf.Descriptors.FileDescriptor
  687 + descriptor;
  688 + static {
  689 + String[] descriptorData = {
  690 + "\n\020BaseProtoc.proto\022\010protocol\"\'\n\010Protocol" +
  691 + "\022\016\n\006header\030\002 \002(\005\022\013\n\003msg\030\001 \002(\tB3\n&com.cro" +
  692 + "ssoverjie.netty.action.protocolB\tBasePro" +
  693 + "to"
  694 + };
  695 + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
  696 + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
  697 + public com.google.protobuf.ExtensionRegistry assignDescriptors(
  698 + com.google.protobuf.Descriptors.FileDescriptor root) {
  699 + descriptor = root;
  700 + return null;
  701 + }
  702 + };
  703 + com.google.protobuf.Descriptors.FileDescriptor
  704 + .internalBuildGeneratedFileFrom(descriptorData,
  705 + new com.google.protobuf.Descriptors.FileDescriptor[] {
  706 + }, assigner);
  707 + internal_static_protocol_Protocol_descriptor =
  708 + getDescriptor().getMessageTypes().get(0);
  709 + internal_static_protocol_Protocol_fieldAccessorTable = new
  710 + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
  711 + internal_static_protocol_Protocol_descriptor,
  712 + new String[] { "Header", "Msg", });
  713 + }
  714 +
  715 + // @@protoc_insertion_point(outer_class_scope)
  716 +}
  1 +// Generated by the protocol buffer compiler. DO NOT EDIT!
  2 +// source: BaseRequestProto.proto
  3 +
  4 +package com.crossoverjie.netty.action.common.protocol;
  5 +
  6 +public final class BaseRequestProto {
  7 + private BaseRequestProto() {}
  8 + public static void registerAllExtensions(
  9 + com.google.protobuf.ExtensionRegistryLite registry) {
  10 + }
  11 +
  12 + public static void registerAllExtensions(
  13 + com.google.protobuf.ExtensionRegistry registry) {
  14 + registerAllExtensions(
  15 + (com.google.protobuf.ExtensionRegistryLite) registry);
  16 + }
  17 + public interface RequestProtocolOrBuilder extends
  18 + // @@protoc_insertion_point(interface_extends:protocol.RequestProtocol)
  19 + com.google.protobuf.MessageOrBuilder {
  20 +
  21 + /**
  22 + * <code>required int32 requestId = 2;</code>
  23 + */
  24 + boolean hasRequestId();
  25 + /**
  26 + * <code>required int32 requestId = 2;</code>
  27 + */
  28 + int getRequestId();
  29 +
  30 + /**
  31 + * <code>required string reqMsg = 1;</code>
  32 + */
  33 + boolean hasReqMsg();
  34 + /**
  35 + * <code>required string reqMsg = 1;</code>
  36 + */
  37 + String getReqMsg();
  38 + /**
  39 + * <code>required string reqMsg = 1;</code>
  40 + */
  41 + com.google.protobuf.ByteString
  42 + getReqMsgBytes();
  43 + }
  44 + /**
  45 + * Protobuf type {@code protocol.RequestProtocol}
  46 + */
  47 + public static final class RequestProtocol extends
  48 + com.google.protobuf.GeneratedMessageV3 implements
  49 + // @@protoc_insertion_point(message_implements:protocol.RequestProtocol)
  50 + RequestProtocolOrBuilder {
  51 + private static final long serialVersionUID = 0L;
  52 + // Use RequestProtocol.newBuilder() to construct.
  53 + private RequestProtocol(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
  54 + super(builder);
  55 + }
  56 + private RequestProtocol() {
  57 + requestId_ = 0;
  58 + reqMsg_ = "";
  59 + }
  60 +
  61 + @Override
  62 + public final com.google.protobuf.UnknownFieldSet
  63 + getUnknownFields() {
  64 + return this.unknownFields;
  65 + }
  66 + private RequestProtocol(
  67 + com.google.protobuf.CodedInputStream input,
  68 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  69 + throws com.google.protobuf.InvalidProtocolBufferException {
  70 + this();
  71 + if (extensionRegistry == null) {
  72 + throw new NullPointerException();
  73 + }
  74 + int mutable_bitField0_ = 0;
  75 + com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  76 + com.google.protobuf.UnknownFieldSet.newBuilder();
  77 + try {
  78 + boolean done = false;
  79 + while (!done) {
  80 + int tag = input.readTag();
  81 + switch (tag) {
  82 + case 0:
  83 + done = true;
  84 + break;
  85 + default: {
  86 + if (!parseUnknownField(
  87 + input, unknownFields, extensionRegistry, tag)) {
  88 + done = true;
  89 + }
  90 + break;
  91 + }
  92 + case 10: {
  93 + com.google.protobuf.ByteString bs = input.readBytes();
  94 + bitField0_ |= 0x00000002;
  95 + reqMsg_ = bs;
  96 + break;
  97 + }
  98 + case 16: {
  99 + bitField0_ |= 0x00000001;
  100 + requestId_ = input.readInt32();
  101 + break;
  102 + }
  103 + }
  104 + }
  105 + } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  106 + throw e.setUnfinishedMessage(this);
  107 + } catch (java.io.IOException e) {
  108 + throw new com.google.protobuf.InvalidProtocolBufferException(
  109 + e).setUnfinishedMessage(this);
  110 + } finally {
  111 + this.unknownFields = unknownFields.build();
  112 + makeExtensionsImmutable();
  113 + }
  114 + }
  115 + public static final com.google.protobuf.Descriptors.Descriptor
  116 + getDescriptor() {
  117 + return BaseRequestProto.internal_static_protocol_RequestProtocol_descriptor;
  118 + }
  119 +
  120 + protected FieldAccessorTable
  121 + internalGetFieldAccessorTable() {
  122 + return BaseRequestProto.internal_static_protocol_RequestProtocol_fieldAccessorTable
  123 + .ensureFieldAccessorsInitialized(
  124 + RequestProtocol.class, Builder.class);
  125 + }
  126 +
  127 + private int bitField0_;
  128 + public static final int REQUESTID_FIELD_NUMBER = 2;
  129 + private int requestId_;
  130 + /**
  131 + * <code>required int32 requestId = 2;</code>
  132 + */
  133 + public boolean hasRequestId() {
  134 + return ((bitField0_ & 0x00000001) == 0x00000001);
  135 + }
  136 + /**
  137 + * <code>required int32 requestId = 2;</code>
  138 + */
  139 + public int getRequestId() {
  140 + return requestId_;
  141 + }
  142 +
  143 + public static final int REQMSG_FIELD_NUMBER = 1;
  144 + private volatile Object reqMsg_;
  145 + /**
  146 + * <code>required string reqMsg = 1;</code>
  147 + */
  148 + public boolean hasReqMsg() {
  149 + return ((bitField0_ & 0x00000002) == 0x00000002);
  150 + }
  151 + /**
  152 + * <code>required string reqMsg = 1;</code>
  153 + */
  154 + public String getReqMsg() {
  155 + Object ref = reqMsg_;
  156 + if (ref instanceof String) {
  157 + return (String) ref;
  158 + } else {
  159 + com.google.protobuf.ByteString bs =
  160 + (com.google.protobuf.ByteString) ref;
  161 + String s = bs.toStringUtf8();
  162 + if (bs.isValidUtf8()) {
  163 + reqMsg_ = s;
  164 + }
  165 + return s;
  166 + }
  167 + }
  168 + /**
  169 + * <code>required string reqMsg = 1;</code>
  170 + */
  171 + public com.google.protobuf.ByteString
  172 + getReqMsgBytes() {
  173 + Object ref = reqMsg_;
  174 + if (ref instanceof String) {
  175 + com.google.protobuf.ByteString b =
  176 + com.google.protobuf.ByteString.copyFromUtf8(
  177 + (String) ref);
  178 + reqMsg_ = b;
  179 + return b;
  180 + } else {
  181 + return (com.google.protobuf.ByteString) ref;
  182 + }
  183 + }
  184 +
  185 + private byte memoizedIsInitialized = -1;
  186 + public final boolean isInitialized() {
  187 + byte isInitialized = memoizedIsInitialized;
  188 + if (isInitialized == 1) return true;
  189 + if (isInitialized == 0) return false;
  190 +
  191 + if (!hasRequestId()) {
  192 + memoizedIsInitialized = 0;
  193 + return false;
  194 + }
  195 + if (!hasReqMsg()) {
  196 + memoizedIsInitialized = 0;
  197 + return false;
  198 + }
  199 + memoizedIsInitialized = 1;
  200 + return true;
  201 + }
  202 +
  203 + public void writeTo(com.google.protobuf.CodedOutputStream output)
  204 + throws java.io.IOException {
  205 + if (((bitField0_ & 0x00000002) == 0x00000002)) {
  206 + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, reqMsg_);
  207 + }
  208 + if (((bitField0_ & 0x00000001) == 0x00000001)) {
  209 + output.writeInt32(2, requestId_);
  210 + }
  211 + unknownFields.writeTo(output);
  212 + }
  213 +
  214 + public int getSerializedSize() {
  215 + int size = memoizedSize;
  216 + if (size != -1) return size;
  217 +
  218 + size = 0;
  219 + if (((bitField0_ & 0x00000002) == 0x00000002)) {
  220 + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, reqMsg_);
  221 + }
  222 + if (((bitField0_ & 0x00000001) == 0x00000001)) {
  223 + size += com.google.protobuf.CodedOutputStream
  224 + .computeInt32Size(2, requestId_);
  225 + }
  226 + size += unknownFields.getSerializedSize();
  227 + memoizedSize = size;
  228 + return size;
  229 + }
  230 +
  231 + @Override
  232 + public boolean equals(final Object obj) {
  233 + if (obj == this) {
  234 + return true;
  235 + }
  236 + if (!(obj instanceof RequestProtocol)) {
  237 + return super.equals(obj);
  238 + }
  239 + RequestProtocol other = (RequestProtocol) obj;
  240 +
  241 + boolean result = true;
  242 + result = result && (hasRequestId() == other.hasRequestId());
  243 + if (hasRequestId()) {
  244 + result = result && (getRequestId()
  245 + == other.getRequestId());
  246 + }
  247 + result = result && (hasReqMsg() == other.hasReqMsg());
  248 + if (hasReqMsg()) {
  249 + result = result && getReqMsg()
  250 + .equals(other.getReqMsg());
  251 + }
  252 + result = result && unknownFields.equals(other.unknownFields);
  253 + return result;
  254 + }
  255 +
  256 + @Override
  257 + public int hashCode() {
  258 + if (memoizedHashCode != 0) {
  259 + return memoizedHashCode;
  260 + }
  261 + int hash = 41;
  262 + hash = (19 * hash) + getDescriptor().hashCode();
  263 + if (hasRequestId()) {
  264 + hash = (37 * hash) + REQUESTID_FIELD_NUMBER;
  265 + hash = (53 * hash) + getRequestId();
  266 + }
  267 + if (hasReqMsg()) {
  268 + hash = (37 * hash) + REQMSG_FIELD_NUMBER;
  269 + hash = (53 * hash) + getReqMsg().hashCode();
  270 + }
  271 + hash = (29 * hash) + unknownFields.hashCode();
  272 + memoizedHashCode = hash;
  273 + return hash;
  274 + }
  275 +
  276 + public static RequestProtocol parseFrom(
  277 + java.nio.ByteBuffer data)
  278 + throws com.google.protobuf.InvalidProtocolBufferException {
  279 + return PARSER.parseFrom(data);
  280 + }
  281 + public static RequestProtocol parseFrom(
  282 + java.nio.ByteBuffer data,
  283 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  284 + throws com.google.protobuf.InvalidProtocolBufferException {
  285 + return PARSER.parseFrom(data, extensionRegistry);
  286 + }
  287 + public static RequestProtocol parseFrom(
  288 + com.google.protobuf.ByteString data)
  289 + throws com.google.protobuf.InvalidProtocolBufferException {
  290 + return PARSER.parseFrom(data);
  291 + }
  292 + public static RequestProtocol parseFrom(
  293 + com.google.protobuf.ByteString data,
  294 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  295 + throws com.google.protobuf.InvalidProtocolBufferException {
  296 + return PARSER.parseFrom(data, extensionRegistry);
  297 + }
  298 + public static RequestProtocol parseFrom(byte[] data)
  299 + throws com.google.protobuf.InvalidProtocolBufferException {
  300 + return PARSER.parseFrom(data);
  301 + }
  302 + public static RequestProtocol parseFrom(
  303 + byte[] data,
  304 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  305 + throws com.google.protobuf.InvalidProtocolBufferException {
  306 + return PARSER.parseFrom(data, extensionRegistry);
  307 + }
  308 + public static RequestProtocol parseFrom(java.io.InputStream input)
  309 + throws java.io.IOException {
  310 + return com.google.protobuf.GeneratedMessageV3
  311 + .parseWithIOException(PARSER, input);
  312 + }
  313 + public static RequestProtocol parseFrom(
  314 + java.io.InputStream input,
  315 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  316 + throws java.io.IOException {
  317 + return com.google.protobuf.GeneratedMessageV3
  318 + .parseWithIOException(PARSER, input, extensionRegistry);
  319 + }
  320 + public static RequestProtocol parseDelimitedFrom(java.io.InputStream input)
  321 + throws java.io.IOException {
  322 + return com.google.protobuf.GeneratedMessageV3
  323 + .parseDelimitedWithIOException(PARSER, input);
  324 + }
  325 + public static RequestProtocol parseDelimitedFrom(
  326 + java.io.InputStream input,
  327 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  328 + throws java.io.IOException {
  329 + return com.google.protobuf.GeneratedMessageV3
  330 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  331 + }
  332 + public static RequestProtocol parseFrom(
  333 + com.google.protobuf.CodedInputStream input)
  334 + throws java.io.IOException {
  335 + return com.google.protobuf.GeneratedMessageV3
  336 + .parseWithIOException(PARSER, input);
  337 + }
  338 + public static RequestProtocol parseFrom(
  339 + com.google.protobuf.CodedInputStream input,
  340 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  341 + throws java.io.IOException {
  342 + return com.google.protobuf.GeneratedMessageV3
  343 + .parseWithIOException(PARSER, input, extensionRegistry);
  344 + }
  345 +
  346 + public Builder newBuilderForType() { return newBuilder(); }
  347 + public static Builder newBuilder() {
  348 + return DEFAULT_INSTANCE.toBuilder();
  349 + }
  350 + public static Builder newBuilder(RequestProtocol prototype) {
  351 + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  352 + }
  353 + public Builder toBuilder() {
  354 + return this == DEFAULT_INSTANCE
  355 + ? new Builder() : new Builder().mergeFrom(this);
  356 + }
  357 +
  358 + @Override
  359 + protected Builder newBuilderForType(
  360 + BuilderParent parent) {
  361 + Builder builder = new Builder(parent);
  362 + return builder;
  363 + }
  364 + /**
  365 + * Protobuf type {@code protocol.RequestProtocol}
  366 + */
  367 + public static final class Builder extends
  368 + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
  369 + // @@protoc_insertion_point(builder_implements:protocol.RequestProtocol)
  370 + RequestProtocolOrBuilder {
  371 + public static final com.google.protobuf.Descriptors.Descriptor
  372 + getDescriptor() {
  373 + return BaseRequestProto.internal_static_protocol_RequestProtocol_descriptor;
  374 + }
  375 +
  376 + protected FieldAccessorTable
  377 + internalGetFieldAccessorTable() {
  378 + return BaseRequestProto.internal_static_protocol_RequestProtocol_fieldAccessorTable
  379 + .ensureFieldAccessorsInitialized(
  380 + RequestProtocol.class, Builder.class);
  381 + }
  382 +
  383 + // Construct using com.crossoverjie.netty.action.protocol.BaseRequestProto.RequestProtocol.newBuilder()
  384 + private Builder() {
  385 + maybeForceBuilderInitialization();
  386 + }
  387 +
  388 + private Builder(
  389 + BuilderParent parent) {
  390 + super(parent);
  391 + maybeForceBuilderInitialization();
  392 + }
  393 + private void maybeForceBuilderInitialization() {
  394 + if (com.google.protobuf.GeneratedMessageV3
  395 + .alwaysUseFieldBuilders) {
  396 + }
  397 + }
  398 + public Builder clear() {
  399 + super.clear();
  400 + requestId_ = 0;
  401 + bitField0_ = (bitField0_ & ~0x00000001);
  402 + reqMsg_ = "";
  403 + bitField0_ = (bitField0_ & ~0x00000002);
  404 + return this;
  405 + }
  406 +
  407 + public com.google.protobuf.Descriptors.Descriptor
  408 + getDescriptorForType() {
  409 + return BaseRequestProto.internal_static_protocol_RequestProtocol_descriptor;
  410 + }
  411 +
  412 + public RequestProtocol getDefaultInstanceForType() {
  413 + return RequestProtocol.getDefaultInstance();
  414 + }
  415 +
  416 + public RequestProtocol build() {
  417 + RequestProtocol result = buildPartial();
  418 + if (!result.isInitialized()) {
  419 + throw newUninitializedMessageException(result);
  420 + }
  421 + return result;
  422 + }
  423 +
  424 + public RequestProtocol buildPartial() {
  425 + RequestProtocol result = new RequestProtocol(this);
  426 + int from_bitField0_ = bitField0_;
  427 + int to_bitField0_ = 0;
  428 + if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
  429 + to_bitField0_ |= 0x00000001;
  430 + }
  431 + result.requestId_ = requestId_;
  432 + if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
  433 + to_bitField0_ |= 0x00000002;
  434 + }
  435 + result.reqMsg_ = reqMsg_;
  436 + result.bitField0_ = to_bitField0_;
  437 + onBuilt();
  438 + return result;
  439 + }
  440 +
  441 + public Builder clone() {
  442 + return (Builder) super.clone();
  443 + }
  444 + public Builder setField(
  445 + com.google.protobuf.Descriptors.FieldDescriptor field,
  446 + Object value) {
  447 + return (Builder) super.setField(field, value);
  448 + }
  449 + public Builder clearField(
  450 + com.google.protobuf.Descriptors.FieldDescriptor field) {
  451 + return (Builder) super.clearField(field);
  452 + }
  453 + public Builder clearOneof(
  454 + com.google.protobuf.Descriptors.OneofDescriptor oneof) {
  455 + return (Builder) super.clearOneof(oneof);
  456 + }
  457 + public Builder setRepeatedField(
  458 + com.google.protobuf.Descriptors.FieldDescriptor field,
  459 + int index, Object value) {
  460 + return (Builder) super.setRepeatedField(field, index, value);
  461 + }
  462 + public Builder addRepeatedField(
  463 + com.google.protobuf.Descriptors.FieldDescriptor field,
  464 + Object value) {
  465 + return (Builder) super.addRepeatedField(field, value);
  466 + }
  467 + public Builder mergeFrom(com.google.protobuf.Message other) {
  468 + if (other instanceof RequestProtocol) {
  469 + return mergeFrom((RequestProtocol)other);
  470 + } else {
  471 + super.mergeFrom(other);
  472 + return this;
  473 + }
  474 + }
  475 +
  476 + public Builder mergeFrom(RequestProtocol other) {
  477 + if (other == RequestProtocol.getDefaultInstance()) return this;
  478 + if (other.hasRequestId()) {
  479 + setRequestId(other.getRequestId());
  480 + }
  481 + if (other.hasReqMsg()) {
  482 + bitField0_ |= 0x00000002;
  483 + reqMsg_ = other.reqMsg_;
  484 + onChanged();
  485 + }
  486 + this.mergeUnknownFields(other.unknownFields);
  487 + onChanged();
  488 + return this;
  489 + }
  490 +
  491 + public final boolean isInitialized() {
  492 + if (!hasRequestId()) {
  493 + return false;
  494 + }
  495 + if (!hasReqMsg()) {
  496 + return false;
  497 + }
  498 + return true;
  499 + }
  500 +
  501 + public Builder mergeFrom(
  502 + com.google.protobuf.CodedInputStream input,
  503 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  504 + throws java.io.IOException {
  505 + RequestProtocol parsedMessage = null;
  506 + try {
  507 + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
  508 + } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  509 + parsedMessage = (RequestProtocol) e.getUnfinishedMessage();
  510 + throw e.unwrapIOException();
  511 + } finally {
  512 + if (parsedMessage != null) {
  513 + mergeFrom(parsedMessage);
  514 + }
  515 + }
  516 + return this;
  517 + }
  518 + private int bitField0_;
  519 +
  520 + private int requestId_ ;
  521 + /**
  522 + * <code>required int32 requestId = 2;</code>
  523 + */
  524 + public boolean hasRequestId() {
  525 + return ((bitField0_ & 0x00000001) == 0x00000001);
  526 + }
  527 + /**
  528 + * <code>required int32 requestId = 2;</code>
  529 + */
  530 + public int getRequestId() {
  531 + return requestId_;
  532 + }
  533 + /**
  534 + * <code>required int32 requestId = 2;</code>
  535 + */
  536 + public Builder setRequestId(int value) {
  537 + bitField0_ |= 0x00000001;
  538 + requestId_ = value;
  539 + onChanged();
  540 + return this;
  541 + }
  542 + /**
  543 + * <code>required int32 requestId = 2;</code>
  544 + */
  545 + public Builder clearRequestId() {
  546 + bitField0_ = (bitField0_ & ~0x00000001);
  547 + requestId_ = 0;
  548 + onChanged();
  549 + return this;
  550 + }
  551 +
  552 + private Object reqMsg_ = "";
  553 + /**
  554 + * <code>required string reqMsg = 1;</code>
  555 + */
  556 + public boolean hasReqMsg() {
  557 + return ((bitField0_ & 0x00000002) == 0x00000002);
  558 + }
  559 + /**
  560 + * <code>required string reqMsg = 1;</code>
  561 + */
  562 + public String getReqMsg() {
  563 + Object ref = reqMsg_;
  564 + if (!(ref instanceof String)) {
  565 + com.google.protobuf.ByteString bs =
  566 + (com.google.protobuf.ByteString) ref;
  567 + String s = bs.toStringUtf8();
  568 + if (bs.isValidUtf8()) {
  569 + reqMsg_ = s;
  570 + }
  571 + return s;
  572 + } else {
  573 + return (String) ref;
  574 + }
  575 + }
  576 + /**
  577 + * <code>required string reqMsg = 1;</code>
  578 + */
  579 + public com.google.protobuf.ByteString
  580 + getReqMsgBytes() {
  581 + Object ref = reqMsg_;
  582 + if (ref instanceof String) {
  583 + com.google.protobuf.ByteString b =
  584 + com.google.protobuf.ByteString.copyFromUtf8(
  585 + (String) ref);
  586 + reqMsg_ = b;
  587 + return b;
  588 + } else {
  589 + return (com.google.protobuf.ByteString) ref;
  590 + }
  591 + }
  592 + /**
  593 + * <code>required string reqMsg = 1;</code>
  594 + */
  595 + public Builder setReqMsg(
  596 + String value) {
  597 + if (value == null) {
  598 + throw new NullPointerException();
  599 + }
  600 + bitField0_ |= 0x00000002;
  601 + reqMsg_ = value;
  602 + onChanged();
  603 + return this;
  604 + }
  605 + /**
  606 + * <code>required string reqMsg = 1;</code>
  607 + */
  608 + public Builder clearReqMsg() {
  609 + bitField0_ = (bitField0_ & ~0x00000002);
  610 + reqMsg_ = getDefaultInstance().getReqMsg();
  611 + onChanged();
  612 + return this;
  613 + }
  614 + /**
  615 + * <code>required string reqMsg = 1;</code>
  616 + */
  617 + public Builder setReqMsgBytes(
  618 + com.google.protobuf.ByteString value) {
  619 + if (value == null) {
  620 + throw new NullPointerException();
  621 + }
  622 + bitField0_ |= 0x00000002;
  623 + reqMsg_ = value;
  624 + onChanged();
  625 + return this;
  626 + }
  627 + public final Builder setUnknownFields(
  628 + final com.google.protobuf.UnknownFieldSet unknownFields) {
  629 + return super.setUnknownFields(unknownFields);
  630 + }
  631 +
  632 + public final Builder mergeUnknownFields(
  633 + final com.google.protobuf.UnknownFieldSet unknownFields) {
  634 + return super.mergeUnknownFields(unknownFields);
  635 + }
  636 +
  637 +
  638 + // @@protoc_insertion_point(builder_scope:protocol.RequestProtocol)
  639 + }
  640 +
  641 + // @@protoc_insertion_point(class_scope:protocol.RequestProtocol)
  642 + private static final RequestProtocol DEFAULT_INSTANCE;
  643 + static {
  644 + DEFAULT_INSTANCE = new RequestProtocol();
  645 + }
  646 +
  647 + public static RequestProtocol getDefaultInstance() {
  648 + return DEFAULT_INSTANCE;
  649 + }
  650 +
  651 + @Deprecated public static final com.google.protobuf.Parser<RequestProtocol>
  652 + PARSER = new com.google.protobuf.AbstractParser<RequestProtocol>() {
  653 + public RequestProtocol parsePartialFrom(
  654 + com.google.protobuf.CodedInputStream input,
  655 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  656 + throws com.google.protobuf.InvalidProtocolBufferException {
  657 + return new RequestProtocol(input, extensionRegistry);
  658 + }
  659 + };
  660 +
  661 + public static com.google.protobuf.Parser<RequestProtocol> parser() {
  662 + return PARSER;
  663 + }
  664 +
  665 + @Override
  666 + public com.google.protobuf.Parser<RequestProtocol> getParserForType() {
  667 + return PARSER;
  668 + }
  669 +
  670 + public RequestProtocol getDefaultInstanceForType() {
  671 + return DEFAULT_INSTANCE;
  672 + }
  673 +
  674 + }
  675 +
  676 + private static final com.google.protobuf.Descriptors.Descriptor
  677 + internal_static_protocol_RequestProtocol_descriptor;
  678 + private static final
  679 + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
  680 + internal_static_protocol_RequestProtocol_fieldAccessorTable;
  681 +
  682 + public static com.google.protobuf.Descriptors.FileDescriptor
  683 + getDescriptor() {
  684 + return descriptor;
  685 + }
  686 + private static com.google.protobuf.Descriptors.FileDescriptor
  687 + descriptor;
  688 + static {
  689 + String[] descriptorData = {
  690 + "\n\026BaseRequestProto.proto\022\010protocol\"4\n\017Re" +
  691 + "questProtocol\022\021\n\trequestId\030\002 \002(\005\022\016\n\006reqM" +
  692 + "sg\030\001 \002(\tB:\n&com.crossoverjie.netty.actio" +
  693 + "n.protocolB\020BaseRequestProto"
  694 + };
  695 + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
  696 + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
  697 + public com.google.protobuf.ExtensionRegistry assignDescriptors(
  698 + com.google.protobuf.Descriptors.FileDescriptor root) {
  699 + descriptor = root;
  700 + return null;
  701 + }
  702 + };
  703 + com.google.protobuf.Descriptors.FileDescriptor
  704 + .internalBuildGeneratedFileFrom(descriptorData,
  705 + new com.google.protobuf.Descriptors.FileDescriptor[] {
  706 + }, assigner);
  707 + internal_static_protocol_RequestProtocol_descriptor =
  708 + getDescriptor().getMessageTypes().get(0);
  709 + internal_static_protocol_RequestProtocol_fieldAccessorTable = new
  710 + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
  711 + internal_static_protocol_RequestProtocol_descriptor,
  712 + new String[] { "RequestId", "ReqMsg", });
  713 + }
  714 +
  715 + // @@protoc_insertion_point(outer_class_scope)
  716 +}
  1 +// Generated by the protocol buffer compiler. DO NOT EDIT!
  2 +// source: BaseResponseProto.proto
  3 +
  4 +package com.crossoverjie.netty.action.common.protocol;
  5 +
  6 +public final class BaseResponseProto {
  7 + private BaseResponseProto() {}
  8 + public static void registerAllExtensions(
  9 + com.google.protobuf.ExtensionRegistryLite registry) {
  10 + }
  11 +
  12 + public static void registerAllExtensions(
  13 + com.google.protobuf.ExtensionRegistry registry) {
  14 + registerAllExtensions(
  15 + (com.google.protobuf.ExtensionRegistryLite) registry);
  16 + }
  17 + public interface ResponseProtocolOrBuilder extends
  18 + // @@protoc_insertion_point(interface_extends:protocol.ResponseProtocol)
  19 + com.google.protobuf.MessageOrBuilder {
  20 +
  21 + /**
  22 + * <code>required int32 responseId = 2;</code>
  23 + */
  24 + boolean hasResponseId();
  25 + /**
  26 + * <code>required int32 responseId = 2;</code>
  27 + */
  28 + int getResponseId();
  29 +
  30 + /**
  31 + * <code>required string resMsg = 1;</code>
  32 + */
  33 + boolean hasResMsg();
  34 + /**
  35 + * <code>required string resMsg = 1;</code>
  36 + */
  37 + String getResMsg();
  38 + /**
  39 + * <code>required string resMsg = 1;</code>
  40 + */
  41 + com.google.protobuf.ByteString
  42 + getResMsgBytes();
  43 + }
  44 + /**
  45 + * Protobuf type {@code protocol.ResponseProtocol}
  46 + */
  47 + public static final class ResponseProtocol extends
  48 + com.google.protobuf.GeneratedMessageV3 implements
  49 + // @@protoc_insertion_point(message_implements:protocol.ResponseProtocol)
  50 + ResponseProtocolOrBuilder {
  51 + private static final long serialVersionUID = 0L;
  52 + // Use ResponseProtocol.newBuilder() to construct.
  53 + private ResponseProtocol(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
  54 + super(builder);
  55 + }
  56 + private ResponseProtocol() {
  57 + responseId_ = 0;
  58 + resMsg_ = "";
  59 + }
  60 +
  61 + @Override
  62 + public final com.google.protobuf.UnknownFieldSet
  63 + getUnknownFields() {
  64 + return this.unknownFields;
  65 + }
  66 + private ResponseProtocol(
  67 + com.google.protobuf.CodedInputStream input,
  68 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  69 + throws com.google.protobuf.InvalidProtocolBufferException {
  70 + this();
  71 + if (extensionRegistry == null) {
  72 + throw new NullPointerException();
  73 + }
  74 + int mutable_bitField0_ = 0;
  75 + com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  76 + com.google.protobuf.UnknownFieldSet.newBuilder();
  77 + try {
  78 + boolean done = false;
  79 + while (!done) {
  80 + int tag = input.readTag();
  81 + switch (tag) {
  82 + case 0:
  83 + done = true;
  84 + break;
  85 + default: {
  86 + if (!parseUnknownField(
  87 + input, unknownFields, extensionRegistry, tag)) {
  88 + done = true;
  89 + }
  90 + break;
  91 + }
  92 + case 10: {
  93 + com.google.protobuf.ByteString bs = input.readBytes();
  94 + bitField0_ |= 0x00000002;
  95 + resMsg_ = bs;
  96 + break;
  97 + }
  98 + case 16: {
  99 + bitField0_ |= 0x00000001;
  100 + responseId_ = input.readInt32();
  101 + break;
  102 + }
  103 + }
  104 + }
  105 + } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  106 + throw e.setUnfinishedMessage(this);
  107 + } catch (java.io.IOException e) {
  108 + throw new com.google.protobuf.InvalidProtocolBufferException(
  109 + e).setUnfinishedMessage(this);
  110 + } finally {
  111 + this.unknownFields = unknownFields.build();
  112 + makeExtensionsImmutable();
  113 + }
  114 + }
  115 + public static final com.google.protobuf.Descriptors.Descriptor
  116 + getDescriptor() {
  117 + return BaseResponseProto.internal_static_protocol_ResponseProtocol_descriptor;
  118 + }
  119 +
  120 + protected FieldAccessorTable
  121 + internalGetFieldAccessorTable() {
  122 + return BaseResponseProto.internal_static_protocol_ResponseProtocol_fieldAccessorTable
  123 + .ensureFieldAccessorsInitialized(
  124 + ResponseProtocol.class, Builder.class);
  125 + }
  126 +
  127 + private int bitField0_;
  128 + public static final int RESPONSEID_FIELD_NUMBER = 2;
  129 + private int responseId_;
  130 + /**
  131 + * <code>required int32 responseId = 2;</code>
  132 + */
  133 + public boolean hasResponseId() {
  134 + return ((bitField0_ & 0x00000001) == 0x00000001);
  135 + }
  136 + /**
  137 + * <code>required int32 responseId = 2;</code>
  138 + */
  139 + public int getResponseId() {
  140 + return responseId_;
  141 + }
  142 +
  143 + public static final int RESMSG_FIELD_NUMBER = 1;
  144 + private volatile Object resMsg_;
  145 + /**
  146 + * <code>required string resMsg = 1;</code>
  147 + */
  148 + public boolean hasResMsg() {
  149 + return ((bitField0_ & 0x00000002) == 0x00000002);
  150 + }
  151 + /**
  152 + * <code>required string resMsg = 1;</code>
  153 + */
  154 + public String getResMsg() {
  155 + Object ref = resMsg_;
  156 + if (ref instanceof String) {
  157 + return (String) ref;
  158 + } else {
  159 + com.google.protobuf.ByteString bs =
  160 + (com.google.protobuf.ByteString) ref;
  161 + String s = bs.toStringUtf8();
  162 + if (bs.isValidUtf8()) {
  163 + resMsg_ = s;
  164 + }
  165 + return s;
  166 + }
  167 + }
  168 + /**
  169 + * <code>required string resMsg = 1;</code>
  170 + */
  171 + public com.google.protobuf.ByteString
  172 + getResMsgBytes() {
  173 + Object ref = resMsg_;
  174 + if (ref instanceof String) {
  175 + com.google.protobuf.ByteString b =
  176 + com.google.protobuf.ByteString.copyFromUtf8(
  177 + (String) ref);
  178 + resMsg_ = b;
  179 + return b;
  180 + } else {
  181 + return (com.google.protobuf.ByteString) ref;
  182 + }
  183 + }
  184 +
  185 + private byte memoizedIsInitialized = -1;
  186 + public final boolean isInitialized() {
  187 + byte isInitialized = memoizedIsInitialized;
  188 + if (isInitialized == 1) return true;
  189 + if (isInitialized == 0) return false;
  190 +
  191 + if (!hasResponseId()) {
  192 + memoizedIsInitialized = 0;
  193 + return false;
  194 + }
  195 + if (!hasResMsg()) {
  196 + memoizedIsInitialized = 0;
  197 + return false;
  198 + }
  199 + memoizedIsInitialized = 1;
  200 + return true;
  201 + }
  202 +
  203 + public void writeTo(com.google.protobuf.CodedOutputStream output)
  204 + throws java.io.IOException {
  205 + if (((bitField0_ & 0x00000002) == 0x00000002)) {
  206 + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, resMsg_);
  207 + }
  208 + if (((bitField0_ & 0x00000001) == 0x00000001)) {
  209 + output.writeInt32(2, responseId_);
  210 + }
  211 + unknownFields.writeTo(output);
  212 + }
  213 +
  214 + public int getSerializedSize() {
  215 + int size = memoizedSize;
  216 + if (size != -1) return size;
  217 +
  218 + size = 0;
  219 + if (((bitField0_ & 0x00000002) == 0x00000002)) {
  220 + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, resMsg_);
  221 + }
  222 + if (((bitField0_ & 0x00000001) == 0x00000001)) {
  223 + size += com.google.protobuf.CodedOutputStream
  224 + .computeInt32Size(2, responseId_);
  225 + }
  226 + size += unknownFields.getSerializedSize();
  227 + memoizedSize = size;
  228 + return size;
  229 + }
  230 +
  231 + @Override
  232 + public boolean equals(final Object obj) {
  233 + if (obj == this) {
  234 + return true;
  235 + }
  236 + if (!(obj instanceof ResponseProtocol)) {
  237 + return super.equals(obj);
  238 + }
  239 + ResponseProtocol other = (ResponseProtocol) obj;
  240 +
  241 + boolean result = true;
  242 + result = result && (hasResponseId() == other.hasResponseId());
  243 + if (hasResponseId()) {
  244 + result = result && (getResponseId()
  245 + == other.getResponseId());
  246 + }
  247 + result = result && (hasResMsg() == other.hasResMsg());
  248 + if (hasResMsg()) {
  249 + result = result && getResMsg()
  250 + .equals(other.getResMsg());
  251 + }
  252 + result = result && unknownFields.equals(other.unknownFields);
  253 + return result;
  254 + }
  255 +
  256 + @Override
  257 + public int hashCode() {
  258 + if (memoizedHashCode != 0) {
  259 + return memoizedHashCode;
  260 + }
  261 + int hash = 41;
  262 + hash = (19 * hash) + getDescriptor().hashCode();
  263 + if (hasResponseId()) {
  264 + hash = (37 * hash) + RESPONSEID_FIELD_NUMBER;
  265 + hash = (53 * hash) + getResponseId();
  266 + }
  267 + if (hasResMsg()) {
  268 + hash = (37 * hash) + RESMSG_FIELD_NUMBER;
  269 + hash = (53 * hash) + getResMsg().hashCode();
  270 + }
  271 + hash = (29 * hash) + unknownFields.hashCode();
  272 + memoizedHashCode = hash;
  273 + return hash;
  274 + }
  275 +
  276 + public static ResponseProtocol parseFrom(
  277 + java.nio.ByteBuffer data)
  278 + throws com.google.protobuf.InvalidProtocolBufferException {
  279 + return PARSER.parseFrom(data);
  280 + }
  281 + public static ResponseProtocol parseFrom(
  282 + java.nio.ByteBuffer data,
  283 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  284 + throws com.google.protobuf.InvalidProtocolBufferException {
  285 + return PARSER.parseFrom(data, extensionRegistry);
  286 + }
  287 + public static ResponseProtocol parseFrom(
  288 + com.google.protobuf.ByteString data)
  289 + throws com.google.protobuf.InvalidProtocolBufferException {
  290 + return PARSER.parseFrom(data);
  291 + }
  292 + public static ResponseProtocol parseFrom(
  293 + com.google.protobuf.ByteString data,
  294 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  295 + throws com.google.protobuf.InvalidProtocolBufferException {
  296 + return PARSER.parseFrom(data, extensionRegistry);
  297 + }
  298 + public static ResponseProtocol parseFrom(byte[] data)
  299 + throws com.google.protobuf.InvalidProtocolBufferException {
  300 + return PARSER.parseFrom(data);
  301 + }
  302 + public static ResponseProtocol parseFrom(
  303 + byte[] data,
  304 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  305 + throws com.google.protobuf.InvalidProtocolBufferException {
  306 + return PARSER.parseFrom(data, extensionRegistry);
  307 + }
  308 + public static ResponseProtocol parseFrom(java.io.InputStream input)
  309 + throws java.io.IOException {
  310 + return com.google.protobuf.GeneratedMessageV3
  311 + .parseWithIOException(PARSER, input);
  312 + }
  313 + public static ResponseProtocol parseFrom(
  314 + java.io.InputStream input,
  315 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  316 + throws java.io.IOException {
  317 + return com.google.protobuf.GeneratedMessageV3
  318 + .parseWithIOException(PARSER, input, extensionRegistry);
  319 + }
  320 + public static ResponseProtocol parseDelimitedFrom(java.io.InputStream input)
  321 + throws java.io.IOException {
  322 + return com.google.protobuf.GeneratedMessageV3
  323 + .parseDelimitedWithIOException(PARSER, input);
  324 + }
  325 + public static ResponseProtocol parseDelimitedFrom(
  326 + java.io.InputStream input,
  327 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  328 + throws java.io.IOException {
  329 + return com.google.protobuf.GeneratedMessageV3
  330 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  331 + }
  332 + public static ResponseProtocol parseFrom(
  333 + com.google.protobuf.CodedInputStream input)
  334 + throws java.io.IOException {
  335 + return com.google.protobuf.GeneratedMessageV3
  336 + .parseWithIOException(PARSER, input);
  337 + }
  338 + public static ResponseProtocol parseFrom(
  339 + com.google.protobuf.CodedInputStream input,
  340 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  341 + throws java.io.IOException {
  342 + return com.google.protobuf.GeneratedMessageV3
  343 + .parseWithIOException(PARSER, input, extensionRegistry);
  344 + }
  345 +
  346 + public Builder newBuilderForType() { return newBuilder(); }
  347 + public static Builder newBuilder() {
  348 + return DEFAULT_INSTANCE.toBuilder();
  349 + }
  350 + public static Builder newBuilder(ResponseProtocol prototype) {
  351 + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  352 + }
  353 + public Builder toBuilder() {
  354 + return this == DEFAULT_INSTANCE
  355 + ? new Builder() : new Builder().mergeFrom(this);
  356 + }
  357 +
  358 + @Override
  359 + protected Builder newBuilderForType(
  360 + BuilderParent parent) {
  361 + Builder builder = new Builder(parent);
  362 + return builder;
  363 + }
  364 + /**
  365 + * Protobuf type {@code protocol.ResponseProtocol}
  366 + */
  367 + public static final class Builder extends
  368 + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
  369 + // @@protoc_insertion_point(builder_implements:protocol.ResponseProtocol)
  370 + ResponseProtocolOrBuilder {
  371 + public static final com.google.protobuf.Descriptors.Descriptor
  372 + getDescriptor() {
  373 + return BaseResponseProto.internal_static_protocol_ResponseProtocol_descriptor;
  374 + }
  375 +
  376 + protected FieldAccessorTable
  377 + internalGetFieldAccessorTable() {
  378 + return BaseResponseProto.internal_static_protocol_ResponseProtocol_fieldAccessorTable
  379 + .ensureFieldAccessorsInitialized(
  380 + ResponseProtocol.class, Builder.class);
  381 + }
  382 +
  383 + // Construct using com.crossoverjie.netty.action.protocol.BaseResponseProto.ResponseProtocol.newBuilder()
  384 + private Builder() {
  385 + maybeForceBuilderInitialization();
  386 + }
  387 +
  388 + private Builder(
  389 + BuilderParent parent) {
  390 + super(parent);
  391 + maybeForceBuilderInitialization();
  392 + }
  393 + private void maybeForceBuilderInitialization() {
  394 + if (com.google.protobuf.GeneratedMessageV3
  395 + .alwaysUseFieldBuilders) {
  396 + }
  397 + }
  398 + public Builder clear() {
  399 + super.clear();
  400 + responseId_ = 0;
  401 + bitField0_ = (bitField0_ & ~0x00000001);
  402 + resMsg_ = "";
  403 + bitField0_ = (bitField0_ & ~0x00000002);
  404 + return this;
  405 + }
  406 +
  407 + public com.google.protobuf.Descriptors.Descriptor
  408 + getDescriptorForType() {
  409 + return BaseResponseProto.internal_static_protocol_ResponseProtocol_descriptor;
  410 + }
  411 +
  412 + public ResponseProtocol getDefaultInstanceForType() {
  413 + return ResponseProtocol.getDefaultInstance();
  414 + }
  415 +
  416 + public ResponseProtocol build() {
  417 + ResponseProtocol result = buildPartial();
  418 + if (!result.isInitialized()) {
  419 + throw newUninitializedMessageException(result);
  420 + }
  421 + return result;
  422 + }
  423 +
  424 + public ResponseProtocol buildPartial() {
  425 + ResponseProtocol result = new ResponseProtocol(this);
  426 + int from_bitField0_ = bitField0_;
  427 + int to_bitField0_ = 0;
  428 + if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
  429 + to_bitField0_ |= 0x00000001;
  430 + }
  431 + result.responseId_ = responseId_;
  432 + if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
  433 + to_bitField0_ |= 0x00000002;
  434 + }
  435 + result.resMsg_ = resMsg_;
  436 + result.bitField0_ = to_bitField0_;
  437 + onBuilt();
  438 + return result;
  439 + }
  440 +
  441 + public Builder clone() {
  442 + return (Builder) super.clone();
  443 + }
  444 + public Builder setField(
  445 + com.google.protobuf.Descriptors.FieldDescriptor field,
  446 + Object value) {
  447 + return (Builder) super.setField(field, value);
  448 + }
  449 + public Builder clearField(
  450 + com.google.protobuf.Descriptors.FieldDescriptor field) {
  451 + return (Builder) super.clearField(field);
  452 + }
  453 + public Builder clearOneof(
  454 + com.google.protobuf.Descriptors.OneofDescriptor oneof) {
  455 + return (Builder) super.clearOneof(oneof);
  456 + }
  457 + public Builder setRepeatedField(
  458 + com.google.protobuf.Descriptors.FieldDescriptor field,
  459 + int index, Object value) {
  460 + return (Builder) super.setRepeatedField(field, index, value);
  461 + }
  462 + public Builder addRepeatedField(
  463 + com.google.protobuf.Descriptors.FieldDescriptor field,
  464 + Object value) {
  465 + return (Builder) super.addRepeatedField(field, value);
  466 + }
  467 + public Builder mergeFrom(com.google.protobuf.Message other) {
  468 + if (other instanceof ResponseProtocol) {
  469 + return mergeFrom((ResponseProtocol)other);
  470 + } else {
  471 + super.mergeFrom(other);
  472 + return this;
  473 + }
  474 + }
  475 +
  476 + public Builder mergeFrom(ResponseProtocol other) {
  477 + if (other == ResponseProtocol.getDefaultInstance()) return this;
  478 + if (other.hasResponseId()) {
  479 + setResponseId(other.getResponseId());
  480 + }
  481 + if (other.hasResMsg()) {
  482 + bitField0_ |= 0x00000002;
  483 + resMsg_ = other.resMsg_;
  484 + onChanged();
  485 + }
  486 + this.mergeUnknownFields(other.unknownFields);
  487 + onChanged();
  488 + return this;
  489 + }
  490 +
  491 + public final boolean isInitialized() {
  492 + if (!hasResponseId()) {
  493 + return false;
  494 + }
  495 + if (!hasResMsg()) {
  496 + return false;
  497 + }
  498 + return true;
  499 + }
  500 +
  501 + public Builder mergeFrom(
  502 + com.google.protobuf.CodedInputStream input,
  503 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  504 + throws java.io.IOException {
  505 + ResponseProtocol parsedMessage = null;
  506 + try {
  507 + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
  508 + } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  509 + parsedMessage = (ResponseProtocol) e.getUnfinishedMessage();
  510 + throw e.unwrapIOException();
  511 + } finally {
  512 + if (parsedMessage != null) {
  513 + mergeFrom(parsedMessage);
  514 + }
  515 + }
  516 + return this;
  517 + }
  518 + private int bitField0_;
  519 +
  520 + private int responseId_ ;
  521 + /**
  522 + * <code>required int32 responseId = 2;</code>
  523 + */
  524 + public boolean hasResponseId() {
  525 + return ((bitField0_ & 0x00000001) == 0x00000001);
  526 + }
  527 + /**
  528 + * <code>required int32 responseId = 2;</code>
  529 + */
  530 + public int getResponseId() {
  531 + return responseId_;
  532 + }
  533 + /**
  534 + * <code>required int32 responseId = 2;</code>
  535 + */
  536 + public Builder setResponseId(int value) {
  537 + bitField0_ |= 0x00000001;
  538 + responseId_ = value;
  539 + onChanged();
  540 + return this;
  541 + }
  542 + /**
  543 + * <code>required int32 responseId = 2;</code>
  544 + */
  545 + public Builder clearResponseId() {
  546 + bitField0_ = (bitField0_ & ~0x00000001);
  547 + responseId_ = 0;
  548 + onChanged();
  549 + return this;
  550 + }
  551 +
  552 + private Object resMsg_ = "";
  553 + /**
  554 + * <code>required string resMsg = 1;</code>
  555 + */
  556 + public boolean hasResMsg() {
  557 + return ((bitField0_ & 0x00000002) == 0x00000002);
  558 + }
  559 + /**
  560 + * <code>required string resMsg = 1;</code>
  561 + */
  562 + public String getResMsg() {
  563 + Object ref = resMsg_;
  564 + if (!(ref instanceof String)) {
  565 + com.google.protobuf.ByteString bs =
  566 + (com.google.protobuf.ByteString) ref;
  567 + String s = bs.toStringUtf8();
  568 + if (bs.isValidUtf8()) {
  569 + resMsg_ = s;
  570 + }
  571 + return s;
  572 + } else {
  573 + return (String) ref;
  574 + }
  575 + }
  576 + /**
  577 + * <code>required string resMsg = 1;</code>
  578 + */
  579 + public com.google.protobuf.ByteString
  580 + getResMsgBytes() {
  581 + Object ref = resMsg_;
  582 + if (ref instanceof String) {
  583 + com.google.protobuf.ByteString b =
  584 + com.google.protobuf.ByteString.copyFromUtf8(
  585 + (String) ref);
  586 + resMsg_ = b;
  587 + return b;
  588 + } else {
  589 + return (com.google.protobuf.ByteString) ref;
  590 + }
  591 + }
  592 + /**
  593 + * <code>required string resMsg = 1;</code>
  594 + */
  595 + public Builder setResMsg(
  596 + String value) {
  597 + if (value == null) {
  598 + throw new NullPointerException();
  599 + }
  600 + bitField0_ |= 0x00000002;
  601 + resMsg_ = value;
  602 + onChanged();
  603 + return this;
  604 + }
  605 + /**
  606 + * <code>required string resMsg = 1;</code>
  607 + */
  608 + public Builder clearResMsg() {
  609 + bitField0_ = (bitField0_ & ~0x00000002);
  610 + resMsg_ = getDefaultInstance().getResMsg();
  611 + onChanged();
  612 + return this;
  613 + }
  614 + /**
  615 + * <code>required string resMsg = 1;</code>
  616 + */
  617 + public Builder setResMsgBytes(
  618 + com.google.protobuf.ByteString value) {
  619 + if (value == null) {
  620 + throw new NullPointerException();
  621 + }
  622 + bitField0_ |= 0x00000002;
  623 + resMsg_ = value;
  624 + onChanged();
  625 + return this;
  626 + }
  627 + public final Builder setUnknownFields(
  628 + final com.google.protobuf.UnknownFieldSet unknownFields) {
  629 + return super.setUnknownFields(unknownFields);
  630 + }
  631 +
  632 + public final Builder mergeUnknownFields(
  633 + final com.google.protobuf.UnknownFieldSet unknownFields) {
  634 + return super.mergeUnknownFields(unknownFields);
  635 + }
  636 +
  637 +
  638 + // @@protoc_insertion_point(builder_scope:protocol.ResponseProtocol)
  639 + }
  640 +
  641 + // @@protoc_insertion_point(class_scope:protocol.ResponseProtocol)
  642 + private static final ResponseProtocol DEFAULT_INSTANCE;
  643 + static {
  644 + DEFAULT_INSTANCE = new ResponseProtocol();
  645 + }
  646 +
  647 + public static ResponseProtocol getDefaultInstance() {
  648 + return DEFAULT_INSTANCE;
  649 + }
  650 +
  651 + @Deprecated public static final com.google.protobuf.Parser<ResponseProtocol>
  652 + PARSER = new com.google.protobuf.AbstractParser<ResponseProtocol>() {
  653 + public ResponseProtocol parsePartialFrom(
  654 + com.google.protobuf.CodedInputStream input,
  655 + com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  656 + throws com.google.protobuf.InvalidProtocolBufferException {
  657 + return new ResponseProtocol(input, extensionRegistry);
  658 + }
  659 + };
  660 +
  661 + public static com.google.protobuf.Parser<ResponseProtocol> parser() {
  662 + return PARSER;
  663 + }
  664 +
  665 + @Override
  666 + public com.google.protobuf.Parser<ResponseProtocol> getParserForType() {
  667 + return PARSER;
  668 + }
  669 +
  670 + public ResponseProtocol getDefaultInstanceForType() {
  671 + return DEFAULT_INSTANCE;
  672 + }
  673 +
  674 + }
  675 +
  676 + private static final com.google.protobuf.Descriptors.Descriptor
  677 + internal_static_protocol_ResponseProtocol_descriptor;
  678 + private static final
  679 + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
  680 + internal_static_protocol_ResponseProtocol_fieldAccessorTable;
  681 +
  682 + public static com.google.protobuf.Descriptors.FileDescriptor
  683 + getDescriptor() {
  684 + return descriptor;
  685 + }
  686 + private static com.google.protobuf.Descriptors.FileDescriptor
  687 + descriptor;
  688 + static {
  689 + String[] descriptorData = {
  690 + "\n\027BaseResponseProto.proto\022\010protocol\"6\n\020R" +
  691 + "esponseProtocol\022\022\n\nresponseId\030\002 \002(\005\022\016\n\006r" +
  692 + "esMsg\030\001 \002(\tB;\n&com.crossoverjie.netty.ac" +
  693 + "tion.protocolB\021BaseResponseProto"
  694 + };
  695 + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
  696 + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
  697 + public com.google.protobuf.ExtensionRegistry assignDescriptors(
  698 + com.google.protobuf.Descriptors.FileDescriptor root) {
  699 + descriptor = root;
  700 + return null;
  701 + }
  702 + };
  703 + com.google.protobuf.Descriptors.FileDescriptor
  704 + .internalBuildGeneratedFileFrom(descriptorData,
  705 + new com.google.protobuf.Descriptors.FileDescriptor[] {
  706 + }, assigner);
  707 + internal_static_protocol_ResponseProtocol_descriptor =
  708 + getDescriptor().getMessageTypes().get(0);
  709 + internal_static_protocol_ResponseProtocol_fieldAccessorTable = new
  710 + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
  711 + internal_static_protocol_ResponseProtocol_descriptor,
  712 + new String[] { "ResponseId", "ResMsg", });
  713 + }
  714 +
  715 + // @@protoc_insertion_point(outer_class_scope)
  716 +}
  1 +package com.crossoverjie.netty.action.common.protocol;
  2 +
  3 +import com.google.protobuf.InvalidProtocolBufferException;
  4 +
  5 +/**
  6 + * Function:
  7 + *
  8 + * @author crossoverJie
  9 + * Date: 2018/8/1 12:24
  10 + * @since JDK 1.8
  11 + */
  12 +public class ProtocolUtil {
  13 +
  14 + public static void main(String[] args) throws InvalidProtocolBufferException {
  15 + BaseRequestProto.RequestProtocol protocol = BaseRequestProto.RequestProtocol.newBuilder()
  16 + .setRequestId(123)
  17 + .setReqMsg("你好啊")
  18 + .build();
  19 +
  20 + byte[] encode = encode(protocol);
  21 +
  22 + BaseRequestProto.RequestProtocol parseFrom = decode(encode);
  23 +
  24 + System.out.println(protocol.toString());
  25 + System.out.println(protocol.toString().equals(parseFrom.toString()));
  26 + }
  27 +
  28 + /**
  29 + * 编码
  30 + * @param protocol
  31 + * @return
  32 + */
  33 + public static byte[] encode(BaseRequestProto.RequestProtocol protocol){
  34 + return protocol.toByteArray() ;
  35 + }
  36 +
  37 + /**
  38 + * 解码
  39 + * @param bytes
  40 + * @return
  41 + * @throws InvalidProtocolBufferException
  42 + */
  43 + public static BaseRequestProto.RequestProtocol decode(byte[] bytes) throws InvalidProtocolBufferException {
  44 + return BaseRequestProto.RequestProtocol.parseFrom(bytes);
  45 + }
  46 +}
@@ -22,6 +22,12 @@ @@ -22,6 +22,12 @@
22 22
23 <dependencies> 23 <dependencies>
24 24
  25 +
  26 + <dependency>
  27 + <groupId>com.google.protobuf</groupId>
  28 + <artifactId>protobuf-java</artifactId>
  29 + </dependency>
  30 +
25 <dependency> 31 <dependency>
26 <groupId>com.crossoverjie.netty</groupId> 32 <groupId>com.crossoverjie.netty</groupId>
27 <artifactId>netty-action-common</artifactId> 33 <artifactId>netty-action-common</artifactId>
@@ -2,8 +2,12 @@ package com.crossoverjie.netty.action.client; @@ -2,8 +2,12 @@ package com.crossoverjie.netty.action.client;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.crossoverjie.netty.action.client.init.CustomerHandleInitializer; 4 import com.crossoverjie.netty.action.client.init.CustomerHandleInitializer;
  5 +import com.crossoverjie.netty.action.client.vo.req.GoogleProtocolVO;
5 import com.crossoverjie.netty.action.common.pojo.CustomProtocol; 6 import com.crossoverjie.netty.action.common.pojo.CustomProtocol;
  7 +import com.crossoverjie.netty.action.common.protocol.BaseRequestProto;
6 import io.netty.bootstrap.Bootstrap; 8 import io.netty.bootstrap.Bootstrap;
  9 +import io.netty.buffer.ByteBuf;
  10 +import io.netty.buffer.Unpooled;
7 import io.netty.channel.ChannelFuture; 11 import io.netty.channel.ChannelFuture;
8 import io.netty.channel.ChannelFutureListener; 12 import io.netty.channel.ChannelFutureListener;
9 import io.netty.channel.EventLoopGroup; 13 import io.netty.channel.EventLoopGroup;
@@ -66,4 +70,36 @@ public class HeartbeatClient { @@ -66,4 +70,36 @@ public class HeartbeatClient {
66 LOGGER.info("客户端手动发消息成功={}", JSON.toJSONString(customProtocol))); 70 LOGGER.info("客户端手动发消息成功={}", JSON.toJSONString(customProtocol)));
67 71
68 } 72 }
  73 + /**
  74 + * 发送消息字符串
  75 + *
  76 + * @param msg
  77 + */
  78 + public void sendStringMsg(String msg) {
  79 + ByteBuf message = Unpooled.buffer(msg.getBytes().length) ;
  80 + message.writeBytes(msg.getBytes()) ;
  81 + ChannelFuture future = channel.writeAndFlush(message);
  82 + future.addListener((ChannelFutureListener) channelFuture ->
  83 + LOGGER.info("客户端手动发消息成功={}", msg));
  84 +
  85 + }
  86 +
  87 + /**
  88 + * 发送 Google Protocol 编解码字符串
  89 + *
  90 + * @param googleProtocolVO
  91 + */
  92 + public void sendGoogleProtocolMsg(GoogleProtocolVO googleProtocolVO) {
  93 +
  94 + BaseRequestProto.RequestProtocol protocol = BaseRequestProto.RequestProtocol.newBuilder()
  95 + .setRequestId(googleProtocolVO.getRequestId())
  96 + .setReqMsg(googleProtocolVO.getMsg())
  97 + .build();
  98 +
  99 +
  100 + ChannelFuture future = channel.writeAndFlush(protocol);
  101 + future.addListener((ChannelFutureListener) channelFuture ->
  102 + LOGGER.info("客户端手动发送 Google Protocol 成功={}", googleProtocolVO.toString()));
  103 +
  104 + }
69 } 105 }
1 package com.crossoverjie.netty.action.client.controller; 1 package com.crossoverjie.netty.action.client.controller;
2 2
3 import com.crossoverjie.netty.action.client.HeartbeatClient; 3 import com.crossoverjie.netty.action.client.HeartbeatClient;
  4 +import com.crossoverjie.netty.action.client.vo.req.GoogleProtocolVO;
4 import com.crossoverjie.netty.action.client.vo.req.SendMsgReqVO; 5 import com.crossoverjie.netty.action.client.vo.req.SendMsgReqVO;
  6 +import com.crossoverjie.netty.action.client.vo.req.StringReqVO;
5 import com.crossoverjie.netty.action.client.vo.res.SendMsgResVO; 7 import com.crossoverjie.netty.action.client.vo.res.SendMsgResVO;
6 import com.crossoverjie.netty.action.common.constant.Constants; 8 import com.crossoverjie.netty.action.common.constant.Constants;
7 import com.crossoverjie.netty.action.common.enums.StatusEnum; 9 import com.crossoverjie.netty.action.common.enums.StatusEnum;
8 import com.crossoverjie.netty.action.common.pojo.CustomProtocol; 10 import com.crossoverjie.netty.action.common.pojo.CustomProtocol;
9 import com.crossoverjie.netty.action.common.res.BaseResponse; 11 import com.crossoverjie.netty.action.common.res.BaseResponse;
10 -import com.crossoverjie.netty.action.common.util.RandomUtil; 12 +import com.crossoverjie.netty.action.common.res.NULLBody;
11 import io.swagger.annotations.ApiOperation; 13 import io.swagger.annotations.ApiOperation;
12 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.boot.actuate.metrics.CounterService; 15 import org.springframework.boot.actuate.metrics.CounterService;
14 import org.springframework.stereotype.Controller; 16 import org.springframework.stereotype.Controller;
15 import org.springframework.web.bind.annotation.RequestBody; 17 import org.springframework.web.bind.annotation.RequestBody;
16 import org.springframework.web.bind.annotation.RequestMapping; 18 import org.springframework.web.bind.annotation.RequestMapping;
  19 +import org.springframework.web.bind.annotation.RequestMethod;
17 import org.springframework.web.bind.annotation.ResponseBody; 20 import org.springframework.web.bind.annotation.ResponseBody;
18 21
19 /** 22 /**
@@ -42,8 +45,8 @@ public class IndexController { @@ -42,8 +45,8 @@ public class IndexController {
42 * @return 45 * @return
43 */ 46 */
44 @ApiOperation("客户端发送消息") 47 @ApiOperation("客户端发送消息")
45 - @RequestMapping("sendMsg")  
46 - @ResponseBody 48 + @RequestMapping(value = "sendMsg",method = RequestMethod.POST)
  49 + @ResponseBody()
47 public BaseResponse<SendMsgResVO> sendMsg(@RequestBody SendMsgReqVO sendMsgReqVO){ 50 public BaseResponse<SendMsgResVO> sendMsg(@RequestBody SendMsgReqVO sendMsgReqVO){
48 BaseResponse<SendMsgResVO> res = new BaseResponse(); 51 BaseResponse<SendMsgResVO> res = new BaseResponse();
49 heartbeatClient.sendMsg(new CustomProtocol(sendMsgReqVO.getId(),sendMsgReqVO.getMsg())) ; 52 heartbeatClient.sendMsg(new CustomProtocol(sendMsgReqVO.getId(),sendMsgReqVO.getMsg())) ;
@@ -58,4 +61,54 @@ public class IndexController { @@ -58,4 +61,54 @@ public class IndexController {
58 res.setDataBody(sendMsgResVO) ; 61 res.setDataBody(sendMsgResVO) ;
59 return res ; 62 return res ;
60 } 63 }
  64 +
  65 + /**
  66 + * 向服务端发消息 字符串
  67 + * @param stringReqVO
  68 + * @return
  69 + */
  70 + @ApiOperation("客户端发送消息,字符串")
  71 + @RequestMapping(value = "sendStringMsg", method = RequestMethod.POST)
  72 + @ResponseBody
  73 + public BaseResponse<NULLBody> sendStringMsg(@RequestBody StringReqVO stringReqVO){
  74 + BaseResponse<NULLBody> res = new BaseResponse();
  75 +
  76 + for (int i = 0; i < 100; i++) {
  77 + heartbeatClient.sendStringMsg(stringReqVO.getMsg()) ;
  78 + }
  79 +
  80 + // 利用 actuator 来自增
  81 + counterService.increment(Constants.COUNTER_CLIENT_PUSH_COUNT);
  82 +
  83 + SendMsgResVO sendMsgResVO = new SendMsgResVO() ;
  84 + sendMsgResVO.setMsg("OK") ;
  85 + res.setCode(StatusEnum.SUCCESS.getCode()) ;
  86 + res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
  87 + return res ;
  88 + }
  89 +
  90 + /**
  91 + * 向服务端发消息 Google ProtoBuf
  92 + * @param googleProtocolVO
  93 + * @return
  94 + */
  95 + @ApiOperation("向服务端发消息 Google ProtoBuf")
  96 + @RequestMapping(value = "sendProtoBufMsg", method = RequestMethod.POST)
  97 + @ResponseBody
  98 + public BaseResponse<NULLBody> sendProtoBufMsg(@RequestBody GoogleProtocolVO googleProtocolVO){
  99 + BaseResponse<NULLBody> res = new BaseResponse();
  100 +
  101 + for (int i = 0; i < 100; i++) {
  102 + heartbeatClient.sendGoogleProtocolMsg(googleProtocolVO) ;
  103 + }
  104 +
  105 + // 利用 actuator 来自增
  106 + counterService.increment(Constants.COUNTER_CLIENT_PUSH_COUNT);
  107 +
  108 + SendMsgResVO sendMsgResVO = new SendMsgResVO() ;
  109 + sendMsgResVO.setMsg("OK") ;
  110 + res.setCode(StatusEnum.SUCCESS.getCode()) ;
  111 + res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
  112 + return res ;
  113 + }
61 } 114 }
1 package com.crossoverjie.netty.action.client.handle; 1 package com.crossoverjie.netty.action.client.handle;
2 2
3 -import com.crossoverjie.netty.action.client.util.SpringBeanFactory;  
4 -import com.crossoverjie.netty.action.common.pojo.CustomProtocol;  
5 -import io.netty.buffer.ByteBuf;  
6 -import io.netty.buffer.Unpooled;  
7 -import io.netty.channel.ChannelFutureListener; 3 +import com.crossoverjie.netty.action.common.protocol.BaseResponseProto;
8 import io.netty.channel.ChannelHandlerContext; 4 import io.netty.channel.ChannelHandlerContext;
9 import io.netty.channel.SimpleChannelInboundHandler; 5 import io.netty.channel.SimpleChannelInboundHandler;
10 -import io.netty.handler.timeout.IdleState;  
11 -import io.netty.handler.timeout.IdleStateEvent;  
12 -import io.netty.util.CharsetUtil;  
13 import org.slf4j.Logger; 6 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory; 7 import org.slf4j.LoggerFactory;
15 8
@@ -20,7 +13,7 @@ import org.slf4j.LoggerFactory; @@ -20,7 +13,7 @@ import org.slf4j.LoggerFactory;
20 * Date: 16/02/2018 18:09 13 * Date: 16/02/2018 18:09
21 * @since JDK 1.8 14 * @since JDK 1.8
22 */ 15 */
23 -public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> { 16 +public class EchoClientHandle extends SimpleChannelInboundHandler<BaseResponseProto.ResponseProtocol> {
24 17
25 private final static Logger LOGGER = LoggerFactory.getLogger(EchoClientHandle.class); 18 private final static Logger LOGGER = LoggerFactory.getLogger(EchoClientHandle.class);
26 19
@@ -29,7 +22,7 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> { @@ -29,7 +22,7 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> {
29 @Override 22 @Override
30 public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { 23 public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
31 24
32 - if (evt instanceof IdleStateEvent){ 25 + /*if (evt instanceof IdleStateEvent){
33 IdleStateEvent idleStateEvent = (IdleStateEvent) evt ; 26 IdleStateEvent idleStateEvent = (IdleStateEvent) evt ;
34 27
35 if (idleStateEvent.state() == IdleState.WRITER_IDLE){ 28 if (idleStateEvent.state() == IdleState.WRITER_IDLE){
@@ -40,7 +33,7 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> { @@ -40,7 +33,7 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> {
40 } 33 }
41 34
42 35
43 - } 36 + }*/
44 37
45 super.userEventTriggered(ctx, evt); 38 super.userEventTriggered(ctx, evt);
46 } 39 }
@@ -53,11 +46,12 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> { @@ -53,11 +46,12 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> {
53 } 46 }
54 47
55 @Override 48 @Override
56 - protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf in) throws Exception { 49 + protected void channelRead0(ChannelHandlerContext channelHandlerContext, BaseResponseProto.ResponseProtocol responseProtocol) throws Exception {
57 50
58 //从服务端收到消息时被调用 51 //从服务端收到消息时被调用
59 - LOGGER.info("客户端收到消息={}",in.toString(CharsetUtil.UTF_8)) ; 52 + //LOGGER.info("客户端收到消息={}",in.toString(CharsetUtil.UTF_8)) ;
60 53
  54 + LOGGER.info("客户端收到消息={}" ,responseProtocol.getResMsg());
61 } 55 }
62 56
63 @Override 57 @Override
1 package com.crossoverjie.netty.action.client.init; 1 package com.crossoverjie.netty.action.client.init;
2 2
3 -import com.crossoverjie.netty.action.client.encode.HeartbeatEncode;  
4 import com.crossoverjie.netty.action.client.handle.EchoClientHandle; 3 import com.crossoverjie.netty.action.client.handle.EchoClientHandle;
  4 +import com.crossoverjie.netty.action.common.protocol.BaseResponseProto;
5 import io.netty.channel.Channel; 5 import io.netty.channel.Channel;
6 import io.netty.channel.ChannelInitializer; 6 import io.netty.channel.ChannelInitializer;
  7 +import io.netty.handler.codec.protobuf.ProtobufDecoder;
  8 +import io.netty.handler.codec.protobuf.ProtobufEncoder;
  9 +import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
  10 +import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
7 import io.netty.handler.timeout.IdleStateHandler; 11 import io.netty.handler.timeout.IdleStateHandler;
8 12
9 /** 13 /**
@@ -19,7 +23,20 @@ public class CustomerHandleInitializer extends ChannelInitializer<Channel> { @@ -19,7 +23,20 @@ public class CustomerHandleInitializer extends ChannelInitializer<Channel> {
19 ch.pipeline() 23 ch.pipeline()
20 //10 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中 24 //10 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中
21 .addLast(new IdleStateHandler(0, 10, 0)) 25 .addLast(new IdleStateHandler(0, 10, 0))
22 - .addLast(new HeartbeatEncode()) 26 +
  27 + //心跳解码
  28 + //.addLast(new HeartbeatEncode())
  29 +
  30 + // google Protobuf 编解码
  31 + //拆包解码
  32 + .addLast(new ProtobufVarint32FrameDecoder())
  33 + .addLast(new ProtobufDecoder(BaseResponseProto.ResponseProtocol.getDefaultInstance()))
  34 + //
  35 + //拆包编码
  36 + .addLast(new ProtobufVarint32LengthFieldPrepender())
  37 + .addLast(new ProtobufEncoder())
  38 +
  39 +
23 .addLast(new EchoClientHandle()) 40 .addLast(new EchoClientHandle())
24 ; 41 ;
25 } 42 }
  1 +package com.crossoverjie.netty.action.client.vo.req;
  2 +
  3 +import com.crossoverjie.netty.action.common.req.BaseRequest;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +
  6 +import javax.validation.constraints.NotNull;
  7 +
  8 +/**
  9 + * Function: Google Protocol 编解码发送
  10 + *
  11 + * @author crossoverJie
  12 + * Date: 2018/05/21 15:56
  13 + * @since JDK 1.8
  14 + */
  15 +public class GoogleProtocolVO extends BaseRequest {
  16 + @NotNull(message = "requestId 不能为空")
  17 + @ApiModelProperty(required = true, value = "requestId", example = "123")
  18 + private Integer requestId ;
  19 +
  20 + @NotNull(message = "msg 不能为空")
  21 + @ApiModelProperty(required = true, value = "msg", example = "hello")
  22 + private String msg ;
  23 +
  24 + public String getMsg() {
  25 + return msg;
  26 + }
  27 +
  28 + public void setMsg(String msg) {
  29 + this.msg = msg;
  30 + }
  31 +
  32 + public Integer getRequestId() {
  33 + return requestId;
  34 + }
  35 +
  36 + public void setRequestId(Integer requestId) {
  37 + this.requestId = requestId;
  38 + }
  39 +
  40 + @Override
  41 + public String toString() {
  42 + return "GoogleProtocolVO{" +
  43 + "requestId=" + requestId +
  44 + ", msg='" + msg + '\'' +
  45 + "} " + super.toString();
  46 + }
  47 +}
  1 +package com.crossoverjie.netty.action.client.vo.req;
  2 +
  3 +import com.crossoverjie.netty.action.common.req.BaseRequest;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +
  6 +import javax.validation.constraints.NotNull;
  7 +
  8 +/**
  9 + * Function:
  10 + *
  11 + * @author crossoverJie
  12 + * Date: 2018/05/21 15:56
  13 + * @since JDK 1.8
  14 + */
  15 +public class StringReqVO extends BaseRequest {
  16 +
  17 + @NotNull(message = "msg 不能为空")
  18 + @ApiModelProperty(required = true, value = "msg", example = "hello")
  19 + private String msg ;
  20 +
  21 + public String getMsg() {
  22 + return msg;
  23 + }
  24 +
  25 + public void setMsg(String msg) {
  26 + this.msg = msg;
  27 + }
  28 +}
@@ -11,6 +11,7 @@ netty.server.port=11211 @@ -11,6 +11,7 @@ netty.server.port=11211
11 11
12 logging.level.root=info 12 logging.level.root=info
13 13
  14 +# 通道 ID
14 channel.id=100 15 channel.id=100
15 16
16 17
@@ -22,6 +22,11 @@ @@ -22,6 +22,11 @@
22 <dependencies> 22 <dependencies>
23 23
24 <dependency> 24 <dependency>
  25 + <groupId>com.google.protobuf</groupId>
  26 + <artifactId>protobuf-java</artifactId>
  27 + </dependency>
  28 +
  29 + <dependency>
25 <groupId>com.crossoverjie.netty</groupId> 30 <groupId>com.crossoverjie.netty</groupId>
26 <artifactId>netty-action-common</artifactId> 31 <artifactId>netty-action-common</artifactId>
27 </dependency> 32 </dependency>
1 package com.crossoverjie.netty.action.handle; 1 package com.crossoverjie.netty.action.handle;
2 2
3 import com.crossoverjie.netty.action.common.pojo.CustomProtocol; 3 import com.crossoverjie.netty.action.common.pojo.CustomProtocol;
4 -import com.crossoverjie.netty.action.common.util.RandomUtil; 4 +import com.crossoverjie.netty.action.common.protocol.BaseRequestProto;
  5 +import com.crossoverjie.netty.action.common.protocol.BaseResponseProto;
5 import com.crossoverjie.netty.action.util.NettySocketHolder; 6 import com.crossoverjie.netty.action.util.NettySocketHolder;
6 import io.netty.buffer.ByteBuf; 7 import io.netty.buffer.ByteBuf;
7 import io.netty.buffer.Unpooled; 8 import io.netty.buffer.Unpooled;
8 -import io.netty.channel.ChannelFutureListener;  
9 import io.netty.channel.ChannelHandlerContext; 9 import io.netty.channel.ChannelHandlerContext;
10 import io.netty.channel.SimpleChannelInboundHandler; 10 import io.netty.channel.SimpleChannelInboundHandler;
11 -import io.netty.channel.socket.SocketChannel;  
12 -import io.netty.channel.socket.nio.NioServerSocketChannel;  
13 import io.netty.channel.socket.nio.NioSocketChannel; 11 import io.netty.channel.socket.nio.NioSocketChannel;
14 -import io.netty.handler.timeout.IdleState;  
15 -import io.netty.handler.timeout.IdleStateEvent;  
16 import io.netty.util.CharsetUtil; 12 import io.netty.util.CharsetUtil;
17 import org.slf4j.Logger; 13 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory; 14 import org.slf4j.LoggerFactory;
@@ -24,7 +20,7 @@ import org.slf4j.LoggerFactory; @@ -24,7 +20,7 @@ import org.slf4j.LoggerFactory;
24 * Date: 17/05/2018 18:52 20 * Date: 17/05/2018 18:52
25 * @since JDK 1.8 21 * @since JDK 1.8
26 */ 22 */
27 -public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<CustomProtocol> { 23 +public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<BaseRequestProto.RequestProtocol> {
28 24
29 private final static Logger LOGGER = LoggerFactory.getLogger(HeartBeatSimpleHandle.class); 25 private final static Logger LOGGER = LoggerFactory.getLogger(HeartBeatSimpleHandle.class);
30 26
@@ -45,7 +41,7 @@ public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<CustomPro @@ -45,7 +41,7 @@ public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<CustomPro
45 @Override 41 @Override
46 public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { 42 public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
47 43
48 - if (evt instanceof IdleStateEvent){ 44 + /*if (evt instanceof IdleStateEvent){
49 IdleStateEvent idleStateEvent = (IdleStateEvent) evt ; 45 IdleStateEvent idleStateEvent = (IdleStateEvent) evt ;
50 46
51 if (idleStateEvent.state() == IdleState.READER_IDLE){ 47 if (idleStateEvent.state() == IdleState.READER_IDLE){
@@ -55,16 +51,24 @@ public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<CustomPro @@ -55,16 +51,24 @@ public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<CustomPro
55 } 51 }
56 52
57 53
58 - } 54 + }*/
59 55
60 super.userEventTriggered(ctx, evt); 56 super.userEventTriggered(ctx, evt);
61 } 57 }
62 58
63 @Override 59 @Override
64 - protected void channelRead0(ChannelHandlerContext ctx, CustomProtocol customProtocol) throws Exception {  
65 - LOGGER.info("收到customProtocol={}", customProtocol); 60 + protected void channelRead0(ChannelHandlerContext ctx, BaseRequestProto.RequestProtocol msg) throws Exception {
  61 + LOGGER.info("收到msg={}", msg.getReqMsg());
  62 +
  63 + if (999 == msg.getRequestId()){
  64 + BaseResponseProto.ResponseProtocol responseProtocol = BaseResponseProto.ResponseProtocol.newBuilder()
  65 + .setResponseId(1000)
  66 + .setResMsg("服务端响应")
  67 + .build();
  68 + ctx.writeAndFlush(responseProtocol) ;
  69 + }
66 70
67 //保存客户端与 Channel 之间的关系 71 //保存客户端与 Channel 之间的关系
68 - NettySocketHolder.put(customProtocol.getId(),(NioSocketChannel)ctx.channel()) ; 72 + //NettySocketHolder.put(CustomProtocolProtocol.getId(),(NioSocketChannel)ctx.channel()) ;
69 } 73 }
70 } 74 }
1 package com.crossoverjie.netty.action.init; 1 package com.crossoverjie.netty.action.init;
2 2
  3 +import com.crossoverjie.netty.action.common.protocol.BaseRequestProto;
3 import com.crossoverjie.netty.action.handle.HeartBeatSimpleHandle; 4 import com.crossoverjie.netty.action.handle.HeartBeatSimpleHandle;
4 -import com.crossoverjie.netty.action.decoder.HeartbeatDecoder;  
5 import io.netty.channel.Channel; 5 import io.netty.channel.Channel;
6 import io.netty.channel.ChannelInitializer; 6 import io.netty.channel.ChannelInitializer;
  7 +import io.netty.handler.codec.protobuf.ProtobufDecoder;
  8 +import io.netty.handler.codec.protobuf.ProtobufEncoder;
  9 +import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
  10 +import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
7 import io.netty.handler.timeout.IdleStateHandler; 11 import io.netty.handler.timeout.IdleStateHandler;
8 12
9 /** 13 /**
@@ -19,7 +23,18 @@ public class HeartbeatInitializer extends ChannelInitializer<Channel> { @@ -19,7 +23,18 @@ public class HeartbeatInitializer extends ChannelInitializer<Channel> {
19 ch.pipeline() 23 ch.pipeline()
20 //五秒没有收到消息 将IdleStateHandler 添加到 ChannelPipeline 中 24 //五秒没有收到消息 将IdleStateHandler 添加到 ChannelPipeline 中
21 .addLast(new IdleStateHandler(5, 0, 0)) 25 .addLast(new IdleStateHandler(5, 0, 0))
22 - .addLast(new HeartbeatDecoder()) 26 + //.addLast(new HeartbeatDecoder())
  27 +
  28 + //字符串解析,换行防拆包
  29 + //.addLast(new LineBasedFrameDecoder(1024))
  30 + //.addLast(new StringDecoder())
  31 +
  32 + // google Protobuf 编解码
  33 + .addLast(new ProtobufVarint32FrameDecoder())
  34 + .addLast(new ProtobufDecoder(BaseRequestProto.RequestProtocol.getDefaultInstance()))
  35 + .addLast(new ProtobufVarint32LengthFieldPrepender())
  36 + .addLast(new ProtobufEncoder())
  37 +
23 .addLast(new HeartBeatSimpleHandle()); 38 .addLast(new HeartBeatSimpleHandle());
24 } 39 }
25 } 40 }
@@ -43,6 +43,13 @@ @@ -43,6 +43,13 @@
43 <version>1.0.0-SNAPSHOT</version> 43 <version>1.0.0-SNAPSHOT</version>
44 </dependency> 44 </dependency>
45 45
  46 + <dependency>
  47 + <groupId>com.google.protobuf</groupId>
  48 + <artifactId>protobuf-java</artifactId>
  49 + <version>3.4.0</version>
  50 + </dependency>
  51 +
  52 +
46 53
47 <dependency> 54 <dependency>
48 <groupId>io.springfox</groupId> 55 <groupId>io.springfox</groupId>