diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..190ca23229f034871886a6c025f1f5475756ca94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Created by .ignore support plugin (hsz.mobi) +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +target/classes/system.dest.properties +target/generated-sources/ +target/generated-test-sources/ +.idea/ +target/ diff --git a/chat/pom.xml b/chat/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f0a6fde45ea04256c14a4200aeb8a2bca142b148 --- /dev/null +++ b/chat/pom.xml @@ -0,0 +1,203 @@ + + + + my_netty + com.zpf + 1.0-SNAPSHOT + + 4.0.0 + + chat + + + UTF-8 + 1.8 + 1.4.3.RELEASE + + + 4.0.33.Final + 3.6.1 + 1.8 + 1.8 + + 2.10.0 + 17.0 + 1.0 + 3.0.3 + 4.3.11.RELEASE + 1.2.29 + 4.1.0-incubating + + + + + + + + junit + junit + 4.11 + + + + org.springframework.boot + spring-boot-starter + ${springboot} + + + + + org.springframework.boot + spring-boot-starter-test + ${springboot} + + + + + org.springframework.boot + spring-boot-devtools + ${springboot} + true + + + + + + org.apache.zookeeper + zookeeper + 3.4.8 + + + + org.apache.curator + curator-com.zpf.imClient.command.client + 4.0.0 + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.curator + curator-framework + 4.0.0 + + + org.apache.zookeeper + zookeeper + + + + + org.apache.curator + curator-recipes + 4.0.0 + + + + + redis.clients + jedis + 2.9.0 + + + + org.apache.commons + commons-pool2 + 2.6.0 + + + + org.springframework.data + spring-data-redis + ${springboot} + + + + io.netty + netty-all + ${netty.version} + + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + + com.google.code.gson + gson + 2.3.1 + + + + commons-lang + commons-lang + 2.6 + + + + org.projectlombok + lombok + 1.16.10 + + + + + com.google.guava + guava + ${guava.version} + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.0 + true + + + ${project.basedir}/proto/protoConfig + + + ${project.build.sourceDirectory} + + false + + ${project.build.directory}/protoc-temp + + + ${project.basedir}/proto/protobin/protoc-3.6.0-win32/bin/protoc.exe + + + + + compile + test-compile + + + + + + + + + + \ No newline at end of file diff --git a/chat/proto/protoConfig/ProtoMsg.proto b/chat/proto/protoConfig/ProtoMsg.proto new file mode 100644 index 0000000000000000000000000000000000000000..c0c3d1f770eb117b28bbd376c978667539640b9d --- /dev/null +++ b/chat/proto/protoConfig/ProtoMsg.proto @@ -0,0 +1,77 @@ +syntax = "proto3"; +package com.zpf.im.common.bean.msg; + + +enum HeadType { + LOGIN_REQUEST = 0; + LOGIN_RESPONSE = 1; + LOGOUT_REQUEST = 2; + LOGOUT_RESPONSE = 3; + KEEPALIVE_REQUEST = 4; + KEEPALIVE_RESPONSE = 5; + MESSAGE_REQUEST = 6; + MESSAGE_RESPONSE = 7; + MESSAGE_NOTIFICATION = 8; +} + + +message LoginRequest { + string uid = 1; + string deviceId = 2; + string token = 3; + uint32 platform = 4; + string app_version = 5; +} + +message LoginResponse { + bool result = 1; + uint32 code = 2; + string info = 3; + uint32 expose = 4; +} + + +message MessageRequest { + uint64 msg_id = 1; + string from = 2; + string to = 3; + uint64 time = 4; + uint32 msg_type = 5; + string content = 6; + string url = 8; + string property = 9; + string from_nick = 10; + string json = 11; +} + + +message MessageResponse { + bool result = 1; + uint32 code = 2; + string info = 3; + uint32 expose = 4; + bool last_block = 5; + fixed32 block_index = 6; +} + + +message MessageNotification { + uint32 msg_type = 1; + bytes sender = 2; + string json = 3; + string timestamp = 4; +} + + +message Message { + HeadType type = 1; + uint64 sequence = 2; + string session_id = 3; + LoginRequest loginRequest = 4; + LoginResponse loginResponse = 5; + MessageRequest messageRequest = 6; + MessageResponse messageResponse = 7; + MessageNotification notification = 8; +} + + diff --git a/chat/src/main/java/com/zpf/im/common/ProtoInstant.java b/chat/src/main/java/com/zpf/im/common/ProtoInstant.java new file mode 100644 index 0000000000000000000000000000000000000000..4bd0e78e8716a56c7bd0ef9ffe60f5050bf14dc4 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/ProtoInstant.java @@ -0,0 +1,69 @@ +package com.zpf.im.common; + +public class ProtoInstant { + /** + * 魔数 + */ + public static final short MAGIC_CODE = 0x86; + + /** + * 版本号 + */ + + public static final short VERSION_CODE = 0x01; + + /** + * 客户端平台 + */ + + public interface PlatForm{ + + public static final int WINDOWS = 1; + + public static final int MAC = 2; + + public static final int ANDROID = 3; + + public static final int IOS = 4; + + public static final int WEB = 5; + + public static final int UNKNOWN = 6; + } + + /** + * 返回枚举类 + */ + public enum ResultCodeEnum{ + SUCCESS(0,"登录成功"), + AUTH_FAILED(1,"登录失败"), + NO_TOKEN(2,"没有授权码"), + UNKNOW_ERROR(3,"未知错误") + ; + + private Integer code; + private String desc; + + ResultCodeEnum(Integer code,String desc){ + this.code = code; + this.desc = desc; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + } +} diff --git a/chat/src/main/java/com/zpf/im/common/bean/msg/ChatMsg.java b/chat/src/main/java/com/zpf/im/common/bean/msg/ChatMsg.java new file mode 100644 index 0000000000000000000000000000000000000000..9974248450a08d335f34bcbd89a7400c0c9e9900 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/bean/msg/ChatMsg.java @@ -0,0 +1,78 @@ +package com.zpf.im.common.bean.msg; + +import lombok.Data; +import org.apache.commons.lang.StringUtils; + +@Data +public class ChatMsg { + + + //消息类型 1:纯文本 2:音频 3:视频 4:地理位置 5:其他 + public enum MSGTYPE { + TEXT, + AUDIO, + VIDEO, + POS, + OTHER; + } + + public ChatMsg(User user) { + if (null == user) { + return; + } + this.user = user; + this.setTime(System.currentTimeMillis()); + this.setFrom(user.getUid()); + this.setFromNick(user.getNickName()); + + } + + private User user; + + private long msgId; + private String from; + private String to; + private long time; + private MSGTYPE msgType; + private String content; + private String url; //多媒体地址 + private String property; //附加属性 + private String fromNick; //发送者昵称 + private String json; //附加的json串 + + + public void fillMsg(ProtoMsg.MessageRequest.Builder cb) { + if (msgId > 0) { + cb.setMsgId(msgId); + } + if (StringUtils.isNotEmpty(from)) { + cb.setFrom(from); + } + if (StringUtils.isNotEmpty(to)) { + cb.setTo(to); + } + if (time > 0) { + cb.setTime(time); + } + if (msgType != null) { + cb.setMsgType(msgType.ordinal()); + } + if (StringUtils.isNotEmpty(content)) { + cb.setContent(content); + } + if (StringUtils.isNotEmpty(url)) { + cb.setUrl(url); + } + if (StringUtils.isNotEmpty(property)) { + cb.setProperty(property); + } + if (StringUtils.isNotEmpty(fromNick)) { + cb.setFromNick(fromNick); + } + + if (StringUtils.isNotEmpty(json)) { + cb.setJson(json); + } + } + +} diff --git a/chat/src/main/java/com/zpf/im/common/bean/msg/ProtoMsg.java b/chat/src/main/java/com/zpf/im/common/bean/msg/ProtoMsg.java new file mode 100644 index 0000000000000000000000000000000000000000..e2e2f91ee50bef774e229e0c20a46f2a3acc5094 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/bean/msg/ProtoMsg.java @@ -0,0 +1,6989 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ProtoMsg.proto + +package com.zpf.im.common.bean.msg; + +public final class ProtoMsg { + private ProtoMsg() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + /** + * Protobuf enum {@code com.zpf.im.common.bean.msg.HeadType} + */ + public enum HeadType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * LOGIN_REQUEST = 0; + */ + LOGIN_REQUEST(0), + /** + * LOGIN_RESPONSE = 1; + */ + LOGIN_RESPONSE(1), + /** + * LOGOUT_REQUEST = 2; + */ + LOGOUT_REQUEST(2), + /** + * LOGOUT_RESPONSE = 3; + */ + LOGOUT_RESPONSE(3), + /** + * KEEPALIVE_REQUEST = 4; + */ + KEEPALIVE_REQUEST(4), + /** + * KEEPALIVE_RESPONSE = 5; + */ + KEEPALIVE_RESPONSE(5), + /** + * MESSAGE_REQUEST = 6; + */ + MESSAGE_REQUEST(6), + /** + * MESSAGE_RESPONSE = 7; + */ + MESSAGE_RESPONSE(7), + /** + * MESSAGE_NOTIFICATION = 8; + */ + MESSAGE_NOTIFICATION(8), + UNRECOGNIZED(-1), + ; + + /** + * LOGIN_REQUEST = 0; + */ + public static final int LOGIN_REQUEST_VALUE = 0; + /** + * LOGIN_RESPONSE = 1; + */ + public static final int LOGIN_RESPONSE_VALUE = 1; + /** + * LOGOUT_REQUEST = 2; + */ + public static final int LOGOUT_REQUEST_VALUE = 2; + /** + * LOGOUT_RESPONSE = 3; + */ + public static final int LOGOUT_RESPONSE_VALUE = 3; + /** + * KEEPALIVE_REQUEST = 4; + */ + public static final int KEEPALIVE_REQUEST_VALUE = 4; + /** + * KEEPALIVE_RESPONSE = 5; + */ + public static final int KEEPALIVE_RESPONSE_VALUE = 5; + /** + * MESSAGE_REQUEST = 6; + */ + public static final int MESSAGE_REQUEST_VALUE = 6; + /** + * MESSAGE_RESPONSE = 7; + */ + public static final int MESSAGE_RESPONSE_VALUE = 7; + /** + * MESSAGE_NOTIFICATION = 8; + */ + public static final int MESSAGE_NOTIFICATION_VALUE = 8; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static HeadType valueOf(int value) { + return forNumber(value); + } + + public static HeadType forNumber(int value) { + switch (value) { + case 0: return LOGIN_REQUEST; + case 1: return LOGIN_RESPONSE; + case 2: return LOGOUT_REQUEST; + case 3: return LOGOUT_RESPONSE; + case 4: return KEEPALIVE_REQUEST; + case 5: return KEEPALIVE_RESPONSE; + case 6: return MESSAGE_REQUEST; + case 7: return MESSAGE_RESPONSE; + case 8: return MESSAGE_NOTIFICATION; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + HeadType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public HeadType findValueByNumber(int number) { + return HeadType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.getDescriptor().getEnumTypes().get(0); + } + + private static final HeadType[] VALUES = values(); + + public static HeadType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private HeadType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:com.zpf.im.common.bean.msg.HeadType) + } + + public interface LoginRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.zpf.im.common.bean.msg.LoginRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string uid = 1; + */ + java.lang.String getUid(); + /** + * string uid = 1; + */ + com.google.protobuf.ByteString + getUidBytes(); + + /** + * string deviceId = 2; + */ + java.lang.String getDeviceId(); + /** + * string deviceId = 2; + */ + com.google.protobuf.ByteString + getDeviceIdBytes(); + + /** + * string token = 3; + */ + java.lang.String getToken(); + /** + * string token = 3; + */ + com.google.protobuf.ByteString + getTokenBytes(); + + /** + * uint32 platform = 4; + */ + int getPlatform(); + + /** + * string app_version = 5; + */ + java.lang.String getAppVersion(); + /** + * string app_version = 5; + */ + com.google.protobuf.ByteString + getAppVersionBytes(); + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.LoginRequest} + */ + public static final class LoginRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.zpf.im.common.bean.msg.LoginRequest) + LoginRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use LoginRequest.newBuilder() to construct. + private LoginRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private LoginRequest() { + uid_ = ""; + deviceId_ = ""; + token_ = ""; + platform_ = 0; + appVersion_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private LoginRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + uid_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + deviceId_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + token_ = s; + break; + } + case 32: { + + platform_ = input.readUInt32(); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + appVersion_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.class, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder.class); + } + + public static final int UID_FIELD_NUMBER = 1; + private volatile java.lang.Object uid_; + /** + * string uid = 1; + */ + public java.lang.String getUid() { + java.lang.Object ref = uid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uid_ = s; + return s; + } + } + /** + * string uid = 1; + */ + public com.google.protobuf.ByteString + getUidBytes() { + java.lang.Object ref = uid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DEVICEID_FIELD_NUMBER = 2; + private volatile java.lang.Object deviceId_; + /** + * string deviceId = 2; + */ + public java.lang.String getDeviceId() { + java.lang.Object ref = deviceId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + deviceId_ = s; + return s; + } + } + /** + * string deviceId = 2; + */ + public com.google.protobuf.ByteString + getDeviceIdBytes() { + java.lang.Object ref = deviceId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + deviceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object token_; + /** + * string token = 3; + */ + public java.lang.String getToken() { + java.lang.Object ref = token_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + token_ = s; + return s; + } + } + /** + * string token = 3; + */ + public com.google.protobuf.ByteString + getTokenBytes() { + java.lang.Object ref = token_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + token_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PLATFORM_FIELD_NUMBER = 4; + private int platform_; + /** + * uint32 platform = 4; + */ + public int getPlatform() { + return platform_; + } + + public static final int APP_VERSION_FIELD_NUMBER = 5; + private volatile java.lang.Object appVersion_; + /** + * string app_version = 5; + */ + public java.lang.String getAppVersion() { + java.lang.Object ref = appVersion_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + appVersion_ = s; + return s; + } + } + /** + * string app_version = 5; + */ + public com.google.protobuf.ByteString + getAppVersionBytes() { + java.lang.Object ref = appVersion_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + appVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getUidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, uid_); + } + if (!getDeviceIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, deviceId_); + } + if (!getTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, token_); + } + if (platform_ != 0) { + output.writeUInt32(4, platform_); + } + if (!getAppVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, appVersion_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getUidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, uid_); + } + if (!getDeviceIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, deviceId_); + } + if (!getTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, token_); + } + if (platform_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(4, platform_); + } + if (!getAppVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, appVersion_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest)) { + return super.equals(obj); + } + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest other = (com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest) obj; + + boolean result = true; + result = result && getUid() + .equals(other.getUid()); + result = result && getDeviceId() + .equals(other.getDeviceId()); + result = result && getToken() + .equals(other.getToken()); + result = result && (getPlatform() + == other.getPlatform()); + result = result && getAppVersion() + .equals(other.getAppVersion()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + UID_FIELD_NUMBER; + hash = (53 * hash) + getUid().hashCode(); + hash = (37 * hash) + DEVICEID_FIELD_NUMBER; + hash = (53 * hash) + getDeviceId().hashCode(); + hash = (37 * hash) + TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getToken().hashCode(); + hash = (37 * hash) + PLATFORM_FIELD_NUMBER; + hash = (53 * hash) + getPlatform(); + hash = (37 * hash) + APP_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getAppVersion().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.LoginRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.zpf.im.common.bean.msg.LoginRequest) + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.class, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder.class); + } + + // Construct using com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + uid_ = ""; + + deviceId_ = ""; + + token_ = ""; + + platform_ = 0; + + appVersion_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginRequest_descriptor; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest getDefaultInstanceForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest build() { + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest buildPartial() { + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest result = new com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest(this); + result.uid_ = uid_; + result.deviceId_ = deviceId_; + result.token_ = token_; + result.platform_ = platform_; + result.appVersion_ = appVersion_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest) { + return mergeFrom((com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest other) { + if (other == com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.getDefaultInstance()) return this; + if (!other.getUid().isEmpty()) { + uid_ = other.uid_; + onChanged(); + } + if (!other.getDeviceId().isEmpty()) { + deviceId_ = other.deviceId_; + onChanged(); + } + if (!other.getToken().isEmpty()) { + token_ = other.token_; + onChanged(); + } + if (other.getPlatform() != 0) { + setPlatform(other.getPlatform()); + } + if (!other.getAppVersion().isEmpty()) { + appVersion_ = other.appVersion_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object uid_ = ""; + /** + * string uid = 1; + */ + public java.lang.String getUid() { + java.lang.Object ref = uid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string uid = 1; + */ + public com.google.protobuf.ByteString + getUidBytes() { + java.lang.Object ref = uid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string uid = 1; + */ + public Builder setUid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + uid_ = value; + onChanged(); + return this; + } + /** + * string uid = 1; + */ + public Builder clearUid() { + + uid_ = getDefaultInstance().getUid(); + onChanged(); + return this; + } + /** + * string uid = 1; + */ + public Builder setUidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + uid_ = value; + onChanged(); + return this; + } + + private java.lang.Object deviceId_ = ""; + /** + * string deviceId = 2; + */ + public java.lang.String getDeviceId() { + java.lang.Object ref = deviceId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + deviceId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string deviceId = 2; + */ + public com.google.protobuf.ByteString + getDeviceIdBytes() { + java.lang.Object ref = deviceId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + deviceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string deviceId = 2; + */ + public Builder setDeviceId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + deviceId_ = value; + onChanged(); + return this; + } + /** + * string deviceId = 2; + */ + public Builder clearDeviceId() { + + deviceId_ = getDefaultInstance().getDeviceId(); + onChanged(); + return this; + } + /** + * string deviceId = 2; + */ + public Builder setDeviceIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + deviceId_ = value; + onChanged(); + return this; + } + + private java.lang.Object token_ = ""; + /** + * string token = 3; + */ + public java.lang.String getToken() { + java.lang.Object ref = token_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + token_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string token = 3; + */ + public com.google.protobuf.ByteString + getTokenBytes() { + java.lang.Object ref = token_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + token_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string token = 3; + */ + public Builder setToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + token_ = value; + onChanged(); + return this; + } + /** + * string token = 3; + */ + public Builder clearToken() { + + token_ = getDefaultInstance().getToken(); + onChanged(); + return this; + } + /** + * string token = 3; + */ + public Builder setTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + token_ = value; + onChanged(); + return this; + } + + private int platform_ ; + /** + * uint32 platform = 4; + */ + public int getPlatform() { + return platform_; + } + /** + * uint32 platform = 4; + */ + public Builder setPlatform(int value) { + + platform_ = value; + onChanged(); + return this; + } + /** + * uint32 platform = 4; + */ + public Builder clearPlatform() { + + platform_ = 0; + onChanged(); + return this; + } + + private java.lang.Object appVersion_ = ""; + /** + * string app_version = 5; + */ + public java.lang.String getAppVersion() { + java.lang.Object ref = appVersion_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + appVersion_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string app_version = 5; + */ + public com.google.protobuf.ByteString + getAppVersionBytes() { + java.lang.Object ref = appVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + appVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string app_version = 5; + */ + public Builder setAppVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + appVersion_ = value; + onChanged(); + return this; + } + /** + * string app_version = 5; + */ + public Builder clearAppVersion() { + + appVersion_ = getDefaultInstance().getAppVersion(); + onChanged(); + return this; + } + /** + * string app_version = 5; + */ + public Builder setAppVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + appVersion_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.zpf.im.common.bean.msg.LoginRequest) + } + + // @@protoc_insertion_point(class_scope:com.zpf.im.common.bean.msg.LoginRequest) + private static final com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest(); + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LoginRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new LoginRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface LoginResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.zpf.im.common.bean.msg.LoginResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * bool result = 1; + */ + boolean getResult(); + + /** + * uint32 code = 2; + */ + int getCode(); + + /** + * string info = 3; + */ + java.lang.String getInfo(); + /** + * string info = 3; + */ + com.google.protobuf.ByteString + getInfoBytes(); + + /** + * uint32 expose = 4; + */ + int getExpose(); + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.LoginResponse} + */ + public static final class LoginResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.zpf.im.common.bean.msg.LoginResponse) + LoginResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use LoginResponse.newBuilder() to construct. + private LoginResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private LoginResponse() { + result_ = false; + code_ = 0; + info_ = ""; + expose_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private LoginResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + result_ = input.readBool(); + break; + } + case 16: { + + code_ = input.readUInt32(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + info_ = s; + break; + } + case 32: { + + expose_ = input.readUInt32(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.class, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder.class); + } + + public static final int RESULT_FIELD_NUMBER = 1; + private boolean result_; + /** + * bool result = 1; + */ + public boolean getResult() { + return result_; + } + + public static final int CODE_FIELD_NUMBER = 2; + private int code_; + /** + * uint32 code = 2; + */ + public int getCode() { + return code_; + } + + public static final int INFO_FIELD_NUMBER = 3; + private volatile java.lang.Object info_; + /** + * string info = 3; + */ + public java.lang.String getInfo() { + java.lang.Object ref = info_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + info_ = s; + return s; + } + } + /** + * string info = 3; + */ + public com.google.protobuf.ByteString + getInfoBytes() { + java.lang.Object ref = info_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + info_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EXPOSE_FIELD_NUMBER = 4; + private int expose_; + /** + * uint32 expose = 4; + */ + public int getExpose() { + return expose_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (result_ != false) { + output.writeBool(1, result_); + } + if (code_ != 0) { + output.writeUInt32(2, code_); + } + if (!getInfoBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, info_); + } + if (expose_ != 0) { + output.writeUInt32(4, expose_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (result_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, result_); + } + if (code_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(2, code_); + } + if (!getInfoBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, info_); + } + if (expose_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(4, expose_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse)) { + return super.equals(obj); + } + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse other = (com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse) obj; + + boolean result = true; + result = result && (getResult() + == other.getResult()); + result = result && (getCode() + == other.getCode()); + result = result && getInfo() + .equals(other.getInfo()); + result = result && (getExpose() + == other.getExpose()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getResult()); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + getCode(); + hash = (37 * hash) + INFO_FIELD_NUMBER; + hash = (53 * hash) + getInfo().hashCode(); + hash = (37 * hash) + EXPOSE_FIELD_NUMBER; + hash = (53 * hash) + getExpose(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.LoginResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.zpf.im.common.bean.msg.LoginResponse) + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.class, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder.class); + } + + // Construct using com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + result_ = false; + + code_ = 0; + + info_ = ""; + + expose_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_LoginResponse_descriptor; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse getDefaultInstanceForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse build() { + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse buildPartial() { + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse result = new com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse(this); + result.result_ = result_; + result.code_ = code_; + result.info_ = info_; + result.expose_ = expose_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse) { + return mergeFrom((com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse other) { + if (other == com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.getDefaultInstance()) return this; + if (other.getResult() != false) { + setResult(other.getResult()); + } + if (other.getCode() != 0) { + setCode(other.getCode()); + } + if (!other.getInfo().isEmpty()) { + info_ = other.info_; + onChanged(); + } + if (other.getExpose() != 0) { + setExpose(other.getExpose()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean result_ ; + /** + * bool result = 1; + */ + public boolean getResult() { + return result_; + } + /** + * bool result = 1; + */ + public Builder setResult(boolean value) { + + result_ = value; + onChanged(); + return this; + } + /** + * bool result = 1; + */ + public Builder clearResult() { + + result_ = false; + onChanged(); + return this; + } + + private int code_ ; + /** + * uint32 code = 2; + */ + public int getCode() { + return code_; + } + /** + * uint32 code = 2; + */ + public Builder setCode(int value) { + + code_ = value; + onChanged(); + return this; + } + /** + * uint32 code = 2; + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private java.lang.Object info_ = ""; + /** + * string info = 3; + */ + public java.lang.String getInfo() { + java.lang.Object ref = info_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + info_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string info = 3; + */ + public com.google.protobuf.ByteString + getInfoBytes() { + java.lang.Object ref = info_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + info_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string info = 3; + */ + public Builder setInfo( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + info_ = value; + onChanged(); + return this; + } + /** + * string info = 3; + */ + public Builder clearInfo() { + + info_ = getDefaultInstance().getInfo(); + onChanged(); + return this; + } + /** + * string info = 3; + */ + public Builder setInfoBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + info_ = value; + onChanged(); + return this; + } + + private int expose_ ; + /** + * uint32 expose = 4; + */ + public int getExpose() { + return expose_; + } + /** + * uint32 expose = 4; + */ + public Builder setExpose(int value) { + + expose_ = value; + onChanged(); + return this; + } + /** + * uint32 expose = 4; + */ + public Builder clearExpose() { + + expose_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.zpf.im.common.bean.msg.LoginResponse) + } + + // @@protoc_insertion_point(class_scope:com.zpf.im.common.bean.msg.LoginResponse) + private static final com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse(); + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LoginResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new LoginResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface MessageRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.zpf.im.common.bean.msg.MessageRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * uint64 msg_id = 1; + */ + long getMsgId(); + + /** + * string from = 2; + */ + java.lang.String getFrom(); + /** + * string from = 2; + */ + com.google.protobuf.ByteString + getFromBytes(); + + /** + * string to = 3; + */ + java.lang.String getTo(); + /** + * string to = 3; + */ + com.google.protobuf.ByteString + getToBytes(); + + /** + * uint64 time = 4; + */ + long getTime(); + + /** + * uint32 msg_type = 5; + */ + int getMsgType(); + + /** + * string content = 6; + */ + java.lang.String getContent(); + /** + * string content = 6; + */ + com.google.protobuf.ByteString + getContentBytes(); + + /** + * string url = 8; + */ + java.lang.String getUrl(); + /** + * string url = 8; + */ + com.google.protobuf.ByteString + getUrlBytes(); + + /** + * string property = 9; + */ + java.lang.String getProperty(); + /** + * string property = 9; + */ + com.google.protobuf.ByteString + getPropertyBytes(); + + /** + * string from_nick = 10; + */ + java.lang.String getFromNick(); + /** + * string from_nick = 10; + */ + com.google.protobuf.ByteString + getFromNickBytes(); + + /** + * string json = 11; + */ + java.lang.String getJson(); + /** + * string json = 11; + */ + com.google.protobuf.ByteString + getJsonBytes(); + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.MessageRequest} + */ + public static final class MessageRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.zpf.im.common.bean.msg.MessageRequest) + MessageRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use MessageRequest.newBuilder() to construct. + private MessageRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MessageRequest() { + msgId_ = 0L; + from_ = ""; + to_ = ""; + time_ = 0L; + msgType_ = 0; + content_ = ""; + url_ = ""; + property_ = ""; + fromNick_ = ""; + json_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MessageRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + msgId_ = input.readUInt64(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + from_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + to_ = s; + break; + } + case 32: { + + time_ = input.readUInt64(); + break; + } + case 40: { + + msgType_ = input.readUInt32(); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + case 74: { + java.lang.String s = input.readStringRequireUtf8(); + + property_ = s; + break; + } + case 82: { + java.lang.String s = input.readStringRequireUtf8(); + + fromNick_ = s; + break; + } + case 90: { + java.lang.String s = input.readStringRequireUtf8(); + + json_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.class, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder.class); + } + + public static final int MSG_ID_FIELD_NUMBER = 1; + private long msgId_; + /** + * uint64 msg_id = 1; + */ + public long getMsgId() { + return msgId_; + } + + public static final int FROM_FIELD_NUMBER = 2; + private volatile java.lang.Object from_; + /** + * string from = 2; + */ + public java.lang.String getFrom() { + java.lang.Object ref = from_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + from_ = s; + return s; + } + } + /** + * string from = 2; + */ + public com.google.protobuf.ByteString + getFromBytes() { + java.lang.Object ref = from_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + from_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TO_FIELD_NUMBER = 3; + private volatile java.lang.Object to_; + /** + * string to = 3; + */ + public java.lang.String getTo() { + java.lang.Object ref = to_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + to_ = s; + return s; + } + } + /** + * string to = 3; + */ + public com.google.protobuf.ByteString + getToBytes() { + java.lang.Object ref = to_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + to_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_FIELD_NUMBER = 4; + private long time_; + /** + * uint64 time = 4; + */ + public long getTime() { + return time_; + } + + public static final int MSG_TYPE_FIELD_NUMBER = 5; + private int msgType_; + /** + * uint32 msg_type = 5; + */ + public int getMsgType() { + return msgType_; + } + + public static final int CONTENT_FIELD_NUMBER = 6; + private volatile java.lang.Object content_; + /** + * string content = 6; + */ + public java.lang.String getContent() { + java.lang.Object ref = content_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + /** + * string content = 6; + */ + public com.google.protobuf.ByteString + getContentBytes() { + java.lang.Object ref = content_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 8; + private volatile java.lang.Object url_; + /** + * string url = 8; + */ + public java.lang.String getUrl() { + java.lang.Object ref = url_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 8; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + java.lang.Object ref = url_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROPERTY_FIELD_NUMBER = 9; + private volatile java.lang.Object property_; + /** + * string property = 9; + */ + public java.lang.String getProperty() { + java.lang.Object ref = property_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + property_ = s; + return s; + } + } + /** + * string property = 9; + */ + public com.google.protobuf.ByteString + getPropertyBytes() { + java.lang.Object ref = property_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + property_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FROM_NICK_FIELD_NUMBER = 10; + private volatile java.lang.Object fromNick_; + /** + * string from_nick = 10; + */ + public java.lang.String getFromNick() { + java.lang.Object ref = fromNick_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fromNick_ = s; + return s; + } + } + /** + * string from_nick = 10; + */ + public com.google.protobuf.ByteString + getFromNickBytes() { + java.lang.Object ref = fromNick_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + fromNick_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int JSON_FIELD_NUMBER = 11; + private volatile java.lang.Object json_; + /** + * string json = 11; + */ + public java.lang.String getJson() { + java.lang.Object ref = json_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + json_ = s; + return s; + } + } + /** + * string json = 11; + */ + public com.google.protobuf.ByteString + getJsonBytes() { + java.lang.Object ref = json_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + json_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (msgId_ != 0L) { + output.writeUInt64(1, msgId_); + } + if (!getFromBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, from_); + } + if (!getToBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, to_); + } + if (time_ != 0L) { + output.writeUInt64(4, time_); + } + if (msgType_ != 0) { + output.writeUInt32(5, msgType_); + } + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, content_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, url_); + } + if (!getPropertyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, property_); + } + if (!getFromNickBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, fromNick_); + } + if (!getJsonBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 11, json_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (msgId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, msgId_); + } + if (!getFromBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, from_); + } + if (!getToBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, to_); + } + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(4, time_); + } + if (msgType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(5, msgType_); + } + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, content_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, url_); + } + if (!getPropertyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, property_); + } + if (!getFromNickBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, fromNick_); + } + if (!getJsonBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, json_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest)) { + return super.equals(obj); + } + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest other = (com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest) obj; + + boolean result = true; + result = result && (getMsgId() + == other.getMsgId()); + result = result && getFrom() + .equals(other.getFrom()); + result = result && getTo() + .equals(other.getTo()); + result = result && (getTime() + == other.getTime()); + result = result && (getMsgType() + == other.getMsgType()); + result = result && getContent() + .equals(other.getContent()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && getProperty() + .equals(other.getProperty()); + result = result && getFromNick() + .equals(other.getFromNick()); + result = result && getJson() + .equals(other.getJson()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MSG_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getMsgId()); + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + hash = (37 * hash) + TO_FIELD_NUMBER; + hash = (53 * hash) + getTo().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + MSG_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getMsgType(); + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().hashCode(); + hash = (37 * hash) + FROM_NICK_FIELD_NUMBER; + hash = (53 * hash) + getFromNick().hashCode(); + hash = (37 * hash) + JSON_FIELD_NUMBER; + hash = (53 * hash) + getJson().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.MessageRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.zpf.im.common.bean.msg.MessageRequest) + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.class, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder.class); + } + + // Construct using com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + msgId_ = 0L; + + from_ = ""; + + to_ = ""; + + time_ = 0L; + + msgType_ = 0; + + content_ = ""; + + url_ = ""; + + property_ = ""; + + fromNick_ = ""; + + json_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageRequest_descriptor; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest getDefaultInstanceForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest build() { + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest buildPartial() { + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest result = new com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest(this); + result.msgId_ = msgId_; + result.from_ = from_; + result.to_ = to_; + result.time_ = time_; + result.msgType_ = msgType_; + result.content_ = content_; + result.url_ = url_; + result.property_ = property_; + result.fromNick_ = fromNick_; + result.json_ = json_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest) { + return mergeFrom((com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest other) { + if (other == com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.getDefaultInstance()) return this; + if (other.getMsgId() != 0L) { + setMsgId(other.getMsgId()); + } + if (!other.getFrom().isEmpty()) { + from_ = other.from_; + onChanged(); + } + if (!other.getTo().isEmpty()) { + to_ = other.to_; + onChanged(); + } + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (other.getMsgType() != 0) { + setMsgType(other.getMsgType()); + } + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + if (!other.getProperty().isEmpty()) { + property_ = other.property_; + onChanged(); + } + if (!other.getFromNick().isEmpty()) { + fromNick_ = other.fromNick_; + onChanged(); + } + if (!other.getJson().isEmpty()) { + json_ = other.json_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long msgId_ ; + /** + * uint64 msg_id = 1; + */ + public long getMsgId() { + return msgId_; + } + /** + * uint64 msg_id = 1; + */ + public Builder setMsgId(long value) { + + msgId_ = value; + onChanged(); + return this; + } + /** + * uint64 msg_id = 1; + */ + public Builder clearMsgId() { + + msgId_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object from_ = ""; + /** + * string from = 2; + */ + public java.lang.String getFrom() { + java.lang.Object ref = from_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + from_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string from = 2; + */ + public com.google.protobuf.ByteString + getFromBytes() { + java.lang.Object ref = from_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + from_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string from = 2; + */ + public Builder setFrom( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + from_ = value; + onChanged(); + return this; + } + /** + * string from = 2; + */ + public Builder clearFrom() { + + from_ = getDefaultInstance().getFrom(); + onChanged(); + return this; + } + /** + * string from = 2; + */ + public Builder setFromBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + from_ = value; + onChanged(); + return this; + } + + private java.lang.Object to_ = ""; + /** + * string to = 3; + */ + public java.lang.String getTo() { + java.lang.Object ref = to_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + to_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string to = 3; + */ + public com.google.protobuf.ByteString + getToBytes() { + java.lang.Object ref = to_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + to_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string to = 3; + */ + public Builder setTo( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + to_ = value; + onChanged(); + return this; + } + /** + * string to = 3; + */ + public Builder clearTo() { + + to_ = getDefaultInstance().getTo(); + onChanged(); + return this; + } + /** + * string to = 3; + */ + public Builder setToBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + to_ = value; + onChanged(); + return this; + } + + private long time_ ; + /** + * uint64 time = 4; + */ + public long getTime() { + return time_; + } + /** + * uint64 time = 4; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + * uint64 time = 4; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private int msgType_ ; + /** + * uint32 msg_type = 5; + */ + public int getMsgType() { + return msgType_; + } + /** + * uint32 msg_type = 5; + */ + public Builder setMsgType(int value) { + + msgType_ = value; + onChanged(); + return this; + } + /** + * uint32 msg_type = 5; + */ + public Builder clearMsgType() { + + msgType_ = 0; + onChanged(); + return this; + } + + private java.lang.Object content_ = ""; + /** + * string content = 6; + */ + public java.lang.String getContent() { + java.lang.Object ref = content_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string content = 6; + */ + public com.google.protobuf.ByteString + getContentBytes() { + java.lang.Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string content = 6; + */ + public Builder setContent( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + /** + * string content = 6; + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + /** + * string content = 6; + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + + private java.lang.Object url_ = ""; + /** + * string url = 8; + */ + public java.lang.String getUrl() { + java.lang.Object ref = url_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string url = 8; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + java.lang.Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 8; + */ + public Builder setUrl( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 8; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 8; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + + private java.lang.Object property_ = ""; + /** + * string property = 9; + */ + public java.lang.String getProperty() { + java.lang.Object ref = property_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + property_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string property = 9; + */ + public com.google.protobuf.ByteString + getPropertyBytes() { + java.lang.Object ref = property_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + property_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string property = 9; + */ + public Builder setProperty( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + property_ = value; + onChanged(); + return this; + } + /** + * string property = 9; + */ + public Builder clearProperty() { + + property_ = getDefaultInstance().getProperty(); + onChanged(); + return this; + } + /** + * string property = 9; + */ + public Builder setPropertyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + property_ = value; + onChanged(); + return this; + } + + private java.lang.Object fromNick_ = ""; + /** + * string from_nick = 10; + */ + public java.lang.String getFromNick() { + java.lang.Object ref = fromNick_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fromNick_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string from_nick = 10; + */ + public com.google.protobuf.ByteString + getFromNickBytes() { + java.lang.Object ref = fromNick_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + fromNick_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string from_nick = 10; + */ + public Builder setFromNick( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + fromNick_ = value; + onChanged(); + return this; + } + /** + * string from_nick = 10; + */ + public Builder clearFromNick() { + + fromNick_ = getDefaultInstance().getFromNick(); + onChanged(); + return this; + } + /** + * string from_nick = 10; + */ + public Builder setFromNickBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + fromNick_ = value; + onChanged(); + return this; + } + + private java.lang.Object json_ = ""; + /** + * string json = 11; + */ + public java.lang.String getJson() { + java.lang.Object ref = json_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + json_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string json = 11; + */ + public com.google.protobuf.ByteString + getJsonBytes() { + java.lang.Object ref = json_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + json_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string json = 11; + */ + public Builder setJson( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + json_ = value; + onChanged(); + return this; + } + /** + * string json = 11; + */ + public Builder clearJson() { + + json_ = getDefaultInstance().getJson(); + onChanged(); + return this; + } + /** + * string json = 11; + */ + public Builder setJsonBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + json_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.zpf.im.common.bean.msg.MessageRequest) + } + + // @@protoc_insertion_point(class_scope:com.zpf.im.common.bean.msg.MessageRequest) + private static final com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest(); + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MessageRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MessageRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface MessageResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.zpf.im.common.bean.msg.MessageResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * bool result = 1; + */ + boolean getResult(); + + /** + * uint32 code = 2; + */ + int getCode(); + + /** + * string info = 3; + */ + java.lang.String getInfo(); + /** + * string info = 3; + */ + com.google.protobuf.ByteString + getInfoBytes(); + + /** + * uint32 expose = 4; + */ + int getExpose(); + + /** + * bool last_block = 5; + */ + boolean getLastBlock(); + + /** + * fixed32 block_index = 6; + */ + int getBlockIndex(); + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.MessageResponse} + */ + public static final class MessageResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.zpf.im.common.bean.msg.MessageResponse) + MessageResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use MessageResponse.newBuilder() to construct. + private MessageResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MessageResponse() { + result_ = false; + code_ = 0; + info_ = ""; + expose_ = 0; + lastBlock_ = false; + blockIndex_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MessageResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + result_ = input.readBool(); + break; + } + case 16: { + + code_ = input.readUInt32(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + info_ = s; + break; + } + case 32: { + + expose_ = input.readUInt32(); + break; + } + case 40: { + + lastBlock_ = input.readBool(); + break; + } + case 53: { + + blockIndex_ = input.readFixed32(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.class, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder.class); + } + + public static final int RESULT_FIELD_NUMBER = 1; + private boolean result_; + /** + * bool result = 1; + */ + public boolean getResult() { + return result_; + } + + public static final int CODE_FIELD_NUMBER = 2; + private int code_; + /** + * uint32 code = 2; + */ + public int getCode() { + return code_; + } + + public static final int INFO_FIELD_NUMBER = 3; + private volatile java.lang.Object info_; + /** + * string info = 3; + */ + public java.lang.String getInfo() { + java.lang.Object ref = info_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + info_ = s; + return s; + } + } + /** + * string info = 3; + */ + public com.google.protobuf.ByteString + getInfoBytes() { + java.lang.Object ref = info_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + info_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EXPOSE_FIELD_NUMBER = 4; + private int expose_; + /** + * uint32 expose = 4; + */ + public int getExpose() { + return expose_; + } + + public static final int LAST_BLOCK_FIELD_NUMBER = 5; + private boolean lastBlock_; + /** + * bool last_block = 5; + */ + public boolean getLastBlock() { + return lastBlock_; + } + + public static final int BLOCK_INDEX_FIELD_NUMBER = 6; + private int blockIndex_; + /** + * fixed32 block_index = 6; + */ + public int getBlockIndex() { + return blockIndex_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (result_ != false) { + output.writeBool(1, result_); + } + if (code_ != 0) { + output.writeUInt32(2, code_); + } + if (!getInfoBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, info_); + } + if (expose_ != 0) { + output.writeUInt32(4, expose_); + } + if (lastBlock_ != false) { + output.writeBool(5, lastBlock_); + } + if (blockIndex_ != 0) { + output.writeFixed32(6, blockIndex_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (result_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, result_); + } + if (code_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(2, code_); + } + if (!getInfoBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, info_); + } + if (expose_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(4, expose_); + } + if (lastBlock_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(5, lastBlock_); + } + if (blockIndex_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFixed32Size(6, blockIndex_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse)) { + return super.equals(obj); + } + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse other = (com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse) obj; + + boolean result = true; + result = result && (getResult() + == other.getResult()); + result = result && (getCode() + == other.getCode()); + result = result && getInfo() + .equals(other.getInfo()); + result = result && (getExpose() + == other.getExpose()); + result = result && (getLastBlock() + == other.getLastBlock()); + result = result && (getBlockIndex() + == other.getBlockIndex()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getResult()); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + getCode(); + hash = (37 * hash) + INFO_FIELD_NUMBER; + hash = (53 * hash) + getInfo().hashCode(); + hash = (37 * hash) + EXPOSE_FIELD_NUMBER; + hash = (53 * hash) + getExpose(); + hash = (37 * hash) + LAST_BLOCK_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getLastBlock()); + hash = (37 * hash) + BLOCK_INDEX_FIELD_NUMBER; + hash = (53 * hash) + getBlockIndex(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.MessageResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.zpf.im.common.bean.msg.MessageResponse) + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.class, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder.class); + } + + // Construct using com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + result_ = false; + + code_ = 0; + + info_ = ""; + + expose_ = 0; + + lastBlock_ = false; + + blockIndex_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageResponse_descriptor; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse getDefaultInstanceForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse build() { + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse buildPartial() { + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse result = new com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse(this); + result.result_ = result_; + result.code_ = code_; + result.info_ = info_; + result.expose_ = expose_; + result.lastBlock_ = lastBlock_; + result.blockIndex_ = blockIndex_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse) { + return mergeFrom((com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse other) { + if (other == com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.getDefaultInstance()) return this; + if (other.getResult() != false) { + setResult(other.getResult()); + } + if (other.getCode() != 0) { + setCode(other.getCode()); + } + if (!other.getInfo().isEmpty()) { + info_ = other.info_; + onChanged(); + } + if (other.getExpose() != 0) { + setExpose(other.getExpose()); + } + if (other.getLastBlock() != false) { + setLastBlock(other.getLastBlock()); + } + if (other.getBlockIndex() != 0) { + setBlockIndex(other.getBlockIndex()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean result_ ; + /** + * bool result = 1; + */ + public boolean getResult() { + return result_; + } + /** + * bool result = 1; + */ + public Builder setResult(boolean value) { + + result_ = value; + onChanged(); + return this; + } + /** + * bool result = 1; + */ + public Builder clearResult() { + + result_ = false; + onChanged(); + return this; + } + + private int code_ ; + /** + * uint32 code = 2; + */ + public int getCode() { + return code_; + } + /** + * uint32 code = 2; + */ + public Builder setCode(int value) { + + code_ = value; + onChanged(); + return this; + } + /** + * uint32 code = 2; + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private java.lang.Object info_ = ""; + /** + * string info = 3; + */ + public java.lang.String getInfo() { + java.lang.Object ref = info_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + info_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string info = 3; + */ + public com.google.protobuf.ByteString + getInfoBytes() { + java.lang.Object ref = info_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + info_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string info = 3; + */ + public Builder setInfo( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + info_ = value; + onChanged(); + return this; + } + /** + * string info = 3; + */ + public Builder clearInfo() { + + info_ = getDefaultInstance().getInfo(); + onChanged(); + return this; + } + /** + * string info = 3; + */ + public Builder setInfoBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + info_ = value; + onChanged(); + return this; + } + + private int expose_ ; + /** + * uint32 expose = 4; + */ + public int getExpose() { + return expose_; + } + /** + * uint32 expose = 4; + */ + public Builder setExpose(int value) { + + expose_ = value; + onChanged(); + return this; + } + /** + * uint32 expose = 4; + */ + public Builder clearExpose() { + + expose_ = 0; + onChanged(); + return this; + } + + private boolean lastBlock_ ; + /** + * bool last_block = 5; + */ + public boolean getLastBlock() { + return lastBlock_; + } + /** + * bool last_block = 5; + */ + public Builder setLastBlock(boolean value) { + + lastBlock_ = value; + onChanged(); + return this; + } + /** + * bool last_block = 5; + */ + public Builder clearLastBlock() { + + lastBlock_ = false; + onChanged(); + return this; + } + + private int blockIndex_ ; + /** + * fixed32 block_index = 6; + */ + public int getBlockIndex() { + return blockIndex_; + } + /** + * fixed32 block_index = 6; + */ + public Builder setBlockIndex(int value) { + + blockIndex_ = value; + onChanged(); + return this; + } + /** + * fixed32 block_index = 6; + */ + public Builder clearBlockIndex() { + + blockIndex_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.zpf.im.common.bean.msg.MessageResponse) + } + + // @@protoc_insertion_point(class_scope:com.zpf.im.common.bean.msg.MessageResponse) + private static final com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse(); + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MessageResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MessageResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface MessageNotificationOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.zpf.im.common.bean.msg.MessageNotification) + com.google.protobuf.MessageOrBuilder { + + /** + * uint32 msg_type = 1; + */ + int getMsgType(); + + /** + * bytes sender = 2; + */ + com.google.protobuf.ByteString getSender(); + + /** + * string json = 3; + */ + java.lang.String getJson(); + /** + * string json = 3; + */ + com.google.protobuf.ByteString + getJsonBytes(); + + /** + * string timestamp = 4; + */ + java.lang.String getTimestamp(); + /** + * string timestamp = 4; + */ + com.google.protobuf.ByteString + getTimestampBytes(); + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.MessageNotification} + */ + public static final class MessageNotification extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.zpf.im.common.bean.msg.MessageNotification) + MessageNotificationOrBuilder { + private static final long serialVersionUID = 0L; + // Use MessageNotification.newBuilder() to construct. + private MessageNotification(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MessageNotification() { + msgType_ = 0; + sender_ = com.google.protobuf.ByteString.EMPTY; + json_ = ""; + timestamp_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MessageNotification( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + msgType_ = input.readUInt32(); + break; + } + case 18: { + + sender_ = input.readBytes(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + json_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + timestamp_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageNotification_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageNotification_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.class, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder.class); + } + + public static final int MSG_TYPE_FIELD_NUMBER = 1; + private int msgType_; + /** + * uint32 msg_type = 1; + */ + public int getMsgType() { + return msgType_; + } + + public static final int SENDER_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString sender_; + /** + * bytes sender = 2; + */ + public com.google.protobuf.ByteString getSender() { + return sender_; + } + + public static final int JSON_FIELD_NUMBER = 3; + private volatile java.lang.Object json_; + /** + * string json = 3; + */ + public java.lang.String getJson() { + java.lang.Object ref = json_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + json_ = s; + return s; + } + } + /** + * string json = 3; + */ + public com.google.protobuf.ByteString + getJsonBytes() { + java.lang.Object ref = json_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + json_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIMESTAMP_FIELD_NUMBER = 4; + private volatile java.lang.Object timestamp_; + /** + * string timestamp = 4; + */ + public java.lang.String getTimestamp() { + java.lang.Object ref = timestamp_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + timestamp_ = s; + return s; + } + } + /** + * string timestamp = 4; + */ + public com.google.protobuf.ByteString + getTimestampBytes() { + java.lang.Object ref = timestamp_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + timestamp_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (msgType_ != 0) { + output.writeUInt32(1, msgType_); + } + if (!sender_.isEmpty()) { + output.writeBytes(2, sender_); + } + if (!getJsonBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, json_); + } + if (!getTimestampBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, timestamp_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (msgType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(1, msgType_); + } + if (!sender_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, sender_); + } + if (!getJsonBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, json_); + } + if (!getTimestampBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, timestamp_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification)) { + return super.equals(obj); + } + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification other = (com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification) obj; + + boolean result = true; + result = result && (getMsgType() + == other.getMsgType()); + result = result && getSender() + .equals(other.getSender()); + result = result && getJson() + .equals(other.getJson()); + result = result && getTimestamp() + .equals(other.getTimestamp()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MSG_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getMsgType(); + hash = (37 * hash) + SENDER_FIELD_NUMBER; + hash = (53 * hash) + getSender().hashCode(); + hash = (37 * hash) + JSON_FIELD_NUMBER; + hash = (53 * hash) + getJson().hashCode(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + getTimestamp().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.MessageNotification} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.zpf.im.common.bean.msg.MessageNotification) + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageNotification_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageNotification_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.class, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder.class); + } + + // Construct using com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + msgType_ = 0; + + sender_ = com.google.protobuf.ByteString.EMPTY; + + json_ = ""; + + timestamp_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_MessageNotification_descriptor; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification getDefaultInstanceForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.getDefaultInstance(); + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification build() { + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification buildPartial() { + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification result = new com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification(this); + result.msgType_ = msgType_; + result.sender_ = sender_; + result.json_ = json_; + result.timestamp_ = timestamp_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification) { + return mergeFrom((com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification other) { + if (other == com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.getDefaultInstance()) return this; + if (other.getMsgType() != 0) { + setMsgType(other.getMsgType()); + } + if (other.getSender() != com.google.protobuf.ByteString.EMPTY) { + setSender(other.getSender()); + } + if (!other.getJson().isEmpty()) { + json_ = other.json_; + onChanged(); + } + if (!other.getTimestamp().isEmpty()) { + timestamp_ = other.timestamp_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int msgType_ ; + /** + * uint32 msg_type = 1; + */ + public int getMsgType() { + return msgType_; + } + /** + * uint32 msg_type = 1; + */ + public Builder setMsgType(int value) { + + msgType_ = value; + onChanged(); + return this; + } + /** + * uint32 msg_type = 1; + */ + public Builder clearMsgType() { + + msgType_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString sender_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes sender = 2; + */ + public com.google.protobuf.ByteString getSender() { + return sender_; + } + /** + * bytes sender = 2; + */ + public Builder setSender(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + sender_ = value; + onChanged(); + return this; + } + /** + * bytes sender = 2; + */ + public Builder clearSender() { + + sender_ = getDefaultInstance().getSender(); + onChanged(); + return this; + } + + private java.lang.Object json_ = ""; + /** + * string json = 3; + */ + public java.lang.String getJson() { + java.lang.Object ref = json_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + json_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string json = 3; + */ + public com.google.protobuf.ByteString + getJsonBytes() { + java.lang.Object ref = json_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + json_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string json = 3; + */ + public Builder setJson( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + json_ = value; + onChanged(); + return this; + } + /** + * string json = 3; + */ + public Builder clearJson() { + + json_ = getDefaultInstance().getJson(); + onChanged(); + return this; + } + /** + * string json = 3; + */ + public Builder setJsonBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + json_ = value; + onChanged(); + return this; + } + + private java.lang.Object timestamp_ = ""; + /** + * string timestamp = 4; + */ + public java.lang.String getTimestamp() { + java.lang.Object ref = timestamp_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + timestamp_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string timestamp = 4; + */ + public com.google.protobuf.ByteString + getTimestampBytes() { + java.lang.Object ref = timestamp_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + timestamp_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string timestamp = 4; + */ + public Builder setTimestamp( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + timestamp_ = value; + onChanged(); + return this; + } + /** + * string timestamp = 4; + */ + public Builder clearTimestamp() { + + timestamp_ = getDefaultInstance().getTimestamp(); + onChanged(); + return this; + } + /** + * string timestamp = 4; + */ + public Builder setTimestampBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + timestamp_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.zpf.im.common.bean.msg.MessageNotification) + } + + // @@protoc_insertion_point(class_scope:com.zpf.im.common.bean.msg.MessageNotification) + private static final com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification(); + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MessageNotification parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MessageNotification(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface MessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.zpf.im.common.bean.msg.Message) + com.google.protobuf.MessageOrBuilder { + + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + int getTypeValue(); + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + com.zpf.im.common.bean.msg.ProtoMsg.HeadType getType(); + + /** + * uint64 sequence = 2; + */ + long getSequence(); + + /** + * string session_id = 3; + */ + java.lang.String getSessionId(); + /** + * string session_id = 3; + */ + com.google.protobuf.ByteString + getSessionIdBytes(); + + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + boolean hasLoginRequest(); + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest getLoginRequest(); + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder getLoginRequestOrBuilder(); + + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + boolean hasLoginResponse(); + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse getLoginResponse(); + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder getLoginResponseOrBuilder(); + + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + boolean hasMessageRequest(); + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest getMessageRequest(); + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder getMessageRequestOrBuilder(); + + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + boolean hasMessageResponse(); + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse getMessageResponse(); + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder getMessageResponseOrBuilder(); + + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + boolean hasNotification(); + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification getNotification(); + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder getNotificationOrBuilder(); + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.Message} + */ + public static final class Message extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.zpf.im.common.bean.msg.Message) + MessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use Message.newBuilder() to construct. + private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Message() { + type_ = 0; + sequence_ = 0L; + sessionId_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Message( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 16: { + + sequence_ = input.readUInt64(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + sessionId_ = s; + break; + } + case 34: { + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder subBuilder = null; + if (loginRequest_ != null) { + subBuilder = loginRequest_.toBuilder(); + } + loginRequest_ = input.readMessage(com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(loginRequest_); + loginRequest_ = subBuilder.buildPartial(); + } + + break; + } + case 42: { + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder subBuilder = null; + if (loginResponse_ != null) { + subBuilder = loginResponse_.toBuilder(); + } + loginResponse_ = input.readMessage(com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(loginResponse_); + loginResponse_ = subBuilder.buildPartial(); + } + + break; + } + case 50: { + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder subBuilder = null; + if (messageRequest_ != null) { + subBuilder = messageRequest_.toBuilder(); + } + messageRequest_ = input.readMessage(com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(messageRequest_); + messageRequest_ = subBuilder.buildPartial(); + } + + break; + } + case 58: { + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder subBuilder = null; + if (messageResponse_ != null) { + subBuilder = messageResponse_.toBuilder(); + } + messageResponse_ = input.readMessage(com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(messageResponse_); + messageResponse_ = subBuilder.buildPartial(); + } + + break; + } + case 66: { + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder subBuilder = null; + if (notification_ != null) { + subBuilder = notification_.toBuilder(); + } + notification_ = input.readMessage(com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(notification_); + notification_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_Message_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.Message.class, com.zpf.im.common.bean.msg.ProtoMsg.Message.Builder.class); + } + + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.HeadType getType() { + @SuppressWarnings("deprecation") + com.zpf.im.common.bean.msg.ProtoMsg.HeadType result = com.zpf.im.common.bean.msg.ProtoMsg.HeadType.valueOf(type_); + return result == null ? com.zpf.im.common.bean.msg.ProtoMsg.HeadType.UNRECOGNIZED : result; + } + + public static final int SEQUENCE_FIELD_NUMBER = 2; + private long sequence_; + /** + * uint64 sequence = 2; + */ + public long getSequence() { + return sequence_; + } + + public static final int SESSION_ID_FIELD_NUMBER = 3; + private volatile java.lang.Object sessionId_; + /** + * string session_id = 3; + */ + public java.lang.String getSessionId() { + java.lang.Object ref = sessionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sessionId_ = s; + return s; + } + } + /** + * string session_id = 3; + */ + public com.google.protobuf.ByteString + getSessionIdBytes() { + java.lang.Object ref = sessionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + sessionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LOGINREQUEST_FIELD_NUMBER = 4; + private com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest loginRequest_; + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public boolean hasLoginRequest() { + return loginRequest_ != null; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest getLoginRequest() { + return loginRequest_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.getDefaultInstance() : loginRequest_; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder getLoginRequestOrBuilder() { + return getLoginRequest(); + } + + public static final int LOGINRESPONSE_FIELD_NUMBER = 5; + private com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse loginResponse_; + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public boolean hasLoginResponse() { + return loginResponse_ != null; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse getLoginResponse() { + return loginResponse_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.getDefaultInstance() : loginResponse_; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder getLoginResponseOrBuilder() { + return getLoginResponse(); + } + + public static final int MESSAGEREQUEST_FIELD_NUMBER = 6; + private com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest messageRequest_; + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public boolean hasMessageRequest() { + return messageRequest_ != null; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest getMessageRequest() { + return messageRequest_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.getDefaultInstance() : messageRequest_; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder getMessageRequestOrBuilder() { + return getMessageRequest(); + } + + public static final int MESSAGERESPONSE_FIELD_NUMBER = 7; + private com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse messageResponse_; + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public boolean hasMessageResponse() { + return messageResponse_ != null; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse getMessageResponse() { + return messageResponse_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.getDefaultInstance() : messageResponse_; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder getMessageResponseOrBuilder() { + return getMessageResponse(); + } + + public static final int NOTIFICATION_FIELD_NUMBER = 8; + private com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification notification_; + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public boolean hasNotification() { + return notification_ != null; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification getNotification() { + return notification_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.getDefaultInstance() : notification_; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder getNotificationOrBuilder() { + return getNotification(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != com.zpf.im.common.bean.msg.ProtoMsg.HeadType.LOGIN_REQUEST.getNumber()) { + output.writeEnum(1, type_); + } + if (sequence_ != 0L) { + output.writeUInt64(2, sequence_); + } + if (!getSessionIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, sessionId_); + } + if (loginRequest_ != null) { + output.writeMessage(4, getLoginRequest()); + } + if (loginResponse_ != null) { + output.writeMessage(5, getLoginResponse()); + } + if (messageRequest_ != null) { + output.writeMessage(6, getMessageRequest()); + } + if (messageResponse_ != null) { + output.writeMessage(7, getMessageResponse()); + } + if (notification_ != null) { + output.writeMessage(8, getNotification()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != com.zpf.im.common.bean.msg.ProtoMsg.HeadType.LOGIN_REQUEST.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, type_); + } + if (sequence_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(2, sequence_); + } + if (!getSessionIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, sessionId_); + } + if (loginRequest_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getLoginRequest()); + } + if (loginResponse_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getLoginResponse()); + } + if (messageRequest_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getMessageRequest()); + } + if (messageResponse_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getMessageResponse()); + } + if (notification_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, getNotification()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.zpf.im.common.bean.msg.ProtoMsg.Message)) { + return super.equals(obj); + } + com.zpf.im.common.bean.msg.ProtoMsg.Message other = (com.zpf.im.common.bean.msg.ProtoMsg.Message) obj; + + boolean result = true; + result = result && type_ == other.type_; + result = result && (getSequence() + == other.getSequence()); + result = result && getSessionId() + .equals(other.getSessionId()); + result = result && (hasLoginRequest() == other.hasLoginRequest()); + if (hasLoginRequest()) { + result = result && getLoginRequest() + .equals(other.getLoginRequest()); + } + result = result && (hasLoginResponse() == other.hasLoginResponse()); + if (hasLoginResponse()) { + result = result && getLoginResponse() + .equals(other.getLoginResponse()); + } + result = result && (hasMessageRequest() == other.hasMessageRequest()); + if (hasMessageRequest()) { + result = result && getMessageRequest() + .equals(other.getMessageRequest()); + } + result = result && (hasMessageResponse() == other.hasMessageResponse()); + if (hasMessageResponse()) { + result = result && getMessageResponse() + .equals(other.getMessageResponse()); + } + result = result && (hasNotification() == other.hasNotification()); + if (hasNotification()) { + result = result && getNotification() + .equals(other.getNotification()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + SEQUENCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSequence()); + hash = (37 * hash) + SESSION_ID_FIELD_NUMBER; + hash = (53 * hash) + getSessionId().hashCode(); + if (hasLoginRequest()) { + hash = (37 * hash) + LOGINREQUEST_FIELD_NUMBER; + hash = (53 * hash) + getLoginRequest().hashCode(); + } + if (hasLoginResponse()) { + hash = (37 * hash) + LOGINRESPONSE_FIELD_NUMBER; + hash = (53 * hash) + getLoginResponse().hashCode(); + } + if (hasMessageRequest()) { + hash = (37 * hash) + MESSAGEREQUEST_FIELD_NUMBER; + hash = (53 * hash) + getMessageRequest().hashCode(); + } + if (hasMessageResponse()) { + hash = (37 * hash) + MESSAGERESPONSE_FIELD_NUMBER; + hash = (53 * hash) + getMessageResponse().hashCode(); + } + if (hasNotification()) { + hash = (37 * hash) + NOTIFICATION_FIELD_NUMBER; + hash = (53 * hash) + getNotification().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.zpf.im.common.bean.msg.ProtoMsg.Message parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.zpf.im.common.bean.msg.ProtoMsg.Message prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.zpf.im.common.bean.msg.Message} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.zpf.im.common.bean.msg.Message) + com.zpf.im.common.bean.msg.ProtoMsg.MessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_Message_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.zpf.im.common.bean.msg.ProtoMsg.Message.class, com.zpf.im.common.bean.msg.ProtoMsg.Message.Builder.class); + } + + // Construct using com.zpf.im.common.bean.msg.ProtoMsg.Message.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + type_ = 0; + + sequence_ = 0L; + + sessionId_ = ""; + + if (loginRequestBuilder_ == null) { + loginRequest_ = null; + } else { + loginRequest_ = null; + loginRequestBuilder_ = null; + } + if (loginResponseBuilder_ == null) { + loginResponse_ = null; + } else { + loginResponse_ = null; + loginResponseBuilder_ = null; + } + if (messageRequestBuilder_ == null) { + messageRequest_ = null; + } else { + messageRequest_ = null; + messageRequestBuilder_ = null; + } + if (messageResponseBuilder_ == null) { + messageResponse_ = null; + } else { + messageResponse_ = null; + messageResponseBuilder_ = null; + } + if (notificationBuilder_ == null) { + notification_ = null; + } else { + notification_ = null; + notificationBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.internal_static_com_zpf_im_common_bean_msg_Message_descriptor; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.Message getDefaultInstanceForType() { + return com.zpf.im.common.bean.msg.ProtoMsg.Message.getDefaultInstance(); + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.Message build() { + com.zpf.im.common.bean.msg.ProtoMsg.Message result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.Message buildPartial() { + com.zpf.im.common.bean.msg.ProtoMsg.Message result = new com.zpf.im.common.bean.msg.ProtoMsg.Message(this); + result.type_ = type_; + result.sequence_ = sequence_; + result.sessionId_ = sessionId_; + if (loginRequestBuilder_ == null) { + result.loginRequest_ = loginRequest_; + } else { + result.loginRequest_ = loginRequestBuilder_.build(); + } + if (loginResponseBuilder_ == null) { + result.loginResponse_ = loginResponse_; + } else { + result.loginResponse_ = loginResponseBuilder_.build(); + } + if (messageRequestBuilder_ == null) { + result.messageRequest_ = messageRequest_; + } else { + result.messageRequest_ = messageRequestBuilder_.build(); + } + if (messageResponseBuilder_ == null) { + result.messageResponse_ = messageResponse_; + } else { + result.messageResponse_ = messageResponseBuilder_.build(); + } + if (notificationBuilder_ == null) { + result.notification_ = notification_; + } else { + result.notification_ = notificationBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.zpf.im.common.bean.msg.ProtoMsg.Message) { + return mergeFrom((com.zpf.im.common.bean.msg.ProtoMsg.Message)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.zpf.im.common.bean.msg.ProtoMsg.Message other) { + if (other == com.zpf.im.common.bean.msg.ProtoMsg.Message.getDefaultInstance()) return this; + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.getSequence() != 0L) { + setSequence(other.getSequence()); + } + if (!other.getSessionId().isEmpty()) { + sessionId_ = other.sessionId_; + onChanged(); + } + if (other.hasLoginRequest()) { + mergeLoginRequest(other.getLoginRequest()); + } + if (other.hasLoginResponse()) { + mergeLoginResponse(other.getLoginResponse()); + } + if (other.hasMessageRequest()) { + mergeMessageRequest(other.getMessageRequest()); + } + if (other.hasMessageResponse()) { + mergeMessageResponse(other.getMessageResponse()); + } + if (other.hasNotification()) { + mergeNotification(other.getNotification()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.zpf.im.common.bean.msg.ProtoMsg.Message parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.zpf.im.common.bean.msg.ProtoMsg.Message) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int type_ = 0; + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.HeadType getType() { + @SuppressWarnings("deprecation") + com.zpf.im.common.bean.msg.ProtoMsg.HeadType result = com.zpf.im.common.bean.msg.ProtoMsg.HeadType.valueOf(type_); + return result == null ? com.zpf.im.common.bean.msg.ProtoMsg.HeadType.UNRECOGNIZED : result; + } + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public Builder setType(com.zpf.im.common.bean.msg.ProtoMsg.HeadType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .com.zpf.im.common.bean.msg.HeadType type = 1; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private long sequence_ ; + /** + * uint64 sequence = 2; + */ + public long getSequence() { + return sequence_; + } + /** + * uint64 sequence = 2; + */ + public Builder setSequence(long value) { + + sequence_ = value; + onChanged(); + return this; + } + /** + * uint64 sequence = 2; + */ + public Builder clearSequence() { + + sequence_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object sessionId_ = ""; + /** + * string session_id = 3; + */ + public java.lang.String getSessionId() { + java.lang.Object ref = sessionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sessionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string session_id = 3; + */ + public com.google.protobuf.ByteString + getSessionIdBytes() { + java.lang.Object ref = sessionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + sessionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string session_id = 3; + */ + public Builder setSessionId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + sessionId_ = value; + onChanged(); + return this; + } + /** + * string session_id = 3; + */ + public Builder clearSessionId() { + + sessionId_ = getDefaultInstance().getSessionId(); + onChanged(); + return this; + } + /** + * string session_id = 3; + */ + public Builder setSessionIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sessionId_ = value; + onChanged(); + return this; + } + + private com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest loginRequest_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder> loginRequestBuilder_; + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public boolean hasLoginRequest() { + return loginRequestBuilder_ != null || loginRequest_ != null; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest getLoginRequest() { + if (loginRequestBuilder_ == null) { + return loginRequest_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.getDefaultInstance() : loginRequest_; + } else { + return loginRequestBuilder_.getMessage(); + } + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public Builder setLoginRequest(com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest value) { + if (loginRequestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + loginRequest_ = value; + onChanged(); + } else { + loginRequestBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public Builder setLoginRequest( + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder builderForValue) { + if (loginRequestBuilder_ == null) { + loginRequest_ = builderForValue.build(); + onChanged(); + } else { + loginRequestBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public Builder mergeLoginRequest(com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest value) { + if (loginRequestBuilder_ == null) { + if (loginRequest_ != null) { + loginRequest_ = + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.newBuilder(loginRequest_).mergeFrom(value).buildPartial(); + } else { + loginRequest_ = value; + } + onChanged(); + } else { + loginRequestBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public Builder clearLoginRequest() { + if (loginRequestBuilder_ == null) { + loginRequest_ = null; + onChanged(); + } else { + loginRequest_ = null; + loginRequestBuilder_ = null; + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder getLoginRequestBuilder() { + + onChanged(); + return getLoginRequestFieldBuilder().getBuilder(); + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder getLoginRequestOrBuilder() { + if (loginRequestBuilder_ != null) { + return loginRequestBuilder_.getMessageOrBuilder(); + } else { + return loginRequest_ == null ? + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.getDefaultInstance() : loginRequest_; + } + } + /** + * .com.zpf.im.common.bean.msg.LoginRequest loginRequest = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder> + getLoginRequestFieldBuilder() { + if (loginRequestBuilder_ == null) { + loginRequestBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequest.Builder, com.zpf.im.common.bean.msg.ProtoMsg.LoginRequestOrBuilder>( + getLoginRequest(), + getParentForChildren(), + isClean()); + loginRequest_ = null; + } + return loginRequestBuilder_; + } + + private com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse loginResponse_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder> loginResponseBuilder_; + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public boolean hasLoginResponse() { + return loginResponseBuilder_ != null || loginResponse_ != null; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse getLoginResponse() { + if (loginResponseBuilder_ == null) { + return loginResponse_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.getDefaultInstance() : loginResponse_; + } else { + return loginResponseBuilder_.getMessage(); + } + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public Builder setLoginResponse(com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse value) { + if (loginResponseBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + loginResponse_ = value; + onChanged(); + } else { + loginResponseBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public Builder setLoginResponse( + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder builderForValue) { + if (loginResponseBuilder_ == null) { + loginResponse_ = builderForValue.build(); + onChanged(); + } else { + loginResponseBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public Builder mergeLoginResponse(com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse value) { + if (loginResponseBuilder_ == null) { + if (loginResponse_ != null) { + loginResponse_ = + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.newBuilder(loginResponse_).mergeFrom(value).buildPartial(); + } else { + loginResponse_ = value; + } + onChanged(); + } else { + loginResponseBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public Builder clearLoginResponse() { + if (loginResponseBuilder_ == null) { + loginResponse_ = null; + onChanged(); + } else { + loginResponse_ = null; + loginResponseBuilder_ = null; + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder getLoginResponseBuilder() { + + onChanged(); + return getLoginResponseFieldBuilder().getBuilder(); + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder getLoginResponseOrBuilder() { + if (loginResponseBuilder_ != null) { + return loginResponseBuilder_.getMessageOrBuilder(); + } else { + return loginResponse_ == null ? + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.getDefaultInstance() : loginResponse_; + } + } + /** + * .com.zpf.im.common.bean.msg.LoginResponse loginResponse = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder> + getLoginResponseFieldBuilder() { + if (loginResponseBuilder_ == null) { + loginResponseBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponse.Builder, com.zpf.im.common.bean.msg.ProtoMsg.LoginResponseOrBuilder>( + getLoginResponse(), + getParentForChildren(), + isClean()); + loginResponse_ = null; + } + return loginResponseBuilder_; + } + + private com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest messageRequest_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder> messageRequestBuilder_; + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public boolean hasMessageRequest() { + return messageRequestBuilder_ != null || messageRequest_ != null; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest getMessageRequest() { + if (messageRequestBuilder_ == null) { + return messageRequest_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.getDefaultInstance() : messageRequest_; + } else { + return messageRequestBuilder_.getMessage(); + } + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public Builder setMessageRequest(com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest value) { + if (messageRequestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + messageRequest_ = value; + onChanged(); + } else { + messageRequestBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public Builder setMessageRequest( + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder builderForValue) { + if (messageRequestBuilder_ == null) { + messageRequest_ = builderForValue.build(); + onChanged(); + } else { + messageRequestBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public Builder mergeMessageRequest(com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest value) { + if (messageRequestBuilder_ == null) { + if (messageRequest_ != null) { + messageRequest_ = + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.newBuilder(messageRequest_).mergeFrom(value).buildPartial(); + } else { + messageRequest_ = value; + } + onChanged(); + } else { + messageRequestBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public Builder clearMessageRequest() { + if (messageRequestBuilder_ == null) { + messageRequest_ = null; + onChanged(); + } else { + messageRequest_ = null; + messageRequestBuilder_ = null; + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder getMessageRequestBuilder() { + + onChanged(); + return getMessageRequestFieldBuilder().getBuilder(); + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder getMessageRequestOrBuilder() { + if (messageRequestBuilder_ != null) { + return messageRequestBuilder_.getMessageOrBuilder(); + } else { + return messageRequest_ == null ? + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.getDefaultInstance() : messageRequest_; + } + } + /** + * .com.zpf.im.common.bean.msg.MessageRequest messageRequest = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder> + getMessageRequestFieldBuilder() { + if (messageRequestBuilder_ == null) { + messageRequestBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequest.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageRequestOrBuilder>( + getMessageRequest(), + getParentForChildren(), + isClean()); + messageRequest_ = null; + } + return messageRequestBuilder_; + } + + private com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse messageResponse_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder> messageResponseBuilder_; + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public boolean hasMessageResponse() { + return messageResponseBuilder_ != null || messageResponse_ != null; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse getMessageResponse() { + if (messageResponseBuilder_ == null) { + return messageResponse_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.getDefaultInstance() : messageResponse_; + } else { + return messageResponseBuilder_.getMessage(); + } + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public Builder setMessageResponse(com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse value) { + if (messageResponseBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + messageResponse_ = value; + onChanged(); + } else { + messageResponseBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public Builder setMessageResponse( + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder builderForValue) { + if (messageResponseBuilder_ == null) { + messageResponse_ = builderForValue.build(); + onChanged(); + } else { + messageResponseBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public Builder mergeMessageResponse(com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse value) { + if (messageResponseBuilder_ == null) { + if (messageResponse_ != null) { + messageResponse_ = + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.newBuilder(messageResponse_).mergeFrom(value).buildPartial(); + } else { + messageResponse_ = value; + } + onChanged(); + } else { + messageResponseBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public Builder clearMessageResponse() { + if (messageResponseBuilder_ == null) { + messageResponse_ = null; + onChanged(); + } else { + messageResponse_ = null; + messageResponseBuilder_ = null; + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder getMessageResponseBuilder() { + + onChanged(); + return getMessageResponseFieldBuilder().getBuilder(); + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder getMessageResponseOrBuilder() { + if (messageResponseBuilder_ != null) { + return messageResponseBuilder_.getMessageOrBuilder(); + } else { + return messageResponse_ == null ? + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.getDefaultInstance() : messageResponse_; + } + } + /** + * .com.zpf.im.common.bean.msg.MessageResponse messageResponse = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder> + getMessageResponseFieldBuilder() { + if (messageResponseBuilder_ == null) { + messageResponseBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponse.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageResponseOrBuilder>( + getMessageResponse(), + getParentForChildren(), + isClean()); + messageResponse_ = null; + } + return messageResponseBuilder_; + } + + private com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification notification_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder> notificationBuilder_; + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public boolean hasNotification() { + return notificationBuilder_ != null || notification_ != null; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification getNotification() { + if (notificationBuilder_ == null) { + return notification_ == null ? com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.getDefaultInstance() : notification_; + } else { + return notificationBuilder_.getMessage(); + } + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public Builder setNotification(com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification value) { + if (notificationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + notification_ = value; + onChanged(); + } else { + notificationBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public Builder setNotification( + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder builderForValue) { + if (notificationBuilder_ == null) { + notification_ = builderForValue.build(); + onChanged(); + } else { + notificationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public Builder mergeNotification(com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification value) { + if (notificationBuilder_ == null) { + if (notification_ != null) { + notification_ = + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.newBuilder(notification_).mergeFrom(value).buildPartial(); + } else { + notification_ = value; + } + onChanged(); + } else { + notificationBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public Builder clearNotification() { + if (notificationBuilder_ == null) { + notification_ = null; + onChanged(); + } else { + notification_ = null; + notificationBuilder_ = null; + } + + return this; + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder getNotificationBuilder() { + + onChanged(); + return getNotificationFieldBuilder().getBuilder(); + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + public com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder getNotificationOrBuilder() { + if (notificationBuilder_ != null) { + return notificationBuilder_.getMessageOrBuilder(); + } else { + return notification_ == null ? + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.getDefaultInstance() : notification_; + } + } + /** + * .com.zpf.im.common.bean.msg.MessageNotification notification = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder> + getNotificationFieldBuilder() { + if (notificationBuilder_ == null) { + notificationBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotification.Builder, com.zpf.im.common.bean.msg.ProtoMsg.MessageNotificationOrBuilder>( + getNotification(), + getParentForChildren(), + isClean()); + notification_ = null; + } + return notificationBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.zpf.im.common.bean.msg.Message) + } + + // @@protoc_insertion_point(class_scope:com.zpf.im.common.bean.msg.Message) + private static final com.zpf.im.common.bean.msg.ProtoMsg.Message DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.zpf.im.common.bean.msg.ProtoMsg.Message(); + } + + public static com.zpf.im.common.bean.msg.ProtoMsg.Message getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Message parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Message(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.zpf.im.common.bean.msg.ProtoMsg.Message getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_zpf_im_common_bean_msg_LoginRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_zpf_im_common_bean_msg_LoginRequest_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_zpf_im_common_bean_msg_LoginResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_zpf_im_common_bean_msg_LoginResponse_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_zpf_im_common_bean_msg_MessageRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_zpf_im_common_bean_msg_MessageRequest_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_zpf_im_common_bean_msg_MessageResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_zpf_im_common_bean_msg_MessageResponse_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_zpf_im_common_bean_msg_MessageNotification_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_zpf_im_common_bean_msg_MessageNotification_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_zpf_im_common_bean_msg_Message_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_zpf_im_common_bean_msg_Message_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\016ProtoMsg.proto\022\032com.zpf.im.common.bean" + + ".msg\"c\n\014LoginRequest\022\013\n\003uid\030\001 \001(\t\022\020\n\010dev" + + "iceId\030\002 \001(\t\022\r\n\005token\030\003 \001(\t\022\020\n\010platform\030\004" + + " \001(\r\022\023\n\013app_version\030\005 \001(\t\"K\n\rLoginRespon" + + "se\022\016\n\006result\030\001 \001(\010\022\014\n\004code\030\002 \001(\r\022\014\n\004info" + + "\030\003 \001(\t\022\016\n\006expose\030\004 \001(\r\"\253\001\n\016MessageReques" + + "t\022\016\n\006msg_id\030\001 \001(\004\022\014\n\004from\030\002 \001(\t\022\n\n\002to\030\003 " + + "\001(\t\022\014\n\004time\030\004 \001(\004\022\020\n\010msg_type\030\005 \001(\r\022\017\n\007c" + + "ontent\030\006 \001(\t\022\013\n\003url\030\010 \001(\t\022\020\n\010property\030\t " + + "\001(\t\022\021\n\tfrom_nick\030\n \001(\t\022\014\n\004json\030\013 \001(\t\"v\n\017" + + "MessageResponse\022\016\n\006result\030\001 \001(\010\022\014\n\004code\030" + + "\002 \001(\r\022\014\n\004info\030\003 \001(\t\022\016\n\006expose\030\004 \001(\r\022\022\n\nl" + + "ast_block\030\005 \001(\010\022\023\n\013block_index\030\006 \001(\007\"X\n\023" + + "MessageNotification\022\020\n\010msg_type\030\001 \001(\r\022\016\n" + + "\006sender\030\002 \001(\014\022\014\n\004json\030\003 \001(\t\022\021\n\ttimestamp" + + "\030\004 \001(\t\"\266\003\n\007Message\0222\n\004type\030\001 \001(\0162$.com.z" + + "pf.im.common.bean.msg.HeadType\022\020\n\010sequen" + + "ce\030\002 \001(\004\022\022\n\nsession_id\030\003 \001(\t\022>\n\014loginReq" + + "uest\030\004 \001(\0132(.com.zpf.im.common.bean.msg." + + "LoginRequest\022@\n\rloginResponse\030\005 \001(\0132).co" + + "m.zpf.im.common.bean.msg.LoginResponse\022B" + + "\n\016messageRequest\030\006 \001(\0132*.com.zpf.im.comm" + + "on.bean.msg.MessageRequest\022D\n\017messageRes" + + "ponse\030\007 \001(\0132+.com.zpf.im.common.bean.msg" + + ".MessageResponse\022E\n\014notification\030\010 \001(\0132/" + + ".com.zpf.im.common.bean.msg.MessageNotif" + + "ication*\316\001\n\010HeadType\022\021\n\rLOGIN_REQUEST\020\000\022" + + "\022\n\016LOGIN_RESPONSE\020\001\022\022\n\016LOGOUT_REQUEST\020\002\022" + + "\023\n\017LOGOUT_RESPONSE\020\003\022\025\n\021KEEPALIVE_REQUES" + + "T\020\004\022\026\n\022KEEPALIVE_RESPONSE\020\005\022\023\n\017MESSAGE_R" + + "EQUEST\020\006\022\024\n\020MESSAGE_RESPONSE\020\007\022\030\n\024MESSAG" + + "E_NOTIFICATION\020\010b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_com_zpf_im_common_bean_msg_LoginRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_com_zpf_im_common_bean_msg_LoginRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_zpf_im_common_bean_msg_LoginRequest_descriptor, + new java.lang.String[] { "Uid", "DeviceId", "Token", "Platform", "AppVersion", }); + internal_static_com_zpf_im_common_bean_msg_LoginResponse_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_com_zpf_im_common_bean_msg_LoginResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_zpf_im_common_bean_msg_LoginResponse_descriptor, + new java.lang.String[] { "Result", "Code", "Info", "Expose", }); + internal_static_com_zpf_im_common_bean_msg_MessageRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_com_zpf_im_common_bean_msg_MessageRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_zpf_im_common_bean_msg_MessageRequest_descriptor, + new java.lang.String[] { "MsgId", "From", "To", "Time", "MsgType", "Content", "Url", "Property", "FromNick", "Json", }); + internal_static_com_zpf_im_common_bean_msg_MessageResponse_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_com_zpf_im_common_bean_msg_MessageResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_zpf_im_common_bean_msg_MessageResponse_descriptor, + new java.lang.String[] { "Result", "Code", "Info", "Expose", "LastBlock", "BlockIndex", }); + internal_static_com_zpf_im_common_bean_msg_MessageNotification_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_com_zpf_im_common_bean_msg_MessageNotification_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_zpf_im_common_bean_msg_MessageNotification_descriptor, + new java.lang.String[] { "MsgType", "Sender", "Json", "Timestamp", }); + internal_static_com_zpf_im_common_bean_msg_Message_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_com_zpf_im_common_bean_msg_Message_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_zpf_im_common_bean_msg_Message_descriptor, + new java.lang.String[] { "Type", "Sequence", "SessionId", "LoginRequest", "LoginResponse", "MessageRequest", "MessageResponse", "Notification", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/chat/src/main/java/com/zpf/im/common/bean/msg/User.java b/chat/src/main/java/com/zpf/im/common/bean/msg/User.java new file mode 100644 index 0000000000000000000000000000000000000000..7c6e3aa19f47cef6ff4a7abb6156b7522f28eaf3 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/bean/msg/User.java @@ -0,0 +1,52 @@ +package com.zpf.im.common.bean.msg; + +import lombok.Data; + +@Data +public class User { + String uid; + String devId; + String token; + String nickName = "nickName"; + PLATTYPE platForm = PLATTYPE.WINDOWS; + + + public enum PLATTYPE { + WINDOWS, MAC, ANDROID, IOS, WEB, OTHER; + } + + + private String sessionId; + + public void setPlatform(int platForm) { + PLATTYPE[] values = PLATTYPE.values(); + for (int i = 0; i < values.length; i++) { + if (values[i].ordinal() == platForm) { + this.platForm = values[i]; + } + } + } + + + @Override + public String toString() { + return "User{" + + "uid='" + uid + '\'' + + ", devId='" + devId + '\'' + + ", token='" + token + '\'' + + ", nickName='" + nickName + '\'' + + ", platForm=" + platForm + + ", sessionId='" + sessionId + '\'' + + '}'; + } + + public static User fromMsg(ProtoMsg.LoginRequest info){ + User user = new User(); + user.uid = new String(info.getUid()); + user.token = new String(info.getToken()); + user.setPlatform(info.getPlatform()); + System.out.println("登录中===>"+user.nickName); + return user; + } + +} diff --git a/chat/src/main/java/com/zpf/im/common/cocurrent/ExecuteTask.java b/chat/src/main/java/com/zpf/im/common/cocurrent/ExecuteTask.java new file mode 100644 index 0000000000000000000000000000000000000000..4ca77c93042be7f7d9c6ed24e9cc460d19bc62f2 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/cocurrent/ExecuteTask.java @@ -0,0 +1,7 @@ +package com.zpf.im.common.cocurrent; + +public interface ExecuteTask { + + void execute(); + +} diff --git a/chat/src/main/java/com/zpf/im/common/cocurrent/FutureTaskScheduler.java b/chat/src/main/java/com/zpf/im/common/cocurrent/FutureTaskScheduler.java new file mode 100644 index 0000000000000000000000000000000000000000..f69276402fd18dc39f72b37dcee7357f3537c239 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/cocurrent/FutureTaskScheduler.java @@ -0,0 +1,85 @@ +package com.zpf.im.common.cocurrent; + +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class FutureTaskScheduler extends Thread{ + + private ConcurrentLinkedQueue executeTaskQueue = new ConcurrentLinkedQueue<>(); + + private long sleepTime = 200; + + private ExecutorService pool = Executors.newFixedThreadPool(10); + + private static FutureTaskScheduler instance = new FutureTaskScheduler(); + + private FutureTaskScheduler(){ + this.start(); + } + + + public static void add(ExecuteTask task){ + instance.executeTaskQueue.add(task); + } + + + @Override + public void run() { + while (true){ + handleTask(); + threadSleep(sleepTime); + } + } + + private void threadSleep(long sleepTime) { + try{ + sleep(sleepTime); + }catch (Exception e){ + e.printStackTrace(); + } + + + } + + /** + * 处理任务对列 + */ + private void handleTask() { + try{ + ExecuteTask executeTask; + while (executeTaskQueue.peek() != null){ + executeTask = executeTaskQueue.poll(); + handleTask(executeTask); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** + * 执行任务操作 + * @param executeTask + */ + private void handleTask(ExecuteTask executeTask){ + pool.execute(new ExecuteRunnable(executeTask)); + + } + + + class ExecuteRunnable implements Runnable{ + ExecuteTask executeTask; + + ExecuteRunnable(ExecuteTask executeTask){ + this.executeTask = executeTask; + } + + @Override + public void run() { + executeTask.execute(); + } + } + + + +} diff --git a/chat/src/main/java/com/zpf/im/common/codec/ProtobufDecoder.java b/chat/src/main/java/com/zpf/im/common/codec/ProtobufDecoder.java new file mode 100644 index 0000000000000000000000000000000000000000..c72b7440b682fa9af6f5c95b9f7f23fc6c6bf0db --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/codec/ProtobufDecoder.java @@ -0,0 +1,67 @@ +package com.zpf.im.common.codec; + +import com.zpf.im.common.ProtoInstant; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.ByteToMessageDecoder; + +import java.util.List; + +public class ProtobufDecoder extends ByteToMessageDecoder { + + @Override + protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { + + //标记一下当前的readIndex的位置 + in.markReaderIndex(); + + //判断包头长度 + if (in.readableBytes() < 8){//不够包头 + return; + } + + short magic = in.readShort(); + if (magic != ProtoInstant.MAGIC_CODE){ + String error = "客户端口令不对:"+ctx.channel().remoteAddress(); + throw new Exception(error); + } + + //读取版本 + short version = in.readShort(); + //读取消息长度 + int length = in.readInt(); + + if (length < 0){ + ctx.close(); + } + + //读到的消息体长度小于传过来的消息体长度 + if(length > in.readableBytes()){ + //重置读取位置 + in.resetReaderIndex(); + return; + } + + + + byte[] array; + if (in.hasArray()){ + //堆缓冲区 + ByteBuf slice = in.slice(); + array = slice.array(); + }else { + //直接缓冲 + array = new byte[length]; + in.readBytes(array,0,length); + } + + //字节转换成对象 + ProtoMsg.Message outMsg = ProtoMsg.Message.parseFrom(array); + + if (outMsg != null){ + out.add(outMsg); + } + + + } +} diff --git a/chat/src/main/java/com/zpf/im/common/codec/ProtobufEncoder.java b/chat/src/main/java/com/zpf/im/common/codec/ProtobufEncoder.java new file mode 100644 index 0000000000000000000000000000000000000000..990e17523ca8f929ca38ba699b64d245846d1702 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/codec/ProtobufEncoder.java @@ -0,0 +1,27 @@ +package com.zpf.im.common.codec; + +import com.zpf.im.common.ProtoInstant; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToByteEncoder; + +public class ProtobufEncoder extends MessageToByteEncoder { + @Override + protected void encode(ChannelHandlerContext ctx, ProtoMsg.Message msg, ByteBuf out) throws Exception { + out.writeShort(ProtoInstant.MAGIC_CODE); + out.writeShort(ProtoInstant.VERSION_CODE); + + byte[] bytes = msg.toByteArray(); + + + int length = bytes.length; + + //消息长度写入 + out.writeInt(length); + + //消息体重包含要发送的数据 + out.writeBytes(bytes); + + + } +} diff --git a/chat/src/main/java/com/zpf/im/common/exception/InvalidFrameException.java b/chat/src/main/java/com/zpf/im/common/exception/InvalidFrameException.java new file mode 100644 index 0000000000000000000000000000000000000000..9622e9873ae9a0d9d9284f66cec0c59cd96be5c7 --- /dev/null +++ b/chat/src/main/java/com/zpf/im/common/exception/InvalidFrameException.java @@ -0,0 +1,11 @@ +package com.zpf.im.common.exception; + +public class InvalidFrameException extends Exception { + + + public InvalidFrameException(String s) { + super(s); + } + + +} diff --git a/chatClient/pom.xml b/chatClient/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..461fc4569032528cbc26c4f9822989fefc8e14b2 --- /dev/null +++ b/chatClient/pom.xml @@ -0,0 +1,23 @@ + + + + my_netty + com.zpf + 1.0-SNAPSHOT + + 4.0.0 + + chatClient + + + + com.zpf + chat + 1.0-SNAPSHOT + + + + + \ No newline at end of file diff --git a/chatClient/src/main/java/com/zpf/imClient/client/ClientApplication.java b/chatClient/src/main/java/com/zpf/imClient/client/ClientApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..bf7eb444ef5327f89246bd67bea8aa5fc590ffd3 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/client/ClientApplication.java @@ -0,0 +1,28 @@ +package com.zpf.imClient.client; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableAutoConfiguration +@ComponentScan("com.zpf.imClient") +public class ClientApplication { + + public static void main(String[] args) { + ApplicationContext context = SpringApplication.run(ClientApplication.class, args); + CommandClient commandClient = context.getBean(CommandClient.class); + + commandClient.initCommandMap(); + + try{ + commandClient.startCommandThread(); + }catch (Exception e){ + e.printStackTrace(); + } + + + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/client/ClientSession.java b/chatClient/src/main/java/com/zpf/imClient/client/ClientSession.java new file mode 100644 index 0000000000000000000000000000000000000000..48a927ee80e30cfa6e173b4af7b36e6a9516d205 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/client/ClientSession.java @@ -0,0 +1,136 @@ +package com.zpf.imClient.client; + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.im.common.bean.msg.User; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.AttributeKey; +import lombok.Getter; +import lombok.Setter; + +import java.util.HashMap; +import java.util.Map; + +@Getter +@Setter +public class ClientSession { + + public static final AttributeKey SESSION_KEY = + AttributeKey.valueOf("SESSION_KEY"); + + /** + * 用户实现客户端回话管理的核心 + */ + private Channel channel; + private User user; + + + private String sessionId; + + + public boolean isConnected = false; + public boolean isLogin = false; + + + /** + * session中存储的session变量属性值 + */ + private Map map = new HashMap<>(); + + //绑定通道 + public ClientSession (Channel channel){ + this.channel = channel; + this.sessionId = String.valueOf(-1); + channel.attr(ClientSession.SESSION_KEY).set(this); + } + + + + //登录成功之后,设置sessionId + public static void loginSuccess(ChannelHandlerContext ctx, ProtoMsg.Message pkg){ + Channel channel = ctx.channel(); + ClientSession clientSession = channel.attr(ClientSession.SESSION_KEY).get(); + clientSession.sessionId = pkg.getSessionId(); + clientSession.isLogin = true; + System.out.println("登录成功"); + } + + + + //获取channel + public static ClientSession getSession(ChannelHandlerContext ctx){ + Channel channel = ctx.channel(); + ClientSession session = channel.attr(ClientSession.SESSION_KEY).get(); + return session; + } + + + + + public String getRemoteAddress(){ + return channel.remoteAddress().toString(); + } + + //写protobuf 数据帧 + public ChannelFuture writeAndFlush(Object pkg){ + ChannelFuture future = channel.writeAndFlush(pkg); + return future; + } + + + public void writeAndClose(Object pkg){ + ChannelFuture future = channel.writeAndFlush(pkg); + future.addListener(ChannelFutureListener.CLOSE); + } + + + //关闭通道 + public void close(){ + isConnected = false; + + ChannelFuture future = channel.close(); + future.addListener(new ChannelFutureListener() { + @Override + public void operationComplete(ChannelFuture future) throws Exception { + if (future.isSuccess()){ + System.out.println("连接顺利断开"); + } + } + }); + + + + + + + + + + + + } + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/chatClient/src/main/java/com/zpf/imClient/client/CommandClient.java b/chatClient/src/main/java/com/zpf/imClient/client/CommandClient.java new file mode 100644 index 0000000000000000000000000000000000000000..b23c964d1566d7f4149cc5753943840bed25b8b0 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/client/CommandClient.java @@ -0,0 +1,91 @@ +package com.zpf.imClient.client; + +import com.zpf.imClient.command.*; +import com.zpf.imClient.sender.ChatSender; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.nio.channels.Channel; +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Data +@Service("CommandController") +public class CommandClient { + //聊天命令收集类 + @Autowired + ChatConsoleCommand chatConsoleCommand; + + //登录命令收集类 + @Autowired + LoginConsoleCommand loginConsoleCommand; + + //登出命令收集类 + @Autowired + LogoutConsoleCommand logoutConsoleCommand; + + //菜单命令收集类 + @Autowired + ClientCommandMenu clientCommandMenu; + + private Map commandMap; + + private String menuString; + + //会话类 + private ClientSession session; + + @Autowired + private NettyClient nettyClient; + + private Channel channel; + + @Autowired + private ChatSender chatSender; + + private boolean connectFlag = false; + + + + private Map commandMap; + + + + //命令收集线程 + public void startCommandThread(){ + Thread.currentThread().setName("命令线程"); + + while (true){ + //建立连接 + while (connectFlag == false){ + //开始连接 + startConnectServer(); + waitCommandThread(); + } + + } + + + + + } + + private void waitCommandThread() { + + + } + + + public void startConnectServer() { + FutureTaskSchedu + } + + + public void initCommandMap() { + commandMap = new HashMap<>(); + commandMap.put() + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/client/NettyClient.java b/chatClient/src/main/java/com/zpf/imClient/client/NettyClient.java new file mode 100644 index 0000000000000000000000000000000000000000..7d9dbddb6af9d35680c97df58a41edc1fdbf87be --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/client/NettyClient.java @@ -0,0 +1,102 @@ +package com.zpf.imClient.client; + +import com.zpf.im.common.bean.msg.User; +import com.zpf.im.common.codec.ProtobufDecoder; +import com.zpf.im.common.codec.ProtobufEncoder; +import com.zpf.imClient.handler.ChatMsgHandler; +import com.zpf.imClient.handler.ExceptionHandler; +import com.zpf.imClient.handler.LoginResponceHandler; +import com.zpf.imClient.sender.ChatSender; +import com.zpf.imClient.sender.LoginSender; +import io.netty.bootstrap.Bootstrap; +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.channel.*; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.util.concurrent.GenericFutureListener; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +@Slf4j +@Data +@Service("NettyClient") +public class NettyClient { + + @Value("${server.ip}") + private String host; + @Value("${server.port}") + private int port; + + + @Autowired + private ChatMsgHandler chatMsgHandler; + + @Autowired + private LoginResponceHandler loginResponceHandler; + + @Autowired + private ExceptionHandler exceptionHandler; + + + + private Channel channel; + private ChatSender chatSender; + private LoginSender loginSender; + + + + private boolean initFlag = true; + private User user; + private GenericFutureListener connectedListener; + + private Bootstrap b; + private EventLoopGroup g; + + + public NettyClient() { + g = new NioEventLoopGroup(); + } + + /** + * 重连 + */ + public void doConnect() { + + try { + b = new Bootstrap(); + + b.group(g); + b.channel(NioSocketChannel.class).option(ChannelOption.SO_KEEPALIVE,true) + .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); + b.remoteAddress(host,port); + + b.handler(new ChannelInitializer() { + @Override + protected void initChannel(SocketChannel ch) throws Exception { + ch.pipeline().addLast("decoder",new ProtobufDecoder()) + .addLast("encoder",new ProtobufEncoder()) + .addLast(loginResponceHandler) + .addLast(chatMsgHandler) + .addLast(exceptionHandler); + } + }); + + log.info("客户端开始连接"); + ChannelFuture future = b.connect(); + future.addListener(connectedListener); + + // + future.channel().closeFuture().await(); + + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + +} diff --git a/chatClient/src/main/java/com/zpf/imClient/command/BaseCommand.java b/chatClient/src/main/java/com/zpf/imClient/command/BaseCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..7ea7311298e299175a959eee071340024dd83d51 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/command/BaseCommand.java @@ -0,0 +1,11 @@ +package com.zpf.imClient.command; + +import java.util.Scanner; + +public interface BaseCommand { + void exec(Scanner scanner); + + String getKey(); + + String getTip(); +} diff --git a/chatClient/src/main/java/com/zpf/imClient/command/ChatConsoleCommand.java b/chatClient/src/main/java/com/zpf/imClient/command/ChatConsoleCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..a23daef8e75b56e06b8d1b473d929338451c7c7a --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/command/ChatConsoleCommand.java @@ -0,0 +1,46 @@ +package com.zpf.imClient.command; + +import com.zpf.imClient.command.BaseCommand; +import lombok.Data; +import org.springframework.stereotype.Service; + +import java.util.Scanner; + +@Data +@Service("ChatConsoleCommand") +public class ChatConsoleCommand implements BaseCommand { + + private String toUserId; + private String message; + public static final String KEY = "2"; + + @Override + public void exec(Scanner scanner) { + System.out.print("请输入聊天的消息(id:message):"); + String[] info = null; + while (true) { + String input = scanner.next(); + info = input.split(":"); + if (info.length != 2) { + System.out.println("请输入聊天的消息(id:message):"); + } else { + break; + } + } + toUserId = info[0]; + message = info[1]; + } + + + @Override + public String getKey() { + return KEY; + } + + @Override + public String getTip() { + return "聊天"; + } + +} + diff --git a/chatClient/src/main/java/com/zpf/imClient/command/ClientCommandMenu.java b/chatClient/src/main/java/com/zpf/imClient/command/ClientCommandMenu.java new file mode 100644 index 0000000000000000000000000000000000000000..cd366a8a45642311ebb6b931be09770c1b32b328 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/command/ClientCommandMenu.java @@ -0,0 +1,39 @@ +package com.zpf.imClient.command; + +import lombok.Data; +import org.springframework.stereotype.Service; + +import java.util.Scanner; + +@Data +@Service("ClientCommandMenu") +public class ClientCommandMenu implements BaseCommand { + + public static final String KEY = "0"; + + private String allCommandsShow; + private String commandInput; + + @Override + public void exec(Scanner scanner) { + + System.err.println("请输入某个操作指令:"); + System.err.println(allCommandsShow); + // 获取第一个指令 + commandInput = scanner.next(); + + + } + + + @Override + public String getKey() { + return KEY; + } + + @Override + public String getTip() { + return "show 所有命令"; + } + +} diff --git a/chatClient/src/main/java/com/zpf/imClient/command/LoginConsoleCommand.java b/chatClient/src/main/java/com/zpf/imClient/command/LoginConsoleCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..f5e45e1a5071ce31ff70c98a67ef1c04f920ecb1 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/command/LoginConsoleCommand.java @@ -0,0 +1,43 @@ +package com.zpf.imClient.command; + +import com.zpf.imClient.command.BaseCommand; +import lombok.Data; +import org.springframework.stereotype.Service; + +import java.util.Scanner; +@Data +@Service +public class LoginConsoleCommand implements BaseCommand { + public static final String KEY = "1"; + + private String userName; + private String password; + + @Override + public void exec(Scanner scanner) { + System.out.println("请输入用户信息(id:password)"); + String[] info = null; + + while (true){ + String input = scanner.next(); + info = input.split(":"); + if (info.length != 2){ + System.out.println("请按格式输入(id:password)"); + }else { + break; + } + } + userName = info[0]; + password = info[1]; + } + + @Override + public String getKey() { + return KEY; + } + + @Override + public String getTip() { + return "登录"; + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/command/LogoutConsoleCommand.java b/chatClient/src/main/java/com/zpf/imClient/command/LogoutConsoleCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..56e1754d317c10f31893b322a2f91b45f133540a --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/command/LogoutConsoleCommand.java @@ -0,0 +1,28 @@ +package com.zpf.imClient.command; + +import com.zpf.imClient.command.BaseCommand; +import org.springframework.stereotype.Service; + +import java.util.Scanner; + +@Service("LogoutConsoleCommand") +public class LogoutConsoleCommand implements BaseCommand { + public static final String KEY = "10"; + + @Override + public void exec(Scanner scanner) { + + } + + + @Override + public String getKey() { + return KEY; + } + + @Override + public String getTip() { + return "退出"; + } + +} diff --git a/chatClient/src/main/java/com/zpf/imClient/handler/ChatMsgHandler.java b/chatClient/src/main/java/com/zpf/imClient/handler/ChatMsgHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..1108fb26c569a26fb0935471b19df88367deb465 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/handler/ChatMsgHandler.java @@ -0,0 +1,42 @@ +package com.zpf.imClient.handler; + +import com.zpf.im.common.bean.msg.ProtoMsg; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import org.springframework.stereotype.Component; + +@ChannelHandler.Sharable +@Component("ChatMsgHandler") +public class ChatMsgHandler extends ChannelInboundHandlerAdapter { + public ChatMsgHandler(){ + + } + + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + if (null == msg || !(msg instanceof ProtoMsg.Message)){ + super.channelRead(ctx,msg); + //ctx.fireChannelRead(msg); + return; + } + + + + ProtoMsg.Message pkg = (ProtoMsg.Message) msg; + ProtoMsg.HeadType headType = pkg.getType(); + if (!headType.equals(ProtoMsg.HeadType.MESSAGE_REQUEST)){ + super.channelRead(ctx,msg); + return; + } + + + ProtoMsg.MessageRequest req = pkg.getMessageRequest(); + String content = req.getContent(); + String uid= req.getFrom(); + + System.out.println("收到消息从 uid:"+uid+"-->"+content); + + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/handler/ExceptionHandler.java b/chatClient/src/main/java/com/zpf/imClient/handler/ExceptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..e23c20a81ec97f5d8ced7fab5e388ad00d87f7fa --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/handler/ExceptionHandler.java @@ -0,0 +1,50 @@ +package com.zpf.imClient.handler; + +import com.zpf.im.common.exception.InvalidFrameException; +import com.zpf.imClient.client.ClientSession; +import com.zpf.imClient.client.CommandClient; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Slf4j +@ChannelHandler.Sharable +@Component("ExceptionHandler") +public class ExceptionHandler extends ChannelInboundHandlerAdapter { + + + @Autowired + private CommandClient commandClient; + + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + if (cause instanceof InvalidFrameException){ + log.error(cause.getMessage()); + ClientSession.getSession(ctx).close(); + }else { + //捕捉异常信息 + log.error(cause.getMessage()); + ctx.close(); + + + //重连 + commandClient.setConnectFlag(false); + commandClient.startConnectServer(); + } + } + + /** + * 通道 read 读取 complete 完成 + * 刷洗 flush + * @param ctx + * @throws Exception + */ + @Override + public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { + ctx.flush(); + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/handler/HeartBeatClientHandler.java b/chatClient/src/main/java/com/zpf/imClient/handler/HeartBeatClientHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..63eee2527d919e463aae5df6f125332df38b7b9c --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/handler/HeartBeatClientHandler.java @@ -0,0 +1,78 @@ +package com.zpf.imClient.handler; + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.im.common.bean.msg.User; +import com.zpf.imClient.client.ClientSession; +import com.zpf.imClient.protoBuilder.HeartBeatMsgBuilder; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +@Slf4j +@Component("HeartBeatClientHandler") +@ChannelHandler.Sharable +public class HeartBeatClientHandler extends ChannelInboundHandlerAdapter { + + //心跳时间间隔 s + private static final int HEART_INTERVAL = 100; + + + //handler被添加到pipline时,开始发送心跳 + @Override + public void handlerAdded(ChannelHandlerContext ctx) throws Exception { + ClientSession session = ClientSession.getSession(ctx); + User user = session.getUser(); + HeartBeatMsgBuilder builder = new HeartBeatMsgBuilder(user, session); + + ProtoMsg.Message message = builder.buildMsg(); + //发送心跳 + heartBeat(ctx, message); + } + + //使用定时器,发送心跳报文 + private void heartBeat(ChannelHandlerContext ctx, ProtoMsg.Message message) { + ctx.executor().schedule(new Runnable() { + @Override + public void run() { + if (ctx.channel().isActive()) { + log.info("发送 HEART_BEAT 消息到 server"); + ctx.writeAndFlush(message); + + //递归调用 + heartBeat(ctx, message); + } + } + }, HEART_INTERVAL, TimeUnit.SECONDS); + } + + //接受到服务器的心跳回写 + + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + + if (null == msg || !(msg instanceof ProtoMsg.Message)) { + super.channelRead(ctx, msg); + return; + } + + + //判断类型 + ProtoMsg.Message pkg = (ProtoMsg.Message) msg; + + ProtoMsg.HeadType headType = pkg.getType(); + + if (headType.equals(ProtoMsg.HeadType.HEART_BEAT)) { + log.info("收到回写的 HEART_BEAT 消息 从 server"); + return; + } else { + super.channelRead(ctx, msg); + } + + + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/handler/LoginResponceHandler.java b/chatClient/src/main/java/com/zpf/imClient/handler/LoginResponceHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..2dc96fbd4971b297700ba61dce5f36c9193552d8 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/handler/LoginResponceHandler.java @@ -0,0 +1,55 @@ +package com.zpf.imClient.handler; + +import com.zpf.im.common.ProtoInstant; +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.imClient.client.ClientSession; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelPipeline; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Slf4j +@ChannelHandler.Sharable +@Component("LoginResponceHandler") +public class LoginResponceHandler extends ChannelInboundHandlerAdapter { + + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + if (null == msg || !(msg instanceof ProtoMsg.Message)){ + super.channelRead(ctx,msg); + return; + } + + //判断类型 + ProtoMsg.Message pkg = (ProtoMsg.Message) msg; + ProtoMsg.HeadType headType = ((ProtoMsg.Message) msg).getType(); + if (!headType.equals(ProtoMsg.HeadType.LOGIN_RESPONSE)){ + super.channelRead(ctx,msg); + return; + } + + + + //判断返回是否成功 + ProtoMsg.LoginResponse info = pkg.getLoginResponse(); + ProtoInstant.ResultCodeEnum result = ProtoInstant.ResultCodeEnum.values()[info.getCode()]; + if (!result.equals(ProtoInstant.ResultCodeEnum.SUCCESS)){ + log.info(result.getDesc()); + }else { + //登录成功 + ClientSession.loginSuccess(ctx,pkg); + ChannelPipeline p = ctx.pipeline(); + + //移除登录响应handler + p.remove(this); + + //动态插入心跳处理器 + p.addAfter("encoder","heartbeat",new HeartBeatClientHandler()); + } + + + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/protoBuilder/BaseBuilder.java b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/BaseBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..99849c9699ddb9eb1d7a4740ed441b2b808dffd7 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/BaseBuilder.java @@ -0,0 +1,37 @@ +package com.zpf.imClient.protoBuilder; + + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.imClient.client.ClientSession; + +/** + * 基础 Builder + * + * @author 尼恩 at 疯狂创客圈 + */ +public class BaseBuilder { + protected ProtoMsg.HeadType type; + private long seqId; + private ClientSession session; + + public BaseBuilder(ProtoMsg.HeadType type, ClientSession session) { + this.type = type; + this.session = session; + } + + /** + * 构建消息 基础部分 + */ + public ProtoMsg.Message buildCommon(long seqId) { + this.seqId = seqId; + + ProtoMsg.Message.Builder mb = + ProtoMsg.Message + .newBuilder() + .setType(type) + .setSessionId(session.getSessionId()) + .setSequence(seqId); + return mb.buildPartial(); + } + +} diff --git a/chatClient/src/main/java/com/zpf/imClient/protoBuilder/ChatMsgBuilder.java b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/ChatMsgBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..7003ba16d4dfc79ec9391197d79b42e6f7f8d3fd --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/ChatMsgBuilder.java @@ -0,0 +1,54 @@ +/** + * Created by 尼恩 at 疯狂创客圈 + */ + +package com.zpf.imClient.protoBuilder; + + +import com.zpf.im.common.bean.msg.ChatMsg; +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.im.common.bean.msg.ProtoMsg.HeadType; +import com.zpf.im.common.bean.msg.User; +import com.zpf.imClient.client.ClientSession; + +/** + * 聊天消息Builder + */ + +public class ChatMsgBuilder extends BaseBuilder { + + + private ChatMsg chatMsg; + private User user; + + + public ChatMsgBuilder(ChatMsg chatMsg, User user, ClientSession session) { + super(HeadType.MESSAGE_REQUEST, session); + this.chatMsg = chatMsg; + this.user = user; + + } + + + public ProtoMsg.Message build() { + ProtoMsg.Message message = buildCommon(-1); + ProtoMsg.MessageRequest.Builder cb + = ProtoMsg.MessageRequest.newBuilder(); + + chatMsg.fillMsg(cb); + return message + .toBuilder() + .setMessageRequest(cb) + .build(); + } + + public static ProtoMsg.Message buildChatMsg( + ChatMsg chatMsg, + User user, + ClientSession session) { + ChatMsgBuilder builder = + new ChatMsgBuilder(chatMsg, user, session); + return builder.build(); + + } +} \ No newline at end of file diff --git a/chatClient/src/main/java/com/zpf/imClient/protoBuilder/HeartBeatMsgBuilder.java b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/HeartBeatMsgBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..9689509b674518581b9b13b60cb442ae4c4a4b80 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/HeartBeatMsgBuilder.java @@ -0,0 +1,36 @@ +/** + * Created by 尼恩 at 疯狂创客圈 + */ + +package com.zpf.imClient.protoBuilder; + + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.im.common.bean.msg.User; +import com.zpf.imClient.client.ClientSession; + +/** + * 心跳消息Builder + */ +public class HeartBeatMsgBuilder extends BaseBuilder { + private final User user; + + public HeartBeatMsgBuilder(User user, ClientSession session) { + super(ProtoMsg.HeadType.HEART_BEAT, session); + this.user = user; + } + + public ProtoMsg.Message buildMsg() { + ProtoMsg.Message message = buildCommon(-1); + ProtoMsg.MessageNotification.Builder lb = + ProtoMsg.MessageHeartBeat.newBuilder() + .setSeq(0) + .setJson("{\"from\":\"client\"}") + .setUid(user.getUid()); + return message.toBuilder().setHeartBeat(lb).build(); + } + + +} + + diff --git a/chatClient/src/main/java/com/zpf/imClient/protoBuilder/LoginMsgBuilder.java b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/LoginMsgBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..6d0abb678982ccef056e289ea3ed91a96f8be582 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/protoBuilder/LoginMsgBuilder.java @@ -0,0 +1,43 @@ +/** + * Created by 尼恩 at 疯狂创客圈 + */ + +package com.zpf.imClient.protoBuilder; + + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.im.common.bean.msg.User; +import com.zpf.imClient.client.ClientSession; + +/** + * 登陆消息Builder + */ +public class LoginMsgBuilder extends BaseBuilder { + private final User user; + + public LoginMsgBuilder(User user, ClientSession session) { + super(ProtoMsg.HeadType.LOGIN_REQUEST, session); + this.user = user; + } + + public ProtoMsg.Message build() { + ProtoMsg.Message message = buildCommon(-1); + ProtoMsg.LoginRequest.Builder lb = + ProtoMsg.LoginRequest.newBuilder() + .setDeviceId(user.getDevId()) + .setPlatform(user.getPlatForm().ordinal()) + .setToken(user.getToken()) + .setUid(user.getUid()); + return message.toBuilder().setLoginRequest(lb).build(); + } + + public static ProtoMsg.Message buildLoginMsg( + User user, ClientSession session) { + LoginMsgBuilder builder = + new LoginMsgBuilder(user, session); + return builder.build(); + + } +} + + diff --git a/chatClient/src/main/java/com/zpf/imClient/sender/BaseSender.java b/chatClient/src/main/java/com/zpf/imClient/sender/BaseSender.java new file mode 100644 index 0000000000000000000000000000000000000000..f2c1d5fdfdb5ae0ba1679b2480e275c56775ef21 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/sender/BaseSender.java @@ -0,0 +1,65 @@ +package com.zpf.imClient.sender; + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.im.common.bean.msg.User; +import com.zpf.imClient.client.ClientSession; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import lombok.Data; +@Data +public abstract class BaseSender { + private User user; + private ClientSession session; + + public boolean isConnected(){ + if (null == session){ + System.out.println("session is null" ); + return false; + } + return session.isConnected; + } + + + public boolean isLogin(){ + if (null == session){ + return false; + } + return session.isLogin; + } + + + + public void sendMsg(ProtoMsg.Message message){ + + if (null == getSession() || !isConnected()){ + System.out.println("连接还没成功"); + return; + } + + Channel channel = getSession().getChannel(); + ChannelFuture future = channel.writeAndFlush(message); + future.addListener(new GenericFutureListener>() { + @Override + public void operationComplete(Future future) throws Exception { + if (future.isSuccess()){ + sendSuccees(message); + } else { + sendFailed(message); + } + } + }); + + + } + + protected void sendFailed(ProtoMsg.Message message){ + System.out.println("发送成功"); + }; + + protected void sendSuccees(ProtoMsg.Message message){ + System.out.println("发送失败"); + }; + +} diff --git a/chatClient/src/main/java/com/zpf/imClient/sender/ChatSender.java b/chatClient/src/main/java/com/zpf/imClient/sender/ChatSender.java new file mode 100644 index 0000000000000000000000000000000000000000..60df002d5300c0ca3333b093c0263673bc539983 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/sender/ChatSender.java @@ -0,0 +1,36 @@ +package com.zpf.imClient.sender; + +import com.zpf.im.common.bean.msg.ChatMsg; +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.imClient.protoBuilder.ChatMsgBuilder; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service("ChatSender") +@Slf4j +public class ChatSender extends BaseSender { + + + public void sendChatMsg(String touid,String content){ + log.info("发送消息 startConnectServer"); + ChatMsg chatMsg = new ChatMsg(getUser()); + chatMsg.setContent(content); + chatMsg.setMsgType(ChatMsg.MSGTYPE.TEXT); + chatMsg.setTo(touid); + chatMsg.setMsgId(System.currentTimeMillis()); + ProtoMsg.Message message = ChatMsgBuilder.buildChatMsg(chatMsg, getUser(), getSession()); + super.sendMsg(message); + } + + + @Override + protected void sendSuccees(ProtoMsg.Message message) { + log.info("发送成功:"+message.getMessageRequest().getContent()); + } + + + @Override + protected void sendFailed(ProtoMsg.Message message) { + log.info("发送失败:"+message.getMessageRequest().getContent()); + } +} diff --git a/chatClient/src/main/java/com/zpf/imClient/sender/LoginSender.java b/chatClient/src/main/java/com/zpf/imClient/sender/LoginSender.java new file mode 100644 index 0000000000000000000000000000000000000000..87156f4b130acf5083251a341b5cb9a277937e41 --- /dev/null +++ b/chatClient/src/main/java/com/zpf/imClient/sender/LoginSender.java @@ -0,0 +1,31 @@ +package com.zpf.imClient.sender; + +import com.zpf.im.common.bean.msg.ProtoMsg; +import com.zpf.imClient.protoBuilder.LoginMsgBuilder; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +@Slf4j +@Service("LoginSender") +public class LoginSender extends BaseSender { + + + public void dendLoginMsg(){ + if (!isConnected()){ + log.info("还没有建立连接"); + return; + } + log.info("构造登录消息"); + ProtoMsg.Message message = LoginMsgBuilder.buildLoginMsg(getUser(), getSession()); + log.info("发送登录消息"); + super.sendMsg(message); + + } + + + + + + + + +} diff --git a/chatServer/pom.xml b/chatServer/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9ee33423fd1d51576418d062f07bbb54927c8988 --- /dev/null +++ b/chatServer/pom.xml @@ -0,0 +1,32 @@ + + + + my_netty + com.zpf + 1.0-SNAPSHOT + + 4.0.0 + + chatServer + + + + com.zpf + chat + 1.0-SNAPSHOT + + + + + io.github.openfeign + feign-gson + 9.5.0 + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..077a9fa77568934d6d8411cbff184ef63b3be256 --- /dev/null +++ b/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + + com.zpf + my_netty + pom + 1.0-SNAPSHOT + + chat + chatClient + chatServer + + + + UTF-8 + 1.8 + + 1.4.3.RELEASE + 4.0.33.Final + 3.6.1 + 1.8 + 1.8 + 2.6.2 + + + 2.10.0 + 17.0 + 1.0 + 3.0.3 + 4.3.11.RELEASE + 1.2.29 + 4.1.0-incubating + + + + + + + + junit + junit + 4.11 + + + + io.netty + netty-all + ${netty.version} + + + + + + + + org.springframework.boot + spring-boot-starter + ${springboot} + + + + + org.springframework.boot + spring-boot-starter-test + ${springboot} + + + + + org.springframework.boot + spring-boot-devtools + ${springboot} + true + + + + + + org.apache.zookeeper + zookeeper + 3.4.8 + + + + org.apache.curator + curator-com.zpf.imClient.command.client + 4.0.0 + + + org.apache.zookeeper + zookeeper + + + + + + org.apache.curator + curator-framework + 4.0.0 + + + org.apache.zookeeper + zookeeper + + + + + org.apache.curator + curator-recipes + 4.0.0 + + + + + redis.clients + jedis + ${redis.version} + + + + org.apache.commons + commons-pool2 + 2.6.0 + + + + org.springframework.data + spring-data-redis + ${springboot} + + + + + + com.alibaba + fastjson + 1.2.62 + + + + + com.google.code.gson + gson + 2.8.5 + + + + + + \ No newline at end of file diff --git a/src/main/java/com/zpf/five/FutureDemo.java b/src/main/java/com/zpf/five/FutureDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..9b884c18c4d7e25838073c6652c9e4ffb3244a2a --- /dev/null +++ b/src/main/java/com/zpf/five/FutureDemo.java @@ -0,0 +1,117 @@ +package com.zpf.five; + +import sun.rmi.runtime.Log; +import util.Logger; + +import java.util.concurrent.Callable; +import java.util.concurrent.Future; +import java.util.concurrent.FutureTask; + +public class FutureDemo { + + public static final int SLEEP_GAP = 500; + + public static String geuCurrentThreadName() { + return Thread.currentThread().getName(); + } + + static class HotWaterThread implements Callable { + + + @Override + public Boolean call() throws Exception { + try { + Logger.info("洗好茶壶"); + Logger.info("灌上凉水"); + Logger.info("放在火上"); + + Thread.sleep(SLEEP_GAP); + Logger.info("水开了"); + } catch (Exception e) { + Logger.info("异常 中断"); + return false; + } + + Logger.info("运行结束"); + return true; + } + } + + static class WashThread implements Callable { + + + @Override + public Boolean call() throws Exception { + + try { + Logger.info("洗茶壶"); + Logger.info("洗茶叶"); + Logger.info("拿茶叶"); + + + Thread.sleep(SLEEP_GAP); + Logger.info("洗完了"); + } catch (Exception e) { + return false; + } + Logger.info("运行结束"); + + return true; + } + } + + public static void dreakTea(boolean waterOk,boolean cupOk){ + if (waterOk && cupOk){ + Logger.info("泡茶喝"); + }else if (!waterOk){ + Logger.info("烧水失败,没茶喝了"); + }else if (!cupOk){ + Logger.info("洗失败"); + } + } + + + + + + public static void main(String[] args) { + Callable hotWaterThread = new HotWaterThread(); + FutureTask hf = new FutureTask<>(hotWaterThread); + Thread ht = new Thread(hf,"烧水-thread"); + + + + Callable washThread = new WashThread(); + FutureTask wf = new FutureTask<>(washThread); + Thread wt = new Thread(wf, "清洗-thread"); + + ht.start(); + wt.start(); + + + try { + Boolean waterOk = hf.get(); + Boolean cupOk = wf.get(); + + dreakTea(waterOk,cupOk); + }catch (Exception e){ + + } + + + + + Logger.info(geuCurrentThreadName()+"运行结束"); + + + + } + + + + + + + +} + diff --git a/src/main/java/com/zpf/five/JoinDemo.java b/src/main/java/com/zpf/five/JoinDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..a0668e7f5cba952a03048a116946d6baadc80b29 --- /dev/null +++ b/src/main/java/com/zpf/five/JoinDemo.java @@ -0,0 +1,81 @@ +package com.zpf.five; + +import util.Logger; + +public class JoinDemo { + + public static final int SLEEP_GAP = 500; + + public static String geuCurrentThreadName(){ + return Thread.currentThread().getName(); + } + + static class HotWaterThread extends Thread{ + + HotWaterThread(){ + super("** 烧水-Thread"); + } + + @Override + public void run() { + try{ + Logger.info("洗好茶壶"); + Logger.info("灌上凉水"); + Logger.info("放在火上"); + + Thread.sleep(SLEEP_GAP); + Logger.info("水开了"); + }catch (Exception e){ + Logger.info("异常 中断"); + } + + Logger.info("运行结束"); + } + } + + + static class WashThread extends Thread{ + + + WashThread(){ + super("$$ 清洗-Thread"); + } + + @Override + public void run() { + try{ + Logger.info("洗茶壶"); + Logger.info("洗茶叶"); + Logger.info("拿茶叶"); + + + Thread.sleep(SLEEP_GAP); + Logger.info("洗完了"); + }catch (Exception e){ + + } + Logger.info("运行结束"); + } + } + + public static void main(String[] args) throws InterruptedException { + HotWaterThread hotWaterThread = new HotWaterThread(); + WashThread washThread = new WashThread(); + washThread.start(); + hotWaterThread.start(); + hotWaterThread.join(); + washThread.join(); + + Thread.currentThread().setName("主线程"); + Logger.info("泡茶喝"); + + Logger.info(geuCurrentThreadName()+"运行结束"); + + } + + + + + + +} diff --git a/src/main/java/com/zpf/four/reactormode/EchoClient.java b/src/main/java/com/zpf/four/reactormode/EchoClient.java new file mode 100644 index 0000000000000000000000000000000000000000..2e61e259817718db7b25a3908f4e5ca455d2fa91 --- /dev/null +++ b/src/main/java/com/zpf/four/reactormode/EchoClient.java @@ -0,0 +1,101 @@ +package com.zpf.four.reactormode; + +import config.NioDemoConfig; +import util.Dateutil; +import util.Logger; +import util.Print; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; +import java.util.Iterator; +import java.util.Scanner; +import java.util.Set; + +public class EchoClient { + + + + public void start() throws IOException { + InetSocketAddress address = new InetSocketAddress(NioDemoConfig.SOCKET_SERVER_IP,NioDemoConfig.SOCKET_SERVER_PORT); + //获取通道 + SocketChannel socketChannel = SocketChannel.open(address); + socketChannel.configureBlocking(false); + while (!socketChannel.finishConnect()){ + + } + Print.tcfo("客户端启动!!!"); + + //启动接受线程 + Processer processer = new Processer(socketChannel); + new Thread(processer).start(); + + + } + + static class Processer implements Runnable{ + final Selector selector; + final SocketChannel channel; + + Processer(SocketChannel channel) throws IOException { + //reactor初始化 + selector = Selector.open(); + this.channel = channel; + channel.register(selector, SelectionKey.OP_READ | SelectionKey.OP_WRITE); + } + + + @Override + public void run() { + try { + while (!Thread.interrupted()){ + selector.select(); + Set selected = selector.selectedKeys(); + Iterator it = selected.iterator(); + while (it.hasNext()){ + SelectionKey sk = it.next(); + //写 + if (sk.isWritable()){ + ByteBuffer buffer = ByteBuffer.allocate(NioDemoConfig.SEND_BUFFER_SIZE); + Scanner scanner = new Scanner(System.in); + Print.tcfo("请输入发送内容:"); + if (scanner.hasNext()){ + SocketChannel channel = (SocketChannel) sk.channel(); + String next = scanner.next(); + buffer.put((Dateutil.getNow()+">>"+next).getBytes()); + buffer.flip(); + //通过udp发送 + channel.write(buffer); + buffer.clear(); + } + } + //读 + if (sk.isReadable()){ + SocketChannel channel = (SocketChannel) sk.channel(); + //读数据 + ByteBuffer buffer= ByteBuffer.allocate(1024); + int length = 0; + while((length = channel.read(buffer)) > 0){ + buffer.flip(); + Logger.info("server echo:"+new String(buffer.array(),0,length)); + buffer.clear(); + } + } + } + selected.clear(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args) throws IOException { + new EchoClient().start(); + } + + +} diff --git a/src/main/java/com/zpf/four/reactormode/EchoHandler.java b/src/main/java/com/zpf/four/reactormode/EchoHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..3dce406294ed7028244e8ab2bed408c3300514bd --- /dev/null +++ b/src/main/java/com/zpf/four/reactormode/EchoHandler.java @@ -0,0 +1,61 @@ +package com.zpf.four.reactormode; + +import util.Logger; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; + +public class EchoHandler implements Runnable{ + + final SocketChannel channel; + final SelectionKey sk; + final ByteBuffer byteBuffer = ByteBuffer.allocate(1024); + static final int RECIEVING = 0,SENDING = 1; + int state = RECIEVING; + + EchoHandler(Selector selector,SocketChannel channel) throws IOException { + this.channel = channel; + channel.configureBlocking(false); + + //取选择键,设置感兴趣的IO事件 + sk = channel.register(selector, 0); + //将handler作为选择键的附件 + sk.attach(this); + + //注册read就绪事件 + sk.interestOps(SelectionKey.OP_READ); + //selector.wakeup(); + } + + @Override + public void run() { + try{ + if (state == SENDING){ + //bytebuffer 此时是read模式 + channel.write(byteBuffer); + + byteBuffer.clear(); + //bytebuffer 此时是写模式 + sk.interestOps(SelectionKey.OP_READ); + state = RECIEVING; + + }else if (state == RECIEVING){ + int length = 0; + while ((length = channel.read(byteBuffer)) > 0){ + Logger.info(new String(byteBuffer.array(),0,length)); + } + byteBuffer.flip(); + sk.interestOps(SelectionKey.OP_WRITE); + state = SENDING; + } + //这里重复使用 不关闭sekectKey +// sk.cancel(); + }catch (Exception e){ + e.printStackTrace(); + } + + } +} diff --git a/src/main/java/com/zpf/four/reactormode/EchoServerReactor.java b/src/main/java/com/zpf/four/reactormode/EchoServerReactor.java new file mode 100644 index 0000000000000000000000000000000000000000..8551976a85b4e68ce460203649e97d3b29b81ab7 --- /dev/null +++ b/src/main/java/com/zpf/four/reactormode/EchoServerReactor.java @@ -0,0 +1,97 @@ +package com.zpf.four.reactormode; + +import config.NioDemoConfig; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.util.Iterator; +import java.util.Set; + +public class EchoServerReactor implements Runnable { + Selector selector; + ServerSocketChannel serSocket; + EchoServerReactor() throws IOException { + //reactor初始化 + selector = Selector.open(); + serSocket = ServerSocketChannel.open(); + + InetSocketAddress address = new InetSocketAddress(NioDemoConfig.SOCKET_SERVER_IP,NioDemoConfig.SOCKET_SERVER_PORT); + serSocket.socket().bind(address); + //设置非阻塞 + serSocket.configureBlocking(false); + + //接收accept事件 + SelectionKey sk = serSocket.register(selector, SelectionKey.OP_ACCEPT); + + //attach callback object + sk.attach(new AcceptorHandler()); + } + + @Override + public void run() { + try{ + while (!Thread.interrupted()){ + /** + * *

This method performs a blocking selection + * * operation. It returns only after at least one channel is selected, + * * this selector's {@link #wakeup wakeup} method is invoked, or the current + * * thread is interrupted, whichever comes first.

+ */ + int select = selector.select(); + System.out.println("select=====>"+select); + Set selected = selector.selectedKeys(); + Iterator it = selected.iterator(); + while (it.hasNext()){ + //reactor负责dispatch收到的事件 + SelectionKey sk = it.next(); + dispatch(sk); + } + } + }catch (Exception e){ + + } + } + + void dispatch(SelectionKey sk){ + Runnable handler = (Runnable) sk.attachment(); + //调用之前绑定的handler处理器对象处理 + if (handler != null){ + handler.run(); + } + + + } + + + + //handler:新连接处理器 + class AcceptorHandler implements Runnable{ + + @Override + public void run() { + try { + SocketChannel channel = serSocket.accept(); + if (channel != null){ + new EchoHandler(selector,channel); + } + + + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static void main(String[] args) throws IOException { + new Thread(new EchoServerReactor()).run(); + } + + + + + +} diff --git a/src/main/java/com/zpf/four/reactormode/MultiThreadEchoHandler.java b/src/main/java/com/zpf/four/reactormode/MultiThreadEchoHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..c48034c69c692ef5f2da0386a513394d6f8ee788 --- /dev/null +++ b/src/main/java/com/zpf/four/reactormode/MultiThreadEchoHandler.java @@ -0,0 +1,88 @@ +package com.zpf.four.reactormode; + +import util.Logger; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class MultiThreadEchoHandler implements Runnable { + final SocketChannel channel; + final SelectionKey sk; + final ByteBuffer byteBuffer = ByteBuffer.allocate(1024); + static final int RECIEVING = 0,SENDING = 1; + volatile int state = RECIEVING; + //线程池 + static ExecutorService pool = Executors.newFixedThreadPool(4); + + MultiThreadEchoHandler(Selector selector, SocketChannel c) throws IOException { + channel = c; + c.configureBlocking(false); + //仅仅取得选择键,后设置感兴趣的IO事件 + sk = channel.register(selector,0); + //将本handler作为sk选择键的附件,方便事件dispatch + sk.attach(this); + //注册read事件 + sk.interestOps(SelectionKey.OP_READ); + selector.wakeup(); + } + + @Override + public void run() { + //异步任务,在独立的线程池中执行 + pool.execute(new AsyncTask()); + } + + + //异步任务,不在reactor线程中执行 + public void asyncRun(){ + try{ + if (state == SENDING){ + //写入通道 + channel.write(byteBuffer); + + byteBuffer.clear(); + + //注册read事件 + sk.interestOps(SelectionKey.OP_READ); + //写完后,进入接收状态 + state = RECIEVING; + + }else if (state == RECIEVING){ + + int length = 0; + while ((length = channel.read(byteBuffer))> 0){ + Logger.info(new String(byteBuffer.array(),0,length)); + } + //读取完毕 准备写入通道,切换成读模式 + byteBuffer.flip(); + + sk.interestOps(SelectionKey.OP_WRITE); + //进入发送状态 + state = SENDING; + } +// sk.cancel(); + + + }catch (Exception e){ + e.printStackTrace(); + } + } + + + + //异步任务的内部类 + class AsyncTask implements Runnable{ + + @Override + public void run() { + MultiThreadEchoHandler.this.asyncRun(); + } + } + + +} diff --git a/src/main/java/com/zpf/four/reactormode/MultiThreadEchoServerReactor.java b/src/main/java/com/zpf/four/reactormode/MultiThreadEchoServerReactor.java new file mode 100644 index 0000000000000000000000000000000000000000..20aaeebf027da05eb9e58ff952f53d6188a11e2c --- /dev/null +++ b/src/main/java/com/zpf/four/reactormode/MultiThreadEchoServerReactor.java @@ -0,0 +1,131 @@ +package com.zpf.four.reactormode; + +import config.NioDemoConfig; +import sun.awt.windows.ThemeReader; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +public class MultiThreadEchoServerReactor { + ServerSocketChannel serverSocket; + AtomicInteger next = new AtomicInteger(0); + //selectors集合,引入多个selector选择器 + Selector[] selectors = new Selector[2]; + //引入多个子反应器 + SubReactor[] subReactors = null; + + MultiThreadEchoServerReactor() throws IOException { + //初始化多个selector选择器 + selectors[0] = Selector.open(); + selectors[1] = Selector.open(); + + serverSocket = ServerSocketChannel.open(); + + InetSocketAddress address = new InetSocketAddress(NioDemoConfig.SOCKET_SERVER_IP,NioDemoConfig.SOCKET_SERVER_PORT); + serverSocket.socket().bind(address); + //非阻塞 + serverSocket.configureBlocking(false); + + //第一个selector负责监听新连接事件 + SelectionKey sk = serverSocket.register(selectors[0], SelectionKey.OP_ACCEPT); + //附加新连接处理handler处理器到selectionKey + sk.attach(new AcceptorHandler()); + + + + //第一个子反应器,一个子反应器负责一个选择器 + SubReactor subReactor1 = new SubReactor(selectors[0]); + //第二个子反应器,一个子反应器负责一个选择器 + SubReactor subReactor2 = new SubReactor(selectors[1]); + + subReactors = new SubReactor[]{subReactor1,subReactor2}; + + } + + private void startService(){ + new Thread(subReactors[0]).start(); + new Thread(subReactors[1]).start(); + } + + + + + + + //反应器 + class SubReactor implements Runnable{ + //每一条线程负责一个选择器的查询 + final Selector selector; + + public SubReactor(Selector selector){ + this.selector = selector; + } + + @Override + public void run() { + try{ + while (!Thread.interrupted()){ + //会阻塞 + selector.select(); + Set keySet = selector.selectedKeys(); + Iterator it = keySet.iterator(); + while (it.hasNext()){ + //Reactor负责dispatch收到的事件 + SelectionKey sk = it.next(); + dispatch(sk); + } + } + }catch (Exception e){ + + } + + } + + void dispatch(SelectionKey sk){ + Runnable handler = (Runnable) sk.attachment(); + //调用之前attach绑定到选择键上的处理器对象 + if (handler != null){ + handler.run(); + } + } + + + } + //handler:新连接处理器 + class AcceptorHandler implements Runnable{ + + @Override + public void run() { + try { + SocketChannel channel = serverSocket.accept(); + if (channel != null){ + //多线程处理器 + new MultiThreadEchoHandler(selectors[next.get()],channel); + } + + + } catch (IOException e) { + e.printStackTrace(); + } + + if (next.incrementAndGet() == selectors.length){ + next.set(0); + } + } + } + + public static void main(String[] args) throws IOException { + MultiThreadEchoServerReactor server = new MultiThreadEchoServerReactor(); + server.startService(); + } + + + +} diff --git a/src/main/java/com/zpf/six/netty/InPipeline.java b/src/main/java/com/zpf/six/netty/InPipeline.java new file mode 100644 index 0000000000000000000000000000000000000000..0d8be97102f6106a513b641b75eb8d78622512fa --- /dev/null +++ b/src/main/java/com/zpf/six/netty/InPipeline.java @@ -0,0 +1,94 @@ +package com.zpf.six.netty; + + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.embedded.EmbeddedChannel; +import org.junit.Test; +import util.Logger; + +/** + * create by 尼恩 @ 疯狂创客圈 + **/ +public class InPipeline { + static class SimpleInHandlerA extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 A: 被回调 "); + super.channelRead(ctx, msg); + } + } + static class SimpleInHandlerB extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 B: 被回调 "); + super.channelRead(ctx, msg); + } + } + static class SimpleInHandlerC extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 C: 被回调 "); + super.channelRead(ctx, msg); + } + } + + + @Test + public void testPipelineInBound() { + ChannelInitializer i = new ChannelInitializer() { + protected void initChannel(EmbeddedChannel ch) { + ch.pipeline().addLast(new SimpleInHandlerA()); + ch.pipeline().addLast(new SimpleInHandlerB()); + ch.pipeline().addLast(new SimpleInHandlerC()); + + } + }; + EmbeddedChannel channel = new EmbeddedChannel(i); + ByteBuf buf = Unpooled.buffer(); + buf.writeInt(1); + //向通道写一个入站报文 + channel.writeInbound(buf); + try { + Thread.sleep(Integer.MAX_VALUE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + + static class SimpleInHandlerB2 extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 B: 被回调 "); + //不调用基类的channelRead, 终止流水线的执行 +// super.channelRead(ctx, msg); + } + } + + //测试流水线的截断 + @Test + public void testPipelineCutting() { + ChannelInitializer i = new ChannelInitializer() { + protected void initChannel(EmbeddedChannel ch) { + ch.pipeline().addLast(new SimpleInHandlerA()); + ch.pipeline().addLast(new SimpleInHandlerB2()); + ch.pipeline().addLast(new SimpleInHandlerC()); + + } + }; + EmbeddedChannel channel = new EmbeddedChannel(i); + ByteBuf buf = Unpooled.buffer(); + buf.writeInt(1); + //向通道写一个入站报文 + channel.writeInbound(buf); + try { + Thread.sleep(Integer.MAX_VALUE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/zpf/six/netty/OutPipeline.java b/src/main/java/com/zpf/six/netty/OutPipeline.java new file mode 100644 index 0000000000000000000000000000000000000000..149c3e1da7dca8682e5694bfd6b3ea9f9ce7a02d --- /dev/null +++ b/src/main/java/com/zpf/six/netty/OutPipeline.java @@ -0,0 +1,91 @@ +package com.zpf.six.netty; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; +import org.junit.Test; +import util.Logger; + +/** + * create by 尼恩 @ 疯狂创客圈 + **/ +public class OutPipeline { + public class SimpleOutHandlerA extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + Logger.info("出站处理器 A: 被回调" ); + super.write(ctx, msg, promise); + } + } + public class SimpleOutHandlerB extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + Logger.info("出站处理器 B: 被回调" ); + super.write(ctx, msg, promise); + } + } + public class SimpleOutHandlerC extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + Logger.info("出站处理器 C: 被回调" ); + super.write(ctx, msg, promise); + } + } + @Test + public void testPipelineOutBound() { + ChannelInitializer i = new ChannelInitializer() { + protected void initChannel(EmbeddedChannel ch) { + ch.pipeline().addLast(new SimpleOutHandlerA()); + ch.pipeline().addLast(new SimpleOutHandlerB()); + ch.pipeline().addLast(new SimpleOutHandlerC()); + } + }; + EmbeddedChannel channel = new EmbeddedChannel(i); + ByteBuf buf = Unpooled.buffer(); + buf.writeInt(1); + //向通道写一个出站报文 + channel.writeOutbound(buf); + try { + Thread.sleep(Integer.MAX_VALUE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public class SimpleOutHandlerB2 extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + Logger.info("出站处理器 B: 被回调" ); + //不调用基类的channelRead, 终止流水线的执行 +// super.write(ctx, msg, promise); + } + } + + @Test + public void testPipelineOutBoundCutting() { + ChannelInitializer i = new ChannelInitializer() { + protected void initChannel(EmbeddedChannel ch) { + ch.pipeline().addLast(new SimpleOutHandlerA()); + ch.pipeline().addLast(new SimpleOutHandlerB2()); + ch.pipeline().addLast(new SimpleOutHandlerC()); + } + }; + EmbeddedChannel channel = new EmbeddedChannel(i); + ByteBuf buf = Unpooled.buffer(); + buf.writeInt(1); + //向通道写一个出站报文 + channel.writeOutbound(buf); + try { + Thread.sleep(Integer.MAX_VALUE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + + +} diff --git a/src/main/java/com/zpf/six/netty/PipelineHotOperateTester.java b/src/main/java/com/zpf/six/netty/PipelineHotOperateTester.java new file mode 100644 index 0000000000000000000000000000000000000000..d2ed8c7884046c00e5900bd99d1c5dea1e07bcc6 --- /dev/null +++ b/src/main/java/com/zpf/six/netty/PipelineHotOperateTester.java @@ -0,0 +1,73 @@ +package com.zpf.six.netty; + + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.embedded.EmbeddedChannel; +import org.junit.Test; +import util.Logger; + +/** + * create by 尼恩 @ 疯狂创客圈 + **/ +public class PipelineHotOperateTester { + + static class SimpleInHandlerA extends ChannelInboundHandlerAdapter { + + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 A: 被回调 "); + super.channelRead(ctx, msg); + //从流水线删除当前Handler + ctx.pipeline().remove(this); + } + + } + + static class SimpleInHandlerB extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 B: 被回调 "); + super.channelRead(ctx, msg); + } + } + + static class SimpleInHandlerC extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Logger.info("入站处理器 C: 被回调 "); + super.channelRead(ctx, msg); + } + } + + //测试处理器的热拔插 + @Test + public void testPipelineHotOperating() { + ChannelInitializer i = new ChannelInitializer() { + protected void initChannel(EmbeddedChannel ch) { + ch.pipeline().addLast(new SimpleInHandlerA()); + ch.pipeline().addLast(new SimpleInHandlerB()); + ch.pipeline().addLast(new SimpleInHandlerC()); + + } + }; + EmbeddedChannel channel = new EmbeddedChannel(i); + ByteBuf buf = Unpooled.buffer(); + buf.writeInt(1); + //第一次向通道写入站报文 + channel.writeInbound(buf); + + //第二次向通道写入站报文 + channel.writeInbound(buf); + //第三次向通道写入站报文 + channel.writeInbound(buf); + try { + Thread.sleep(Integer.MAX_VALUE); + } catch (InterruptedException e) { + e.printStackTrace(); + + } + } +} diff --git a/src/main/java/com/zpf/three/nio/NioReceiveServer.java b/src/main/java/com/zpf/three/nio/NioReceiveServer.java new file mode 100644 index 0000000000000000000000000000000000000000..d6bc4cf800cd3d5992eccd93cd30764348c1bcac --- /dev/null +++ b/src/main/java/com/zpf/three/nio/NioReceiveServer.java @@ -0,0 +1,152 @@ +package com.zpf.three.nio; + +import config.NioDemoConfig; +import util.IOUtil; +import util.Logger; +import util.Print; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.*; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class NioReceiveServer { + private Charset charset = Charset.forName("UTF-8"); + + /** + * 服务端保存的客户端对象,对应一个客户端文件 + */ + static class Client { + volatile String fileName; + volatile long fileLength; + volatile long startTime; + InetSocketAddress remoteAddress; + FileChannel outChannel; + } + + public static void main(String[] args) throws IOException { + NioReceiveServer nioReceiveServer = new NioReceiveServer(); + nioReceiveServer.startServer(); + } + + + private ByteBuffer buffer = ByteBuffer.allocate(NioDemoConfig.SERVER_BUFFER_SIZE); + + Map clientMap = new HashMap<>(); + + public void startServer() throws IOException { + //获取selector选择器 + Selector selector = Selector.open(); + + ServerSocketChannel serverChannel = ServerSocketChannel.open(); + serverChannel.configureBlocking(false); + + InetSocketAddress address = new InetSocketAddress(NioDemoConfig.SOCKET_SERVER_PORT); + serverChannel.bind(address); + + + //通道注册到选择器上,并注册io事件为 ‘接受新连接’ + serverChannel.register(selector, SelectionKey.OP_ACCEPT); + Print.tcfo("serverChannel is listening..."); + + //轮询感兴趣的io事件 + while (selector.select() > 0) { + //选择键集合 + Iterator it = selector.selectedKeys().iterator(); + while (it.hasNext()) { + //获取单个选择键,并处理 + SelectionKey key = it.next(); + if (key.isAcceptable()) { + //接受的事件是新连接事件,就获取客户端新连接 + ServerSocketChannel server = (ServerSocketChannel) key.channel(); + SocketChannel socketChannel = server.accept(); + if (socketChannel == null) { + continue; + } + //客户端新连接,切换为非阻塞模式 + socketChannel.configureBlocking(false); + //将客户端新连接通道注册到selector选择器上 + SelectionKey socketKey = socketChannel.register(selector, SelectionKey.OP_READ); + + //业务 + Client client = new Client(); + client.remoteAddress = (InetSocketAddress) socketChannel.getRemoteAddress(); + clientMap.put(socketChannel, client); + Logger.debug(socketChannel.getRemoteAddress() + "连接成功..."); + } else if (key.isReadable()) { + processDate(key); + } + it.remove(); + } + } + } + + /** + * 处理客户端传输过来的数据 + * + * @param key + */ + private void processDate(SelectionKey key) { + Client client = clientMap.get(key.channel()); + SocketChannel socketChannel = (SocketChannel) key.channel(); + int num = 0; + try { + buffer.clear(); + while ((num = socketChannel.read(buffer)) > 0) { + buffer.flip(); + //客户端发过来的首先是文件名 + if (null == client.fileName) { + String fileName = charset.decode(buffer).toString(); + + String destPath = IOUtil.getResourcePath(NioDemoConfig.SOCKET_RECEIVE_PATH); + File directory = new File(destPath); + if (!directory.exists()) { + directory.mkdir(); + } + + client.fileName = fileName; + String fullName = directory.getAbsolutePath() + File.separatorChar + fileName; + Logger.debug("传输目标文件" + fullName); + + File file = new File(fullName); + FileChannel fileChannel = new FileOutputStream(file).getChannel(); + client.outChannel = fileChannel; + + } else if (0 == client.fileLength) { + //其次是文件长度 + long fileLength = buffer.getLong(); + client.fileLength = fileLength; + client.startTime = System.currentTimeMillis(); + Logger.debug("开始传输"); + } else { + //写入文件 + client.outChannel.write(buffer); + } + buffer.clear(); + + } + } catch (Exception e) { + key.cancel(); + e.printStackTrace(); + return; + } + //close 为 -1 + if (num == -1) { + IOUtil.closeQuietly(client.outChannel); + System.out.println("上传完成"); + key.cancel(); + Logger.debug("文件接收成功,File Name:" + client.fileName); + Logger.debug(" Size:" + IOUtil.getFormatFileSize(client.fileLength)); + long endTime = System.currentTimeMillis(); + Logger.debug("NIO IO 传输毫秒数:" + (endTime - client.startTime)); + } + } +} + + diff --git a/src/main/java/com/zpf/three/nio/NioSendClient.java b/src/main/java/com/zpf/three/nio/NioSendClient.java new file mode 100644 index 0000000000000000000000000000000000000000..2a6c4639fb66b15263f6ab53dae430d182ebf8d4 --- /dev/null +++ b/src/main/java/com/zpf/three/nio/NioSendClient.java @@ -0,0 +1,92 @@ +package com.zpf.three.nio; + +import config.NioDemoConfig; +import util.IOUtil; +import util.Logger; + +import java.io.File; +import java.io.FileInputStream; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.channels.SocketChannel; +import java.nio.charset.Charset; + +public class NioSendClient { + private Charset charset = Charset.forName("UTF-8"); + + /** + * 发送文件 + */ + public void sendFile(){ + try{ + String sourcePath = NioDemoConfig.SOCKET_SEND_FILE; + String srcPath = IOUtil.getResourcePath(sourcePath); + Logger.debug("srcPath ="+srcPath); + + String destFile = NioDemoConfig.SOCKET_RECEIVE_FILE; + Logger.debug("destFile="+destFile); + + File file = new File(srcPath); + if (!file.exists()){ + Logger.debug("文件不存在"); + return; + } + + FileChannel fileChannel = new FileInputStream(file).getChannel(); + SocketChannel socketChannel = SocketChannel.open(); + socketChannel.socket().connect(new InetSocketAddress(NioDemoConfig.SOCKET_SERVER_IP,NioDemoConfig.SOCKET_SERVER_PORT)); + socketChannel.configureBlocking(false); + Logger.debug("com.zpf.imClient.command.client 成功连接服务器"); + + while (!socketChannel.finishConnect()){ + Logger.debug("自旋中"); + } + + + ByteBuffer fileNameByteBuffer = charset.encode(destFile); + socketChannel.write(fileNameByteBuffer); + + ByteBuffer buffer = ByteBuffer.allocate(NioDemoConfig.SEND_BUFFER_SIZE); + buffer.putLong(file.length()); + + buffer.flip(); + socketChannel.write(buffer); + buffer.clear(); + + + Logger.debug("开始传输文件"); + int length = 0; + long progerss = 0; + while ((length = fileChannel.read(buffer))>0){ + buffer.flip(); + socketChannel.write(buffer); + buffer.clear(); + progerss += length; + Logger.debug("| "+(100 * progerss / file.length())+""); + } + + if (length == -1){ + IOUtil.closeQuietly(fileChannel); + //该方法的源码 + socketChannel.shutdownOutput(); + IOUtil.closeQuietly(socketChannel); + } + Logger.debug("===============文件传输完成================="); + + }catch (Exception e){ + + } + } + + public static void main(String[] args) { + NioSendClient client = new NioSendClient(); + client.sendFile(); + } + + + + + + +} diff --git a/src/main/java/config/NioDemoConfig.java b/src/main/java/config/NioDemoConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..3383d3a5d9729393cf8ca63dd6f692f2524c9168 --- /dev/null +++ b/src/main/java/config/NioDemoConfig.java @@ -0,0 +1,56 @@ +package config; + + +import util.ConfigProperties; + +public class NioDemoConfig extends ConfigProperties +{ + + + static ConfigProperties singleton + = new NioDemoConfig("/system.properties"); + + private NioDemoConfig(String fileName) + { + super(fileName); + super.loadFromFile(); + } + + + public static final String FILE_SRC_PATH + = singleton.getValue("file.src.path"); + + public static final String FILE_DEST_PATH + = singleton.getValue("file.dest.path"); + + public static final String FILE_RESOURCE_SRC_PATH + = singleton.getValue("file.resource.src.path"); + + public static final String FILE_RESOURCE_DEST_PATH + = singleton.getValue("file.resource.dest.path"); + + + //发送文件路径 + + public static final String SOCKET_SEND_FILE + = singleton.getValue("socket.send.file"); + public static final String SOCKET_RECEIVE_FILE + = singleton.getValue("socket.receive.file"); + public static final String SOCKET_RECEIVE_PATH + = singleton.getValue("socket.receive.path"); + + + public static final int SEND_BUFFER_SIZE + = singleton.getIntValue("send.buffer.size"); + + public static final int SERVER_BUFFER_SIZE + = singleton.getIntValue("server.buffer.size"); + + public static final String SOCKET_SERVER_IP + = singleton.getValue("socket.server.ip"); + + public static final int SOCKET_SERVER_PORT + = singleton.getIntValue("socket.server.port"); + + +} diff --git a/src/main/java/config/ZConfig.java b/src/main/java/config/ZConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..c76bd6b9d9f996a461a05463bc0e6b6d9468a90a --- /dev/null +++ b/src/main/java/config/ZConfig.java @@ -0,0 +1,63 @@ +package config; + +import org.springframework.core.io.ClassPathResource; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +public class ZConfig { + private static Properties p; + + private ZConfig(){ + ClassPathResource classPathResource = new ClassPathResource("/system.properties"); + InputStream inputStream = null; + try { + inputStream = classPathResource.getInputStream(); + p = new Properties(); + p.load(inputStream); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + public static final String FILE_SRC_PATH + = p.getProperty("file.src.path"); + + public static final String FILE_DEST_PATH + = p.getProperty("file.dest.path"); + + public static final String FILE_RESOURCE_SRC_PATH + = p.getProperty("file.resource.src.path"); + + public static final String FILE_RESOURCE_DEST_PATH + = p.getProperty("file.resource.dest.path"); + + + //发送文件路径 + + public static final String SOCKET_SEND_FILE + = p.getProperty("socket.send.file"); + public static final String SOCKET_RECEIVE_FILE + = p.getProperty("socket.receive.file"); + public static final String SOCKET_RECEIVE_PATH + = p.getProperty("socket.receive.path"); + + + public static final int SEND_BUFFER_SIZE + = Integer.valueOf(p.getProperty("send.buffer.size")); + + public static final int SERVER_BUFFER_SIZE + = Integer.valueOf(p.getProperty("server.buffer.size")); + + public static final String SOCKET_SERVER_IP + = p.getProperty("socket.server.ip"); + + public static final int SOCKET_SERVER_PORT + = Integer.valueOf(p.getProperty("socket.server.port")); + + + public static void main(String[] args) { + System.out.println(SOCKET_RECEIVE_FILE); + } +} diff --git a/src/main/java/util/ClassLoaderUtil.java b/src/main/java/util/ClassLoaderUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..5e7a1e2da7afcc938bea803318a17fbb79d8731e --- /dev/null +++ b/src/main/java/util/ClassLoaderUtil.java @@ -0,0 +1,30 @@ +package util; + +public class ClassLoaderUtil +{ + + /** + * 显示classLoaderTree + *

+ * 当前加载器和所有的父 加载器 + * + * @param aClass + */ + public static void showLoader4Class(Class aClass) + { + ClassLoader loader = aClass.getClassLoader(); + showLoaderTree(loader); + } + + /** + * 迭代,显示class loader 和 父加载器 + */ + public static void showLoaderTree(ClassLoader loader) + { + while (loader != null) + { + Logger.debug(loader.toString()); + loader = loader.getParent(); + } + } +} diff --git a/src/main/java/util/ConfigProperties.java b/src/main/java/util/ConfigProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..03a8a01dc994bc04e6048e1c88ba1392d6c57042 --- /dev/null +++ b/src/main/java/util/ConfigProperties.java @@ -0,0 +1,114 @@ +package util; + + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.util.Properties; + + +/** + * @author + */ +public class ConfigProperties +{ + + private String properiesName = ""; + private Properties properties = new Properties(); + + + public ConfigProperties() + { + + } + + public ConfigProperties(String fileName) + { + this.properiesName = fileName; + } + + + protected void loadFromFile() + { + InputStream in = null; + InputStreamReader ireader = null; + try + { + String filePath = IOUtil.getResourcePath(properiesName); + in = new FileInputStream(filePath); + //解决读非UTF-8编码的配置文件时,出现的中文乱码问题 + ireader = new InputStreamReader(in, "utf-8"); + properties.load(ireader); + } catch (IOException e) + { + e.printStackTrace(); + } finally + { + IOUtil.closeQuietly(ireader); + } + } + + + /** + * 按key获取值 + * + * @param key + * @return + */ + public String readProperty(String key) + { + String value = ""; + + value = properties.getProperty(key); + + return value; + } + + + public String getValue(String key) + { + + return readProperty(key); + + } + + public int getIntValue(String key) + { + + return Integer.parseInt((readProperty(key))); + + } + + public static ConfigProperties loadFromFile(Class aClass) + throws IllegalAccessException + { + + ConfigProperties propertiesUtil = null; + + + return propertiesUtil; + } + + public static void loadAnnotations(Class aClass) + { + + ConfigProperties configProperties = null; + try + { + configProperties = loadFromFile(aClass); + + + if (null == configProperties) return; + + Field[] fields = aClass.getDeclaredFields(); + + } catch (IllegalAccessException e) + { + e.printStackTrace(); + } + } + + +} \ No newline at end of file diff --git a/src/main/java/util/Dateutil.java b/src/main/java/util/Dateutil.java new file mode 100644 index 0000000000000000000000000000000000000000..d66d9d28daa56ffa047f323edeaf024f8c2cd80a --- /dev/null +++ b/src/main/java/util/Dateutil.java @@ -0,0 +1,45 @@ +package util; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class Dateutil +{ + + /** + * 取得今天的日期 + * + * @return + */ + public static String getToday() + { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + return sdf.format(new Date().getTime()); + } + + /** + * 取得昨天的日期 + * + * @return + */ + public static String getYestoday() + { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, 1); + Date date = calendar.getTime(); + return sdf.format(date.getTime()); + } + + public static String getNow() + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + + return sdf.format(new Date().getTime()); + + } +} diff --git a/src/main/java/util/DeEnCode.java b/src/main/java/util/DeEnCode.java new file mode 100644 index 0000000000000000000000000000000000000000..f918d60d90c92a7b2a6dd41c295a3ee54ded551b --- /dev/null +++ b/src/main/java/util/DeEnCode.java @@ -0,0 +1,48 @@ +package util; + +import java.nio.charset.Charset; + +public class DeEnCode +{ + + private static final String key0 = "FECOI()*&= 1) + { + return fileSizeFormater.format(size) + "GB"; + } + size = ((double) length) / (1 << 20); + if (size >= 1) + { + return fileSizeFormater.format(size) + "MB"; + } + size = ((double) length) / (1 << 10); + if (size >= 1) + { + return fileSizeFormater.format(size) + "KB"; + } + return length + "B"; + } + + private static DecimalFormat fileSizeFormater = FormatUtil.decimalFormat(1); + + + /** + * ByteBuffer中字符串是以ascii中0(null)字符结束 + * 如果是以别的字符结束,则修改if(btemp[i]==0){ + * break; + * }即可 + * + * @param buf + * @param MaxLen + * @return + */ + public static String getVarStrFromBuf(ByteBuffer buf, int MaxLen) + { + byte[] btemp = new byte[MaxLen]; + byte j = -1; + int avaibleBytes = buf.array().length - buf.position(); + if (!(avaibleBytes > 0)) + { + return ""; + } + int len = 0; + for (int i = 0; i < MaxLen; i++) + { + btemp[i] = buf.get(); + len = i; + if (btemp[i] == 0) + { + break; + } + } + try + { + return new String(btemp, 0, len, "UTF-8"); + } catch (UnsupportedEncodingException e) + { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/util/JsonUtil.java b/src/main/java/util/JsonUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..e7aa08896162c617177ba27c9843f08362337820 --- /dev/null +++ b/src/main/java/util/JsonUtil.java @@ -0,0 +1,65 @@ +package util; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.io.UnsupportedEncodingException; + +public class JsonUtil { + + //谷歌 Gson + static Gson gson = null; + + static { + //不需要html escape + gson=new GsonBuilder() + .disableHtmlEscaping() +// .excludeFieldsWithoutExposeAnnotation() + .create(); + + } + + //Object对象转成JSON字符串后,进一步转成字节数组 + public static byte[] Object2JsonBytes(Object obj) { + + //把对象转换成JSON + + String json = pojoToJson(obj); + try { + return json.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return null; + } + + //反向:字节数组,转成JSON字符串,转成Object对象 + public static T JsonBytes2Object(byte[] bytes, Class tClass) { + //字节数组,转成JSON字符串 + try { + String json = new String(bytes, "UTF-8"); + T t = jsonToPojo(json, tClass); + return t; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + //使用谷歌 Gson 将 POJO 转成字符串 + public static String pojoToJson(Object obj) { + //String json = new Gson().toJson(obj); + String json = gson.toJson(obj); + + return json; + } + + //使用阿里 Fastjson 将字符串转成 POJO对象 + public static T jsonToPojo(String json, Class tClass) { + T t = JSONObject.parseObject(json, tClass); + return t; + } + + +} diff --git a/src/main/java/util/JvmUtil.java b/src/main/java/util/JvmUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..1afd731832eca4fb418f8fdfd899db2c8ac23b28 --- /dev/null +++ b/src/main/java/util/JvmUtil.java @@ -0,0 +1,21 @@ +package util; + +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; + + +public class JvmUtil +{ + + public static final int getProcessID() + { + // ManagementFactory是一个在运行时管理和监控Java VM的工厂类 + // 它能提供很多管理VM的静态接口的运行时实例,比如RuntimeMXBean + // RuntimeMXBean是Java虚拟机的运行时管理接口. + // 取得VM运行管理实例,到管理接口句柄 + RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); + // 取得VM运行管理实例的名称,也是JVM运行实例的名称 + String jvmInstanceName = runtimeMXBean.getName(); + return Integer.valueOf(jvmInstanceName.split("@")[0]).intValue(); + } +} diff --git a/src/main/java/util/Logger.java b/src/main/java/util/Logger.java new file mode 100644 index 0000000000000000000000000000000000000000..4f45a9a8e8c582feda5b003a4e5f253cb8118e63 --- /dev/null +++ b/src/main/java/util/Logger.java @@ -0,0 +1,108 @@ +/** + * Created by nien woo + * Date: 17-12-30 + * Time: 下午4:50 + */ +package util; + + +public class Logger +{ + + /** + * 带着方法名输出,方法名称放在前面 + * + * @param s 待输出的字符串形参 + */ + public static void debug(Object s) + { + String content = null; + if (null != s) + { + content = s.toString().trim(); + } + else + { + content = ""; + } + + String out = String.format("%20s |> %s ", ReflectionUtil.getCallMethod(), content); + System.out.println(out); + } + + + /** + * 带着线程名+类名+方法名称输出 + * + * @param s 待输出的字符串形参 + */ + synchronized public static void info(Object s) + { + String content = null; + if (null != s) + { + content = s.toString().trim(); + } + else + { + content = ""; + } + String cft = "[" + Thread.currentThread().getName() + "|" + ReflectionUtil.getNakeCallClassMethod() + "]"; + + String out = String.format("%20s |> %s ", cft, content); + System.out.println(out); + + } + + /** + * 带着线程名+类名+方法名称输出 + * + * @param args 待输出的字符串形参 + */ + synchronized public static void info(Object... args) + { + StringBuilder content = new StringBuilder(); + ; + for (int i = 0; i < args.length; i++) { + content.append(args[i]!=null?args[i].toString():"null"); + content.append(" "); + } + + String cft = "[" + Thread.currentThread().getName() + "|" + ReflectionUtil.getNakeCallClassMethod() + "]"; + + String out = String.format("%20s |> %s ", cft, content.toString()); + System.out.println(out); + + } + + /** + * 带着线程名+类名+方法名称输出 + * + * @param args 待输出的字符串形参 + */ + synchronized public static void error(Object... args) + { + StringBuilder content = new StringBuilder(); + ; + for (int i = 0; i < args.length; i++) { + content.append(args[i]!=null?args[i].toString():"null"); + content.append(" "); + } + + String cft = "[" + Thread.currentThread().getName() + "|" + ReflectionUtil.getNakeCallClassMethod() + "]"; + + String out = String.format("%20s |> %s ", cft, content.toString()); + System.err.println(out); + + } + + /** + * 编程过程中的提示说明 + * + * @param s 提示的字符串形参 + */ + public static void hint(Object s) + { + System.out.println("/--" + s + "--/"); + } +} diff --git a/src/main/java/util/Print.java b/src/main/java/util/Print.java new file mode 100644 index 0000000000000000000000000000000000000000..3770e0e8a1ab57158a8ad6f7adeda51ccecfad99 --- /dev/null +++ b/src/main/java/util/Print.java @@ -0,0 +1,55 @@ +/** + * Created by 尼恩 at 疯狂创客圈 + */ + +package util; + + +public class Print { + + /** + * 信息输出 + * + * @param s 输出的字符串形参 + */ + public static void o(Object s) { + System.out.println(s); + } + + /** + * 带着方法名输出,方法名称放在前面 + * + * @param s 待输出的字符串形参 + */ + public static void fo(Object s) { + System.out.println(ReflectionUtil.getCallMethod() + ":" + s); + } + + /** + * 带着类名+方法名输出 + * + * @param s 待输出的字符串形参 + */ + synchronized public static void cfo(Object s) { + System.out.println(ReflectionUtil.getCallClassMethod() + ":" + s); + } + + /** + * 带着线程名+类名+方法名称输出 + * + * @param s 待输出的字符串形参 + */ + synchronized public static void tcfo(Object s) { + String cft= "["+Thread.currentThread().getName()+"|"+ReflectionUtil.getNakeCallClassMethod()+"]"; + System.out.println(cft + ":"+ s); + } + + /** + * 编程过程中的提示说明 + * + * @param s 提示的字符串形参 + */ + public static void hint(Object s) { + System.out.println("/--" + s + "--/"); + } +} diff --git a/src/main/java/util/RandomUtil.java b/src/main/java/util/RandomUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..8e227a157a1ba48c77465a0373f774f1c2126a4c --- /dev/null +++ b/src/main/java/util/RandomUtil.java @@ -0,0 +1,35 @@ +package util; + +import java.util.Random; + +public class RandomUtil +{ + private static Random random = new Random(); + + /** + * 按照范围,生成随机的整数 + * + * @param mod + * @return [1, mod]之间的整数 + */ + public static int randInMod(int mod) + { + return Math.abs(random.nextInt(mod)) + 1; + } + + /** + * 按照上下限范围,生成随机的整数 + * + * @param low 下限 + * @param high 上限 + * @return + */ + public static int randInRange(int low, int high) + { + + return randInMod(high - low) + low; + + } + + +} diff --git a/src/main/java/util/ReflectionUtil.java b/src/main/java/util/ReflectionUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..48adbb02dfe36aa9c1daf1a6aa552d60ee464aaf --- /dev/null +++ b/src/main/java/util/ReflectionUtil.java @@ -0,0 +1,104 @@ +package util; + + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Created by nien woo + * Date: 18-1-11 + * Time: 下午12:40 + */ +public class ReflectionUtil +{ + /** + * 获得调用方法的名称 + * + * @return 方法名称 + */ + public static String getCallMethod() + { + StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + // 获得调用方法名 + String method = stack[3].getMethodName(); + return method; + } + + /** + * 获得调用方法的类名+方法名,带上中括号 + * + * @return 方法名称 + */ + public static String getCallClassMethod() + { + StackTraceElement stack[] = Thread.currentThread().getStackTrace(); + // 获得调用方法名 + String[] className = stack[3].getClassName().split("\\."); + String fullName = className[className.length - 1] + ":" + stack[3].getMethodName(); + return fullName; + } + + /** + * 获得调用方法的类名+方法名 + * + * @return 方法名称 + */ + public static String getNakeCallClassMethod() + { + StackTraceElement stack[] = Thread.currentThread().getStackTrace(); + // 获得调用方法名 + String[] className = stack[3].getClassName().split("\\."); + String fullName = className[className.length - 1] + "." + stack[3].getMethodName(); + return fullName; + } + + /** + * 取得父类所有的接口 + * + * @param targetClass + * @return + */ + public static Class[] getInterfaces(Class targetClass) + { + Set> interfaceSet = new HashSet<>(); + //数组转成list + List> subList = Arrays.asList(targetClass.getInterfaces()); + if (subList.size() > 0) + interfaceSet.addAll(subList); + Class superClass = targetClass.getSuperclass(); + while (null != superClass) + { + subList = Arrays.asList(superClass.getInterfaces()); + + if (subList.size() > 0) + interfaceSet.addAll(subList); + + superClass = superClass.getSuperclass(); + } + //set 转成 数组 + return interfaceSet.toArray(new Class[0]); + + } + + public static Object newProxyInstance(Object targetObject, InvocationHandler handler) + { + + + Class targetClass = targetObject.getClass(); + + ClassLoader loader = targetClass.getClassLoader(); + + //被代理类实现的接口 + Class[] targetInterfaces = ReflectionUtil.getInterfaces(targetClass); + + Object proxy = Proxy.newProxyInstance(loader, targetInterfaces, handler); + return proxy; + } + +} + + diff --git a/src/main/resources/system.properties b/src/main/resources/system.properties new file mode 100644 index 0000000000000000000000000000000000000000..9c05716d23bb361da59c7ba5f6be26c2d8c3f835 --- /dev/null +++ b/src/main/resources/system.properties @@ -0,0 +1,7 @@ +socket.server.ip=127.0.0.1 +socket.server.port=12345 +socket.send.file=/system.properties +socket.receive.file=system.dest.properties +socket.receive.path=/ +send.buffer.size=1024 +server.buffer.size=10240 \ No newline at end of file diff --git a/src/test/java/Test.java b/src/test/java/Test.java new file mode 100644 index 0000000000000000000000000000000000000000..67bbf93b1c62592f0404629f4182aa393059c5c8 --- /dev/null +++ b/src/test/java/Test.java @@ -0,0 +1,7 @@ +import config.ZConfig; + +public class Test { + public static void main(String[] args) { + System.out.println(ZConfig.FILE_DEST_PATH); + } +}