/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ (function(global, factory) { /* global define, require, module */ /* AMD */ if (typeof define === 'function' && define.amd) define(["protobufjs/minimal"], factory); /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) module.exports = factory(require("protobufjs/minimal")); })(this, function($protobuf) { "use strict"; // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); $root.tutorial = (function() { /** * Namespace tutorial. * @exports tutorial * @namespace */ var tutorial = {}; tutorial.Message = (function() { /** * Properties of a Message. * @memberof tutorial * @interface IMessage * @property {tutorial.Message.Type|null} [type] Message type * @property {tutorial.Message.IChatMessage|null} [chatMessage] Message chatMessage * @property {tutorial.Message.ICommonMessage|null} [commonMessage] Message commonMessage * @property {tutorial.Message.IDataMessage|null} [dataMessage] Message dataMessage */ /** * Constructs a new Message. * @memberof tutorial * @classdesc Represents a Message. * @implements IMessage * @constructor * @param {tutorial.IMessage=} [properties] Properties to set */ function Message(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * Message type. * @member {tutorial.Message.Type} type * @memberof tutorial.Message * @instance */ Message.prototype.type = 0; /** * Message chatMessage. * @member {tutorial.Message.IChatMessage|null|undefined} chatMessage * @memberof tutorial.Message * @instance */ Message.prototype.chatMessage = null; /** * Message commonMessage. * @member {tutorial.Message.ICommonMessage|null|undefined} commonMessage * @memberof tutorial.Message * @instance */ Message.prototype.commonMessage = null; /** * Message dataMessage. * @member {tutorial.Message.IDataMessage|null|undefined} dataMessage * @memberof tutorial.Message * @instance */ Message.prototype.dataMessage = null; /** * Creates a new Message instance using the specified properties. * @function create * @memberof tutorial.Message * @static * @param {tutorial.IMessage=} [properties] Properties to set * @returns {tutorial.Message} Message instance */ Message.create = function create(properties) { return new Message(properties); }; /** * Encodes the specified Message message. Does not implicitly {@link tutorial.Message.verify|verify} messages. * @function encode * @memberof tutorial.Message * @static * @param {tutorial.IMessage} message Message message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Message.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.type != null && message.hasOwnProperty("type")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); if (message.chatMessage != null && message.hasOwnProperty("chatMessage")) $root.tutorial.Message.ChatMessage.encode(message.chatMessage, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.commonMessage != null && message.hasOwnProperty("commonMessage")) $root.tutorial.Message.CommonMessage.encode(message.commonMessage, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.dataMessage != null && message.hasOwnProperty("dataMessage")) $root.tutorial.Message.DataMessage.encode(message.dataMessage, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** * Encodes the specified Message message, length delimited. Does not implicitly {@link tutorial.Message.verify|verify} messages. * @function encodeDelimited * @memberof tutorial.Message * @static * @param {tutorial.IMessage} message Message message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Message.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Message message from the specified reader or buffer. * @function decode * @memberof tutorial.Message * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {tutorial.Message} Message * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Message.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.type = reader.int32(); break; case 2: message.chatMessage = $root.tutorial.Message.ChatMessage.decode(reader, reader.uint32()); break; case 3: message.commonMessage = $root.tutorial.Message.CommonMessage.decode(reader, reader.uint32()); break; case 4: message.dataMessage = $root.tutorial.Message.DataMessage.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Message message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof tutorial.Message * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {tutorial.Message} Message * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Message.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Message message. * @function verify * @memberof tutorial.Message * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Message.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.type != null && message.hasOwnProperty("type")) switch (message.type) { default: return "type: enum value expected"; case 0: case 1: case 2: break; } if (message.chatMessage != null && message.hasOwnProperty("chatMessage")) { var error = $root.tutorial.Message.ChatMessage.verify(message.chatMessage); if (error) return "chatMessage." + error; } if (message.commonMessage != null && message.hasOwnProperty("commonMessage")) { var error = $root.tutorial.Message.CommonMessage.verify(message.commonMessage); if (error) return "commonMessage." + error; } if (message.dataMessage != null && message.hasOwnProperty("dataMessage")) { var error = $root.tutorial.Message.DataMessage.verify(message.dataMessage); if (error) return "dataMessage." + error; } return null; }; /** * Creates a Message message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof tutorial.Message * @static * @param {Object.} object Plain object * @returns {tutorial.Message} Message */ Message.fromObject = function fromObject(object) { if (object instanceof $root.tutorial.Message) return object; var message = new $root.tutorial.Message(); switch (object.type) { case "COMMON": case 0: message.type = 0; break; case "CHAT": case 1: message.type = 1; break; case "DATA": case 2: message.type = 2; break; } if (object.chatMessage != null) { if (typeof object.chatMessage !== "object") throw TypeError(".tutorial.Message.chatMessage: object expected"); message.chatMessage = $root.tutorial.Message.ChatMessage.fromObject(object.chatMessage); } if (object.commonMessage != null) { if (typeof object.commonMessage !== "object") throw TypeError(".tutorial.Message.commonMessage: object expected"); message.commonMessage = $root.tutorial.Message.CommonMessage.fromObject(object.commonMessage); } if (object.dataMessage != null) { if (typeof object.dataMessage !== "object") throw TypeError(".tutorial.Message.dataMessage: object expected"); message.dataMessage = $root.tutorial.Message.DataMessage.fromObject(object.dataMessage); } return message; }; /** * Creates a plain object from a Message message. Also converts values to other types if specified. * @function toObject * @memberof tutorial.Message * @static * @param {tutorial.Message} message Message * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ Message.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.type = options.enums === String ? "COMMON" : 0; object.chatMessage = null; object.commonMessage = null; object.dataMessage = null; } if (message.type != null && message.hasOwnProperty("type")) object.type = options.enums === String ? $root.tutorial.Message.Type[message.type] : message.type; if (message.chatMessage != null && message.hasOwnProperty("chatMessage")) object.chatMessage = $root.tutorial.Message.ChatMessage.toObject(message.chatMessage, options); if (message.commonMessage != null && message.hasOwnProperty("commonMessage")) object.commonMessage = $root.tutorial.Message.CommonMessage.toObject(message.commonMessage, options); if (message.dataMessage != null && message.hasOwnProperty("dataMessage")) object.dataMessage = $root.tutorial.Message.DataMessage.toObject(message.dataMessage, options); return object; }; /** * Converts this Message to JSON. * @function toJSON * @memberof tutorial.Message * @instance * @returns {Object.} JSON object */ Message.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Type enum. * @name tutorial.Message.Type * @enum {string} * @property {number} COMMON=0 COMMON value * @property {number} CHAT=1 CHAT value * @property {number} DATA=2 DATA value */ Message.Type = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "COMMON"] = 0; values[valuesById[1] = "CHAT"] = 1; values[valuesById[2] = "DATA"] = 2; return values; })(); Message.ChatMessage = (function() { /** * Properties of a ChatMessage. * @memberof tutorial.Message * @interface IChatMessage * @property {number|Long|null} [id] ChatMessage id * @property {number|Long|null} [uid] ChatMessage uid * @property {number|Long|null} [receiveUid] ChatMessage receiveUid * @property {number|null} [bType] ChatMessage bType * @property {number|null} [contentType] ChatMessage contentType * @property {string|null} [msg] ChatMessage msg * @property {number|null} [contentLen] ChatMessage contentLen * @property {number|null} [hasAuth] ChatMessage hasAuth * @property {number|Long|null} [sendTime] ChatMessage sendTime * @property {number|null} [isRead] ChatMessage isRead * @property {tutorial.Message.IUserInfo|null} [sender] ChatMessage sender */ /** * Constructs a new ChatMessage. * @memberof tutorial.Message * @classdesc Represents a ChatMessage. * @implements IChatMessage * @constructor * @param {tutorial.Message.IChatMessage=} [properties] Properties to set */ function ChatMessage(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * ChatMessage id. * @member {number|Long} id * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.id = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * ChatMessage uid. * @member {number|Long} uid * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.uid = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * ChatMessage receiveUid. * @member {number|Long} receiveUid * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.receiveUid = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * ChatMessage bType. * @member {number} bType * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.bType = 0; /** * ChatMessage contentType. * @member {number} contentType * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.contentType = 0; /** * ChatMessage msg. * @member {string} msg * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.msg = ""; /** * ChatMessage contentLen. * @member {number} contentLen * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.contentLen = 0; /** * ChatMessage hasAuth. * @member {number} hasAuth * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.hasAuth = 0; /** * ChatMessage sendTime. * @member {number|Long} sendTime * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.sendTime = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * ChatMessage isRead. * @member {number} isRead * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.isRead = 0; /** * ChatMessage sender. * @member {tutorial.Message.IUserInfo|null|undefined} sender * @memberof tutorial.Message.ChatMessage * @instance */ ChatMessage.prototype.sender = null; /** * Creates a new ChatMessage instance using the specified properties. * @function create * @memberof tutorial.Message.ChatMessage * @static * @param {tutorial.Message.IChatMessage=} [properties] Properties to set * @returns {tutorial.Message.ChatMessage} ChatMessage instance */ ChatMessage.create = function create(properties) { return new ChatMessage(properties); }; /** * Encodes the specified ChatMessage message. Does not implicitly {@link tutorial.Message.ChatMessage.verify|verify} messages. * @function encode * @memberof tutorial.Message.ChatMessage * @static * @param {tutorial.Message.IChatMessage} message ChatMessage message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ ChatMessage.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.id != null && message.hasOwnProperty("id")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.id); if (message.uid != null && message.hasOwnProperty("uid")) writer.uint32(/* id 2, wireType 0 =*/16).int64(message.uid); if (message.receiveUid != null && message.hasOwnProperty("receiveUid")) writer.uint32(/* id 3, wireType 0 =*/24).int64(message.receiveUid); if (message.bType != null && message.hasOwnProperty("bType")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.bType); if (message.contentType != null && message.hasOwnProperty("contentType")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.contentType); if (message.msg != null && message.hasOwnProperty("msg")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.msg); if (message.contentLen != null && message.hasOwnProperty("contentLen")) writer.uint32(/* id 7, wireType 0 =*/56).int32(message.contentLen); if (message.hasAuth != null && message.hasOwnProperty("hasAuth")) writer.uint32(/* id 8, wireType 0 =*/64).int32(message.hasAuth); if (message.sendTime != null && message.hasOwnProperty("sendTime")) writer.uint32(/* id 9, wireType 0 =*/72).int64(message.sendTime); if (message.isRead != null && message.hasOwnProperty("isRead")) writer.uint32(/* id 10, wireType 0 =*/80).int32(message.isRead); if (message.sender != null && message.hasOwnProperty("sender")) $root.tutorial.Message.UserInfo.encode(message.sender, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); return writer; }; /** * Encodes the specified ChatMessage message, length delimited. Does not implicitly {@link tutorial.Message.ChatMessage.verify|verify} messages. * @function encodeDelimited * @memberof tutorial.Message.ChatMessage * @static * @param {tutorial.Message.IChatMessage} message ChatMessage message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ ChatMessage.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a ChatMessage message from the specified reader or buffer. * @function decode * @memberof tutorial.Message.ChatMessage * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {tutorial.Message.ChatMessage} ChatMessage * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ ChatMessage.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.ChatMessage(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.id = reader.int64(); break; case 2: message.uid = reader.int64(); break; case 3: message.receiveUid = reader.int64(); break; case 4: message.bType = reader.int32(); break; case 5: message.contentType = reader.int32(); break; case 6: message.msg = reader.string(); break; case 7: message.contentLen = reader.int32(); break; case 8: message.hasAuth = reader.int32(); break; case 9: message.sendTime = reader.int64(); break; case 10: message.isRead = reader.int32(); break; case 11: message.sender = $root.tutorial.Message.UserInfo.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a ChatMessage message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof tutorial.Message.ChatMessage * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {tutorial.Message.ChatMessage} ChatMessage * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ ChatMessage.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a ChatMessage message. * @function verify * @memberof tutorial.Message.ChatMessage * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ ChatMessage.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.id != null && message.hasOwnProperty("id")) if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high))) return "id: integer|Long expected"; if (message.uid != null && message.hasOwnProperty("uid")) if (!$util.isInteger(message.uid) && !(message.uid && $util.isInteger(message.uid.low) && $util.isInteger(message.uid.high))) return "uid: integer|Long expected"; if (message.receiveUid != null && message.hasOwnProperty("receiveUid")) if (!$util.isInteger(message.receiveUid) && !(message.receiveUid && $util.isInteger(message.receiveUid.low) && $util.isInteger(message.receiveUid.high))) return "receiveUid: integer|Long expected"; if (message.bType != null && message.hasOwnProperty("bType")) if (!$util.isInteger(message.bType)) return "bType: integer expected"; if (message.contentType != null && message.hasOwnProperty("contentType")) if (!$util.isInteger(message.contentType)) return "contentType: integer expected"; if (message.msg != null && message.hasOwnProperty("msg")) if (!$util.isString(message.msg)) return "msg: string expected"; if (message.contentLen != null && message.hasOwnProperty("contentLen")) if (!$util.isInteger(message.contentLen)) return "contentLen: integer expected"; if (message.hasAuth != null && message.hasOwnProperty("hasAuth")) if (!$util.isInteger(message.hasAuth)) return "hasAuth: integer expected"; if (message.sendTime != null && message.hasOwnProperty("sendTime")) if (!$util.isInteger(message.sendTime) && !(message.sendTime && $util.isInteger(message.sendTime.low) && $util.isInteger(message.sendTime.high))) return "sendTime: integer|Long expected"; if (message.isRead != null && message.hasOwnProperty("isRead")) if (!$util.isInteger(message.isRead)) return "isRead: integer expected"; if (message.sender != null && message.hasOwnProperty("sender")) { var error = $root.tutorial.Message.UserInfo.verify(message.sender); if (error) return "sender." + error; } return null; }; /** * Creates a ChatMessage message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof tutorial.Message.ChatMessage * @static * @param {Object.} object Plain object * @returns {tutorial.Message.ChatMessage} ChatMessage */ ChatMessage.fromObject = function fromObject(object) { if (object instanceof $root.tutorial.Message.ChatMessage) return object; var message = new $root.tutorial.Message.ChatMessage(); if (object.id != null) if ($util.Long) (message.id = $util.Long.fromValue(object.id)).unsigned = false; else if (typeof object.id === "string") message.id = parseInt(object.id, 10); else if (typeof object.id === "number") message.id = object.id; else if (typeof object.id === "object") message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(); if (object.uid != null) if ($util.Long) (message.uid = $util.Long.fromValue(object.uid)).unsigned = false; else if (typeof object.uid === "string") message.uid = parseInt(object.uid, 10); else if (typeof object.uid === "number") message.uid = object.uid; else if (typeof object.uid === "object") message.uid = new $util.LongBits(object.uid.low >>> 0, object.uid.high >>> 0).toNumber(); if (object.receiveUid != null) if ($util.Long) (message.receiveUid = $util.Long.fromValue(object.receiveUid)).unsigned = false; else if (typeof object.receiveUid === "string") message.receiveUid = parseInt(object.receiveUid, 10); else if (typeof object.receiveUid === "number") message.receiveUid = object.receiveUid; else if (typeof object.receiveUid === "object") message.receiveUid = new $util.LongBits(object.receiveUid.low >>> 0, object.receiveUid.high >>> 0).toNumber(); if (object.bType != null) message.bType = object.bType | 0; if (object.contentType != null) message.contentType = object.contentType | 0; if (object.msg != null) message.msg = String(object.msg); if (object.contentLen != null) message.contentLen = object.contentLen | 0; if (object.hasAuth != null) message.hasAuth = object.hasAuth | 0; if (object.sendTime != null) if ($util.Long) (message.sendTime = $util.Long.fromValue(object.sendTime)).unsigned = false; else if (typeof object.sendTime === "string") message.sendTime = parseInt(object.sendTime, 10); else if (typeof object.sendTime === "number") message.sendTime = object.sendTime; else if (typeof object.sendTime === "object") message.sendTime = new $util.LongBits(object.sendTime.low >>> 0, object.sendTime.high >>> 0).toNumber(); if (object.isRead != null) message.isRead = object.isRead | 0; if (object.sender != null) { if (typeof object.sender !== "object") throw TypeError(".tutorial.Message.ChatMessage.sender: object expected"); message.sender = $root.tutorial.Message.UserInfo.fromObject(object.sender); } return message; }; /** * Creates a plain object from a ChatMessage message. Also converts values to other types if specified. * @function toObject * @memberof tutorial.Message.ChatMessage * @static * @param {tutorial.Message.ChatMessage} message ChatMessage * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ ChatMessage.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { if ($util.Long) { var long = new $util.Long(0, 0, false); object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.id = options.longs === String ? "0" : 0; if ($util.Long) { var long = new $util.Long(0, 0, false); object.uid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.uid = options.longs === String ? "0" : 0; if ($util.Long) { var long = new $util.Long(0, 0, false); object.receiveUid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.receiveUid = options.longs === String ? "0" : 0; object.bType = 0; object.contentType = 0; object.msg = ""; object.contentLen = 0; object.hasAuth = 0; if ($util.Long) { var long = new $util.Long(0, 0, false); object.sendTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.sendTime = options.longs === String ? "0" : 0; object.isRead = 0; object.sender = null; } if (message.id != null && message.hasOwnProperty("id")) if (typeof message.id === "number") object.id = options.longs === String ? String(message.id) : message.id; else object.id = options.longs === String ? $util.Long.prototype.toString.call(message.id) : options.longs === Number ? new $util.LongBits(message.id.low >>> 0, message.id.high >>> 0).toNumber() : message.id; if (message.uid != null && message.hasOwnProperty("uid")) if (typeof message.uid === "number") object.uid = options.longs === String ? String(message.uid) : message.uid; else object.uid = options.longs === String ? $util.Long.prototype.toString.call(message.uid) : options.longs === Number ? new $util.LongBits(message.uid.low >>> 0, message.uid.high >>> 0).toNumber() : message.uid; if (message.receiveUid != null && message.hasOwnProperty("receiveUid")) if (typeof message.receiveUid === "number") object.receiveUid = options.longs === String ? String(message.receiveUid) : message.receiveUid; else object.receiveUid = options.longs === String ? $util.Long.prototype.toString.call(message.receiveUid) : options.longs === Number ? new $util.LongBits(message.receiveUid.low >>> 0, message.receiveUid.high >>> 0).toNumber() : message.receiveUid; if (message.bType != null && message.hasOwnProperty("bType")) object.bType = message.bType; if (message.contentType != null && message.hasOwnProperty("contentType")) object.contentType = message.contentType; if (message.msg != null && message.hasOwnProperty("msg")) object.msg = message.msg; if (message.contentLen != null && message.hasOwnProperty("contentLen")) object.contentLen = message.contentLen; if (message.hasAuth != null && message.hasOwnProperty("hasAuth")) object.hasAuth = message.hasAuth; if (message.sendTime != null && message.hasOwnProperty("sendTime")) if (typeof message.sendTime === "number") object.sendTime = options.longs === String ? String(message.sendTime) : message.sendTime; else object.sendTime = options.longs === String ? $util.Long.prototype.toString.call(message.sendTime) : options.longs === Number ? new $util.LongBits(message.sendTime.low >>> 0, message.sendTime.high >>> 0).toNumber() : message.sendTime; if (message.isRead != null && message.hasOwnProperty("isRead")) object.isRead = message.isRead; if (message.sender != null && message.hasOwnProperty("sender")) object.sender = $root.tutorial.Message.UserInfo.toObject(message.sender, options); return object; }; /** * Converts this ChatMessage to JSON. * @function toJSON * @memberof tutorial.Message.ChatMessage * @instance * @returns {Object.} JSON object */ ChatMessage.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return ChatMessage; })(); Message.CommonMessage = (function() { /** * Properties of a CommonMessage. * @memberof tutorial.Message * @interface ICommonMessage * @property {string|null} [msg] CommonMessage msg */ /** * Constructs a new CommonMessage. * @memberof tutorial.Message * @classdesc Represents a CommonMessage. * @implements ICommonMessage * @constructor * @param {tutorial.Message.ICommonMessage=} [properties] Properties to set */ function CommonMessage(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * CommonMessage msg. * @member {string} msg * @memberof tutorial.Message.CommonMessage * @instance */ CommonMessage.prototype.msg = ""; /** * Creates a new CommonMessage instance using the specified properties. * @function create * @memberof tutorial.Message.CommonMessage * @static * @param {tutorial.Message.ICommonMessage=} [properties] Properties to set * @returns {tutorial.Message.CommonMessage} CommonMessage instance */ CommonMessage.create = function create(properties) { return new CommonMessage(properties); }; /** * Encodes the specified CommonMessage message. Does not implicitly {@link tutorial.Message.CommonMessage.verify|verify} messages. * @function encode * @memberof tutorial.Message.CommonMessage * @static * @param {tutorial.Message.ICommonMessage} message CommonMessage message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ CommonMessage.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.msg != null && message.hasOwnProperty("msg")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.msg); return writer; }; /** * Encodes the specified CommonMessage message, length delimited. Does not implicitly {@link tutorial.Message.CommonMessage.verify|verify} messages. * @function encodeDelimited * @memberof tutorial.Message.CommonMessage * @static * @param {tutorial.Message.ICommonMessage} message CommonMessage message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ CommonMessage.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a CommonMessage message from the specified reader or buffer. * @function decode * @memberof tutorial.Message.CommonMessage * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {tutorial.Message.CommonMessage} CommonMessage * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ CommonMessage.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.CommonMessage(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.msg = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a CommonMessage message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof tutorial.Message.CommonMessage * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {tutorial.Message.CommonMessage} CommonMessage * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ CommonMessage.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a CommonMessage message. * @function verify * @memberof tutorial.Message.CommonMessage * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ CommonMessage.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.msg != null && message.hasOwnProperty("msg")) if (!$util.isString(message.msg)) return "msg: string expected"; return null; }; /** * Creates a CommonMessage message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof tutorial.Message.CommonMessage * @static * @param {Object.} object Plain object * @returns {tutorial.Message.CommonMessage} CommonMessage */ CommonMessage.fromObject = function fromObject(object) { if (object instanceof $root.tutorial.Message.CommonMessage) return object; var message = new $root.tutorial.Message.CommonMessage(); if (object.msg != null) message.msg = String(object.msg); return message; }; /** * Creates a plain object from a CommonMessage message. Also converts values to other types if specified. * @function toObject * @memberof tutorial.Message.CommonMessage * @static * @param {tutorial.Message.CommonMessage} message CommonMessage * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ CommonMessage.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) object.msg = ""; if (message.msg != null && message.hasOwnProperty("msg")) object.msg = message.msg; return object; }; /** * Converts this CommonMessage to JSON. * @function toJSON * @memberof tutorial.Message.CommonMessage * @instance * @returns {Object.} JSON object */ CommonMessage.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return CommonMessage; })(); Message.DataMessage = (function() { /** * Properties of a DataMessage. * @memberof tutorial.Message * @interface IDataMessage * @property {number|null} [code] DataMessage code * @property {number|null} [result] DataMessage result * @property {string|null} [data] DataMessage data * @property {string|null} [msg] DataMessage msg */ /** * Constructs a new DataMessage. * @memberof tutorial.Message * @classdesc Represents a DataMessage. * @implements IDataMessage * @constructor * @param {tutorial.Message.IDataMessage=} [properties] Properties to set */ function DataMessage(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * DataMessage code. * @member {number} code * @memberof tutorial.Message.DataMessage * @instance */ DataMessage.prototype.code = 0; /** * DataMessage result. * @member {number} result * @memberof tutorial.Message.DataMessage * @instance */ DataMessage.prototype.result = 0; /** * DataMessage data. * @member {string} data * @memberof tutorial.Message.DataMessage * @instance */ DataMessage.prototype.data = ""; /** * DataMessage msg. * @member {string} msg * @memberof tutorial.Message.DataMessage * @instance */ DataMessage.prototype.msg = ""; /** * Creates a new DataMessage instance using the specified properties. * @function create * @memberof tutorial.Message.DataMessage * @static * @param {tutorial.Message.IDataMessage=} [properties] Properties to set * @returns {tutorial.Message.DataMessage} DataMessage instance */ DataMessage.create = function create(properties) { return new DataMessage(properties); }; /** * Encodes the specified DataMessage message. Does not implicitly {@link tutorial.Message.DataMessage.verify|verify} messages. * @function encode * @memberof tutorial.Message.DataMessage * @static * @param {tutorial.Message.IDataMessage} message DataMessage message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ DataMessage.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.code != null && message.hasOwnProperty("code")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code); if (message.result != null && message.hasOwnProperty("result")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.result); if (message.data != null && message.hasOwnProperty("data")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.data); if (message.msg != null && message.hasOwnProperty("msg")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.msg); return writer; }; /** * Encodes the specified DataMessage message, length delimited. Does not implicitly {@link tutorial.Message.DataMessage.verify|verify} messages. * @function encodeDelimited * @memberof tutorial.Message.DataMessage * @static * @param {tutorial.Message.IDataMessage} message DataMessage message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ DataMessage.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a DataMessage message from the specified reader or buffer. * @function decode * @memberof tutorial.Message.DataMessage * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {tutorial.Message.DataMessage} DataMessage * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ DataMessage.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.DataMessage(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.code = reader.int32(); break; case 2: message.result = reader.int32(); break; case 3: message.data = reader.string(); break; case 4: message.msg = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a DataMessage message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof tutorial.Message.DataMessage * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {tutorial.Message.DataMessage} DataMessage * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ DataMessage.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a DataMessage message. * @function verify * @memberof tutorial.Message.DataMessage * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ DataMessage.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.code != null && message.hasOwnProperty("code")) if (!$util.isInteger(message.code)) return "code: integer expected"; if (message.result != null && message.hasOwnProperty("result")) if (!$util.isInteger(message.result)) return "result: integer expected"; if (message.data != null && message.hasOwnProperty("data")) if (!$util.isString(message.data)) return "data: string expected"; if (message.msg != null && message.hasOwnProperty("msg")) if (!$util.isString(message.msg)) return "msg: string expected"; return null; }; /** * Creates a DataMessage message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof tutorial.Message.DataMessage * @static * @param {Object.} object Plain object * @returns {tutorial.Message.DataMessage} DataMessage */ DataMessage.fromObject = function fromObject(object) { if (object instanceof $root.tutorial.Message.DataMessage) return object; var message = new $root.tutorial.Message.DataMessage(); if (object.code != null) message.code = object.code | 0; if (object.result != null) message.result = object.result | 0; if (object.data != null) message.data = String(object.data); if (object.msg != null) message.msg = String(object.msg); return message; }; /** * Creates a plain object from a DataMessage message. Also converts values to other types if specified. * @function toObject * @memberof tutorial.Message.DataMessage * @static * @param {tutorial.Message.DataMessage} message DataMessage * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ DataMessage.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.code = 0; object.result = 0; object.data = ""; object.msg = ""; } if (message.code != null && message.hasOwnProperty("code")) object.code = message.code; if (message.result != null && message.hasOwnProperty("result")) object.result = message.result; if (message.data != null && message.hasOwnProperty("data")) object.data = message.data; if (message.msg != null && message.hasOwnProperty("msg")) object.msg = message.msg; return object; }; /** * Converts this DataMessage to JSON. * @function toJSON * @memberof tutorial.Message.DataMessage * @instance * @returns {Object.} JSON object */ DataMessage.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return DataMessage; })(); Message.UserInfo = (function() { /** * Properties of a UserInfo. * @memberof tutorial.Message * @interface IUserInfo * @property {number|Long|null} [uid] UserInfo uid * @property {string|null} [nick] UserInfo nick * @property {string|null} [head] UserInfo head */ /** * Constructs a new UserInfo. * @memberof tutorial.Message * @classdesc Represents a UserInfo. * @implements IUserInfo * @constructor * @param {tutorial.Message.IUserInfo=} [properties] Properties to set */ function UserInfo(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * UserInfo uid. * @member {number|Long} uid * @memberof tutorial.Message.UserInfo * @instance */ UserInfo.prototype.uid = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * UserInfo nick. * @member {string} nick * @memberof tutorial.Message.UserInfo * @instance */ UserInfo.prototype.nick = ""; /** * UserInfo head. * @member {string} head * @memberof tutorial.Message.UserInfo * @instance */ UserInfo.prototype.head = ""; /** * Creates a new UserInfo instance using the specified properties. * @function create * @memberof tutorial.Message.UserInfo * @static * @param {tutorial.Message.IUserInfo=} [properties] Properties to set * @returns {tutorial.Message.UserInfo} UserInfo instance */ UserInfo.create = function create(properties) { return new UserInfo(properties); }; /** * Encodes the specified UserInfo message. Does not implicitly {@link tutorial.Message.UserInfo.verify|verify} messages. * @function encode * @memberof tutorial.Message.UserInfo * @static * @param {tutorial.Message.IUserInfo} message UserInfo message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ UserInfo.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.uid != null && message.hasOwnProperty("uid")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.uid); if (message.nick != null && message.hasOwnProperty("nick")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.nick); if (message.head != null && message.hasOwnProperty("head")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.head); return writer; }; /** * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link tutorial.Message.UserInfo.verify|verify} messages. * @function encodeDelimited * @memberof tutorial.Message.UserInfo * @static * @param {tutorial.Message.IUserInfo} message UserInfo message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ UserInfo.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a UserInfo message from the specified reader or buffer. * @function decode * @memberof tutorial.Message.UserInfo * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {tutorial.Message.UserInfo} UserInfo * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ UserInfo.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.UserInfo(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.uid = reader.int64(); break; case 2: message.nick = reader.string(); break; case 3: message.head = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a UserInfo message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof tutorial.Message.UserInfo * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {tutorial.Message.UserInfo} UserInfo * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ UserInfo.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a UserInfo message. * @function verify * @memberof tutorial.Message.UserInfo * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ UserInfo.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.uid != null && message.hasOwnProperty("uid")) if (!$util.isInteger(message.uid) && !(message.uid && $util.isInteger(message.uid.low) && $util.isInteger(message.uid.high))) return "uid: integer|Long expected"; if (message.nick != null && message.hasOwnProperty("nick")) if (!$util.isString(message.nick)) return "nick: string expected"; if (message.head != null && message.hasOwnProperty("head")) if (!$util.isString(message.head)) return "head: string expected"; return null; }; /** * Creates a UserInfo message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof tutorial.Message.UserInfo * @static * @param {Object.} object Plain object * @returns {tutorial.Message.UserInfo} UserInfo */ UserInfo.fromObject = function fromObject(object) { if (object instanceof $root.tutorial.Message.UserInfo) return object; var message = new $root.tutorial.Message.UserInfo(); if (object.uid != null) if ($util.Long) (message.uid = $util.Long.fromValue(object.uid)).unsigned = false; else if (typeof object.uid === "string") message.uid = parseInt(object.uid, 10); else if (typeof object.uid === "number") message.uid = object.uid; else if (typeof object.uid === "object") message.uid = new $util.LongBits(object.uid.low >>> 0, object.uid.high >>> 0).toNumber(); if (object.nick != null) message.nick = String(object.nick); if (object.head != null) message.head = String(object.head); return message; }; /** * Creates a plain object from a UserInfo message. Also converts values to other types if specified. * @function toObject * @memberof tutorial.Message.UserInfo * @static * @param {tutorial.Message.UserInfo} message UserInfo * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ UserInfo.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { if ($util.Long) { var long = new $util.Long(0, 0, false); object.uid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.uid = options.longs === String ? "0" : 0; object.nick = ""; object.head = ""; } if (message.uid != null && message.hasOwnProperty("uid")) if (typeof message.uid === "number") object.uid = options.longs === String ? String(message.uid) : message.uid; else object.uid = options.longs === String ? $util.Long.prototype.toString.call(message.uid) : options.longs === Number ? new $util.LongBits(message.uid.low >>> 0, message.uid.high >>> 0).toNumber() : message.uid; if (message.nick != null && message.hasOwnProperty("nick")) object.nick = message.nick; if (message.head != null && message.hasOwnProperty("head")) object.head = message.head; return object; }; /** * Converts this UserInfo to JSON. * @function toJSON * @memberof tutorial.Message.UserInfo * @instance * @returns {Object.} JSON object */ UserInfo.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return UserInfo; })(); return Message; })(); return tutorial; })(); return $root; });