Bundle.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491
  1. /*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/
  2. (function(global, factory) { /* global define, require, module */
  3. /* AMD */ if (typeof define === 'function' && define.amd)
  4. define(["protobufjs/minimal"], factory);
  5. /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
  6. module.exports = factory(require("protobufjs/minimal"));
  7. })(this, function($protobuf) {
  8. "use strict";
  9. // Common aliases
  10. var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
  11. // Exported root namespace
  12. var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
  13. $root.tutorial = (function() {
  14. /**
  15. * Namespace tutorial.
  16. * @exports tutorial
  17. * @namespace
  18. */
  19. var tutorial = {};
  20. tutorial.Message = (function() {
  21. /**
  22. * Properties of a Message.
  23. * @memberof tutorial
  24. * @interface IMessage
  25. * @property {tutorial.Message.Type|null} [type] Message type
  26. * @property {tutorial.Message.IChatMessage|null} [chatMessage] Message chatMessage
  27. * @property {tutorial.Message.ICommonMessage|null} [commonMessage] Message commonMessage
  28. * @property {tutorial.Message.IDataMessage|null} [dataMessage] Message dataMessage
  29. */
  30. /**
  31. * Constructs a new Message.
  32. * @memberof tutorial
  33. * @classdesc Represents a Message.
  34. * @implements IMessage
  35. * @constructor
  36. * @param {tutorial.IMessage=} [properties] Properties to set
  37. */
  38. function Message(properties) {
  39. if (properties)
  40. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  41. if (properties[keys[i]] != null)
  42. this[keys[i]] = properties[keys[i]];
  43. }
  44. /**
  45. * Message type.
  46. * @member {tutorial.Message.Type} type
  47. * @memberof tutorial.Message
  48. * @instance
  49. */
  50. Message.prototype.type = 0;
  51. /**
  52. * Message chatMessage.
  53. * @member {tutorial.Message.IChatMessage|null|undefined} chatMessage
  54. * @memberof tutorial.Message
  55. * @instance
  56. */
  57. Message.prototype.chatMessage = null;
  58. /**
  59. * Message commonMessage.
  60. * @member {tutorial.Message.ICommonMessage|null|undefined} commonMessage
  61. * @memberof tutorial.Message
  62. * @instance
  63. */
  64. Message.prototype.commonMessage = null;
  65. /**
  66. * Message dataMessage.
  67. * @member {tutorial.Message.IDataMessage|null|undefined} dataMessage
  68. * @memberof tutorial.Message
  69. * @instance
  70. */
  71. Message.prototype.dataMessage = null;
  72. /**
  73. * Creates a new Message instance using the specified properties.
  74. * @function create
  75. * @memberof tutorial.Message
  76. * @static
  77. * @param {tutorial.IMessage=} [properties] Properties to set
  78. * @returns {tutorial.Message} Message instance
  79. */
  80. Message.create = function create(properties) {
  81. return new Message(properties);
  82. };
  83. /**
  84. * Encodes the specified Message message. Does not implicitly {@link tutorial.Message.verify|verify} messages.
  85. * @function encode
  86. * @memberof tutorial.Message
  87. * @static
  88. * @param {tutorial.IMessage} message Message message or plain object to encode
  89. * @param {$protobuf.Writer} [writer] Writer to encode to
  90. * @returns {$protobuf.Writer} Writer
  91. */
  92. Message.encode = function encode(message, writer) {
  93. if (!writer)
  94. writer = $Writer.create();
  95. if (message.type != null && message.hasOwnProperty("type"))
  96. writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type);
  97. if (message.chatMessage != null && message.hasOwnProperty("chatMessage"))
  98. $root.tutorial.Message.ChatMessage.encode(message.chatMessage, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
  99. if (message.commonMessage != null && message.hasOwnProperty("commonMessage"))
  100. $root.tutorial.Message.CommonMessage.encode(message.commonMessage, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
  101. if (message.dataMessage != null && message.hasOwnProperty("dataMessage"))
  102. $root.tutorial.Message.DataMessage.encode(message.dataMessage, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
  103. return writer;
  104. };
  105. /**
  106. * Encodes the specified Message message, length delimited. Does not implicitly {@link tutorial.Message.verify|verify} messages.
  107. * @function encodeDelimited
  108. * @memberof tutorial.Message
  109. * @static
  110. * @param {tutorial.IMessage} message Message message or plain object to encode
  111. * @param {$protobuf.Writer} [writer] Writer to encode to
  112. * @returns {$protobuf.Writer} Writer
  113. */
  114. Message.encodeDelimited = function encodeDelimited(message, writer) {
  115. return this.encode(message, writer).ldelim();
  116. };
  117. /**
  118. * Decodes a Message message from the specified reader or buffer.
  119. * @function decode
  120. * @memberof tutorial.Message
  121. * @static
  122. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  123. * @param {number} [length] Message length if known beforehand
  124. * @returns {tutorial.Message} Message
  125. * @throws {Error} If the payload is not a reader or valid buffer
  126. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  127. */
  128. Message.decode = function decode(reader, length) {
  129. if (!(reader instanceof $Reader))
  130. reader = $Reader.create(reader);
  131. var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message();
  132. while (reader.pos < end) {
  133. var tag = reader.uint32();
  134. switch (tag >>> 3) {
  135. case 1:
  136. message.type = reader.int32();
  137. break;
  138. case 2:
  139. message.chatMessage = $root.tutorial.Message.ChatMessage.decode(reader, reader.uint32());
  140. break;
  141. case 3:
  142. message.commonMessage = $root.tutorial.Message.CommonMessage.decode(reader, reader.uint32());
  143. break;
  144. case 4:
  145. message.dataMessage = $root.tutorial.Message.DataMessage.decode(reader, reader.uint32());
  146. break;
  147. default:
  148. reader.skipType(tag & 7);
  149. break;
  150. }
  151. }
  152. return message;
  153. };
  154. /**
  155. * Decodes a Message message from the specified reader or buffer, length delimited.
  156. * @function decodeDelimited
  157. * @memberof tutorial.Message
  158. * @static
  159. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  160. * @returns {tutorial.Message} Message
  161. * @throws {Error} If the payload is not a reader or valid buffer
  162. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  163. */
  164. Message.decodeDelimited = function decodeDelimited(reader) {
  165. if (!(reader instanceof $Reader))
  166. reader = new $Reader(reader);
  167. return this.decode(reader, reader.uint32());
  168. };
  169. /**
  170. * Verifies a Message message.
  171. * @function verify
  172. * @memberof tutorial.Message
  173. * @static
  174. * @param {Object.<string,*>} message Plain object to verify
  175. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  176. */
  177. Message.verify = function verify(message) {
  178. if (typeof message !== "object" || message === null)
  179. return "object expected";
  180. if (message.type != null && message.hasOwnProperty("type"))
  181. switch (message.type) {
  182. default:
  183. return "type: enum value expected";
  184. case 0:
  185. case 1:
  186. case 2:
  187. break;
  188. }
  189. if (message.chatMessage != null && message.hasOwnProperty("chatMessage")) {
  190. var error = $root.tutorial.Message.ChatMessage.verify(message.chatMessage);
  191. if (error)
  192. return "chatMessage." + error;
  193. }
  194. if (message.commonMessage != null && message.hasOwnProperty("commonMessage")) {
  195. var error = $root.tutorial.Message.CommonMessage.verify(message.commonMessage);
  196. if (error)
  197. return "commonMessage." + error;
  198. }
  199. if (message.dataMessage != null && message.hasOwnProperty("dataMessage")) {
  200. var error = $root.tutorial.Message.DataMessage.verify(message.dataMessage);
  201. if (error)
  202. return "dataMessage." + error;
  203. }
  204. return null;
  205. };
  206. /**
  207. * Creates a Message message from a plain object. Also converts values to their respective internal types.
  208. * @function fromObject
  209. * @memberof tutorial.Message
  210. * @static
  211. * @param {Object.<string,*>} object Plain object
  212. * @returns {tutorial.Message} Message
  213. */
  214. Message.fromObject = function fromObject(object) {
  215. if (object instanceof $root.tutorial.Message)
  216. return object;
  217. var message = new $root.tutorial.Message();
  218. switch (object.type) {
  219. case "COMMON":
  220. case 0:
  221. message.type = 0;
  222. break;
  223. case "CHAT":
  224. case 1:
  225. message.type = 1;
  226. break;
  227. case "DATA":
  228. case 2:
  229. message.type = 2;
  230. break;
  231. }
  232. if (object.chatMessage != null) {
  233. if (typeof object.chatMessage !== "object")
  234. throw TypeError(".tutorial.Message.chatMessage: object expected");
  235. message.chatMessage = $root.tutorial.Message.ChatMessage.fromObject(object.chatMessage);
  236. }
  237. if (object.commonMessage != null) {
  238. if (typeof object.commonMessage !== "object")
  239. throw TypeError(".tutorial.Message.commonMessage: object expected");
  240. message.commonMessage = $root.tutorial.Message.CommonMessage.fromObject(object.commonMessage);
  241. }
  242. if (object.dataMessage != null) {
  243. if (typeof object.dataMessage !== "object")
  244. throw TypeError(".tutorial.Message.dataMessage: object expected");
  245. message.dataMessage = $root.tutorial.Message.DataMessage.fromObject(object.dataMessage);
  246. }
  247. return message;
  248. };
  249. /**
  250. * Creates a plain object from a Message message. Also converts values to other types if specified.
  251. * @function toObject
  252. * @memberof tutorial.Message
  253. * @static
  254. * @param {tutorial.Message} message Message
  255. * @param {$protobuf.IConversionOptions} [options] Conversion options
  256. * @returns {Object.<string,*>} Plain object
  257. */
  258. Message.toObject = function toObject(message, options) {
  259. if (!options)
  260. options = {};
  261. var object = {};
  262. if (options.defaults) {
  263. object.type = options.enums === String ? "COMMON" : 0;
  264. object.chatMessage = null;
  265. object.commonMessage = null;
  266. object.dataMessage = null;
  267. }
  268. if (message.type != null && message.hasOwnProperty("type"))
  269. object.type = options.enums === String ? $root.tutorial.Message.Type[message.type] : message.type;
  270. if (message.chatMessage != null && message.hasOwnProperty("chatMessage"))
  271. object.chatMessage = $root.tutorial.Message.ChatMessage.toObject(message.chatMessage, options);
  272. if (message.commonMessage != null && message.hasOwnProperty("commonMessage"))
  273. object.commonMessage = $root.tutorial.Message.CommonMessage.toObject(message.commonMessage, options);
  274. if (message.dataMessage != null && message.hasOwnProperty("dataMessage"))
  275. object.dataMessage = $root.tutorial.Message.DataMessage.toObject(message.dataMessage, options);
  276. return object;
  277. };
  278. /**
  279. * Converts this Message to JSON.
  280. * @function toJSON
  281. * @memberof tutorial.Message
  282. * @instance
  283. * @returns {Object.<string,*>} JSON object
  284. */
  285. Message.prototype.toJSON = function toJSON() {
  286. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  287. };
  288. /**
  289. * Type enum.
  290. * @name tutorial.Message.Type
  291. * @enum {string}
  292. * @property {number} COMMON=0 COMMON value
  293. * @property {number} CHAT=1 CHAT value
  294. * @property {number} DATA=2 DATA value
  295. */
  296. Message.Type = (function() {
  297. var valuesById = {}, values = Object.create(valuesById);
  298. values[valuesById[0] = "COMMON"] = 0;
  299. values[valuesById[1] = "CHAT"] = 1;
  300. values[valuesById[2] = "DATA"] = 2;
  301. return values;
  302. })();
  303. Message.ChatMessage = (function() {
  304. /**
  305. * Properties of a ChatMessage.
  306. * @memberof tutorial.Message
  307. * @interface IChatMessage
  308. * @property {number|Long|null} [id] ChatMessage id
  309. * @property {number|Long|null} [uid] ChatMessage uid
  310. * @property {number|Long|null} [receiveUid] ChatMessage receiveUid
  311. * @property {number|null} [bType] ChatMessage bType
  312. * @property {number|null} [contentType] ChatMessage contentType
  313. * @property {string|null} [msg] ChatMessage msg
  314. * @property {number|null} [contentLen] ChatMessage contentLen
  315. * @property {number|null} [hasAuth] ChatMessage hasAuth
  316. * @property {number|Long|null} [sendTime] ChatMessage sendTime
  317. * @property {number|null} [isRead] ChatMessage isRead
  318. * @property {tutorial.Message.IUserInfo|null} [sender] ChatMessage sender
  319. */
  320. /**
  321. * Constructs a new ChatMessage.
  322. * @memberof tutorial.Message
  323. * @classdesc Represents a ChatMessage.
  324. * @implements IChatMessage
  325. * @constructor
  326. * @param {tutorial.Message.IChatMessage=} [properties] Properties to set
  327. */
  328. function ChatMessage(properties) {
  329. if (properties)
  330. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  331. if (properties[keys[i]] != null)
  332. this[keys[i]] = properties[keys[i]];
  333. }
  334. /**
  335. * ChatMessage id.
  336. * @member {number|Long} id
  337. * @memberof tutorial.Message.ChatMessage
  338. * @instance
  339. */
  340. ChatMessage.prototype.id = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
  341. /**
  342. * ChatMessage uid.
  343. * @member {number|Long} uid
  344. * @memberof tutorial.Message.ChatMessage
  345. * @instance
  346. */
  347. ChatMessage.prototype.uid = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
  348. /**
  349. * ChatMessage receiveUid.
  350. * @member {number|Long} receiveUid
  351. * @memberof tutorial.Message.ChatMessage
  352. * @instance
  353. */
  354. ChatMessage.prototype.receiveUid = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
  355. /**
  356. * ChatMessage bType.
  357. * @member {number} bType
  358. * @memberof tutorial.Message.ChatMessage
  359. * @instance
  360. */
  361. ChatMessage.prototype.bType = 0;
  362. /**
  363. * ChatMessage contentType.
  364. * @member {number} contentType
  365. * @memberof tutorial.Message.ChatMessage
  366. * @instance
  367. */
  368. ChatMessage.prototype.contentType = 0;
  369. /**
  370. * ChatMessage msg.
  371. * @member {string} msg
  372. * @memberof tutorial.Message.ChatMessage
  373. * @instance
  374. */
  375. ChatMessage.prototype.msg = "";
  376. /**
  377. * ChatMessage contentLen.
  378. * @member {number} contentLen
  379. * @memberof tutorial.Message.ChatMessage
  380. * @instance
  381. */
  382. ChatMessage.prototype.contentLen = 0;
  383. /**
  384. * ChatMessage hasAuth.
  385. * @member {number} hasAuth
  386. * @memberof tutorial.Message.ChatMessage
  387. * @instance
  388. */
  389. ChatMessage.prototype.hasAuth = 0;
  390. /**
  391. * ChatMessage sendTime.
  392. * @member {number|Long} sendTime
  393. * @memberof tutorial.Message.ChatMessage
  394. * @instance
  395. */
  396. ChatMessage.prototype.sendTime = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
  397. /**
  398. * ChatMessage isRead.
  399. * @member {number} isRead
  400. * @memberof tutorial.Message.ChatMessage
  401. * @instance
  402. */
  403. ChatMessage.prototype.isRead = 0;
  404. /**
  405. * ChatMessage sender.
  406. * @member {tutorial.Message.IUserInfo|null|undefined} sender
  407. * @memberof tutorial.Message.ChatMessage
  408. * @instance
  409. */
  410. ChatMessage.prototype.sender = null;
  411. /**
  412. * Creates a new ChatMessage instance using the specified properties.
  413. * @function create
  414. * @memberof tutorial.Message.ChatMessage
  415. * @static
  416. * @param {tutorial.Message.IChatMessage=} [properties] Properties to set
  417. * @returns {tutorial.Message.ChatMessage} ChatMessage instance
  418. */
  419. ChatMessage.create = function create(properties) {
  420. return new ChatMessage(properties);
  421. };
  422. /**
  423. * Encodes the specified ChatMessage message. Does not implicitly {@link tutorial.Message.ChatMessage.verify|verify} messages.
  424. * @function encode
  425. * @memberof tutorial.Message.ChatMessage
  426. * @static
  427. * @param {tutorial.Message.IChatMessage} message ChatMessage message or plain object to encode
  428. * @param {$protobuf.Writer} [writer] Writer to encode to
  429. * @returns {$protobuf.Writer} Writer
  430. */
  431. ChatMessage.encode = function encode(message, writer) {
  432. if (!writer)
  433. writer = $Writer.create();
  434. if (message.id != null && message.hasOwnProperty("id"))
  435. writer.uint32(/* id 1, wireType 0 =*/8).int64(message.id);
  436. if (message.uid != null && message.hasOwnProperty("uid"))
  437. writer.uint32(/* id 2, wireType 0 =*/16).int64(message.uid);
  438. if (message.receiveUid != null && message.hasOwnProperty("receiveUid"))
  439. writer.uint32(/* id 3, wireType 0 =*/24).int64(message.receiveUid);
  440. if (message.bType != null && message.hasOwnProperty("bType"))
  441. writer.uint32(/* id 4, wireType 0 =*/32).int32(message.bType);
  442. if (message.contentType != null && message.hasOwnProperty("contentType"))
  443. writer.uint32(/* id 5, wireType 0 =*/40).int32(message.contentType);
  444. if (message.msg != null && message.hasOwnProperty("msg"))
  445. writer.uint32(/* id 6, wireType 2 =*/50).string(message.msg);
  446. if (message.contentLen != null && message.hasOwnProperty("contentLen"))
  447. writer.uint32(/* id 7, wireType 0 =*/56).int32(message.contentLen);
  448. if (message.hasAuth != null && message.hasOwnProperty("hasAuth"))
  449. writer.uint32(/* id 8, wireType 0 =*/64).int32(message.hasAuth);
  450. if (message.sendTime != null && message.hasOwnProperty("sendTime"))
  451. writer.uint32(/* id 9, wireType 0 =*/72).int64(message.sendTime);
  452. if (message.isRead != null && message.hasOwnProperty("isRead"))
  453. writer.uint32(/* id 10, wireType 0 =*/80).int32(message.isRead);
  454. if (message.sender != null && message.hasOwnProperty("sender"))
  455. $root.tutorial.Message.UserInfo.encode(message.sender, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim();
  456. return writer;
  457. };
  458. /**
  459. * Encodes the specified ChatMessage message, length delimited. Does not implicitly {@link tutorial.Message.ChatMessage.verify|verify} messages.
  460. * @function encodeDelimited
  461. * @memberof tutorial.Message.ChatMessage
  462. * @static
  463. * @param {tutorial.Message.IChatMessage} message ChatMessage message or plain object to encode
  464. * @param {$protobuf.Writer} [writer] Writer to encode to
  465. * @returns {$protobuf.Writer} Writer
  466. */
  467. ChatMessage.encodeDelimited = function encodeDelimited(message, writer) {
  468. return this.encode(message, writer).ldelim();
  469. };
  470. /**
  471. * Decodes a ChatMessage message from the specified reader or buffer.
  472. * @function decode
  473. * @memberof tutorial.Message.ChatMessage
  474. * @static
  475. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  476. * @param {number} [length] Message length if known beforehand
  477. * @returns {tutorial.Message.ChatMessage} ChatMessage
  478. * @throws {Error} If the payload is not a reader or valid buffer
  479. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  480. */
  481. ChatMessage.decode = function decode(reader, length) {
  482. if (!(reader instanceof $Reader))
  483. reader = $Reader.create(reader);
  484. var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.ChatMessage();
  485. while (reader.pos < end) {
  486. var tag = reader.uint32();
  487. switch (tag >>> 3) {
  488. case 1:
  489. message.id = reader.int64();
  490. break;
  491. case 2:
  492. message.uid = reader.int64();
  493. break;
  494. case 3:
  495. message.receiveUid = reader.int64();
  496. break;
  497. case 4:
  498. message.bType = reader.int32();
  499. break;
  500. case 5:
  501. message.contentType = reader.int32();
  502. break;
  503. case 6:
  504. message.msg = reader.string();
  505. break;
  506. case 7:
  507. message.contentLen = reader.int32();
  508. break;
  509. case 8:
  510. message.hasAuth = reader.int32();
  511. break;
  512. case 9:
  513. message.sendTime = reader.int64();
  514. break;
  515. case 10:
  516. message.isRead = reader.int32();
  517. break;
  518. case 11:
  519. message.sender = $root.tutorial.Message.UserInfo.decode(reader, reader.uint32());
  520. break;
  521. default:
  522. reader.skipType(tag & 7);
  523. break;
  524. }
  525. }
  526. return message;
  527. };
  528. /**
  529. * Decodes a ChatMessage message from the specified reader or buffer, length delimited.
  530. * @function decodeDelimited
  531. * @memberof tutorial.Message.ChatMessage
  532. * @static
  533. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  534. * @returns {tutorial.Message.ChatMessage} ChatMessage
  535. * @throws {Error} If the payload is not a reader or valid buffer
  536. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  537. */
  538. ChatMessage.decodeDelimited = function decodeDelimited(reader) {
  539. if (!(reader instanceof $Reader))
  540. reader = new $Reader(reader);
  541. return this.decode(reader, reader.uint32());
  542. };
  543. /**
  544. * Verifies a ChatMessage message.
  545. * @function verify
  546. * @memberof tutorial.Message.ChatMessage
  547. * @static
  548. * @param {Object.<string,*>} message Plain object to verify
  549. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  550. */
  551. ChatMessage.verify = function verify(message) {
  552. if (typeof message !== "object" || message === null)
  553. return "object expected";
  554. if (message.id != null && message.hasOwnProperty("id"))
  555. if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high)))
  556. return "id: integer|Long expected";
  557. if (message.uid != null && message.hasOwnProperty("uid"))
  558. if (!$util.isInteger(message.uid) && !(message.uid && $util.isInteger(message.uid.low) && $util.isInteger(message.uid.high)))
  559. return "uid: integer|Long expected";
  560. if (message.receiveUid != null && message.hasOwnProperty("receiveUid"))
  561. if (!$util.isInteger(message.receiveUid) && !(message.receiveUid && $util.isInteger(message.receiveUid.low) && $util.isInteger(message.receiveUid.high)))
  562. return "receiveUid: integer|Long expected";
  563. if (message.bType != null && message.hasOwnProperty("bType"))
  564. if (!$util.isInteger(message.bType))
  565. return "bType: integer expected";
  566. if (message.contentType != null && message.hasOwnProperty("contentType"))
  567. if (!$util.isInteger(message.contentType))
  568. return "contentType: integer expected";
  569. if (message.msg != null && message.hasOwnProperty("msg"))
  570. if (!$util.isString(message.msg))
  571. return "msg: string expected";
  572. if (message.contentLen != null && message.hasOwnProperty("contentLen"))
  573. if (!$util.isInteger(message.contentLen))
  574. return "contentLen: integer expected";
  575. if (message.hasAuth != null && message.hasOwnProperty("hasAuth"))
  576. if (!$util.isInteger(message.hasAuth))
  577. return "hasAuth: integer expected";
  578. if (message.sendTime != null && message.hasOwnProperty("sendTime"))
  579. if (!$util.isInteger(message.sendTime) && !(message.sendTime && $util.isInteger(message.sendTime.low) && $util.isInteger(message.sendTime.high)))
  580. return "sendTime: integer|Long expected";
  581. if (message.isRead != null && message.hasOwnProperty("isRead"))
  582. if (!$util.isInteger(message.isRead))
  583. return "isRead: integer expected";
  584. if (message.sender != null && message.hasOwnProperty("sender")) {
  585. var error = $root.tutorial.Message.UserInfo.verify(message.sender);
  586. if (error)
  587. return "sender." + error;
  588. }
  589. return null;
  590. };
  591. /**
  592. * Creates a ChatMessage message from a plain object. Also converts values to their respective internal types.
  593. * @function fromObject
  594. * @memberof tutorial.Message.ChatMessage
  595. * @static
  596. * @param {Object.<string,*>} object Plain object
  597. * @returns {tutorial.Message.ChatMessage} ChatMessage
  598. */
  599. ChatMessage.fromObject = function fromObject(object) {
  600. if (object instanceof $root.tutorial.Message.ChatMessage)
  601. return object;
  602. var message = new $root.tutorial.Message.ChatMessage();
  603. if (object.id != null)
  604. if ($util.Long)
  605. (message.id = $util.Long.fromValue(object.id)).unsigned = false;
  606. else if (typeof object.id === "string")
  607. message.id = parseInt(object.id, 10);
  608. else if (typeof object.id === "number")
  609. message.id = object.id;
  610. else if (typeof object.id === "object")
  611. message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber();
  612. if (object.uid != null)
  613. if ($util.Long)
  614. (message.uid = $util.Long.fromValue(object.uid)).unsigned = false;
  615. else if (typeof object.uid === "string")
  616. message.uid = parseInt(object.uid, 10);
  617. else if (typeof object.uid === "number")
  618. message.uid = object.uid;
  619. else if (typeof object.uid === "object")
  620. message.uid = new $util.LongBits(object.uid.low >>> 0, object.uid.high >>> 0).toNumber();
  621. if (object.receiveUid != null)
  622. if ($util.Long)
  623. (message.receiveUid = $util.Long.fromValue(object.receiveUid)).unsigned = false;
  624. else if (typeof object.receiveUid === "string")
  625. message.receiveUid = parseInt(object.receiveUid, 10);
  626. else if (typeof object.receiveUid === "number")
  627. message.receiveUid = object.receiveUid;
  628. else if (typeof object.receiveUid === "object")
  629. message.receiveUid = new $util.LongBits(object.receiveUid.low >>> 0, object.receiveUid.high >>> 0).toNumber();
  630. if (object.bType != null)
  631. message.bType = object.bType | 0;
  632. if (object.contentType != null)
  633. message.contentType = object.contentType | 0;
  634. if (object.msg != null)
  635. message.msg = String(object.msg);
  636. if (object.contentLen != null)
  637. message.contentLen = object.contentLen | 0;
  638. if (object.hasAuth != null)
  639. message.hasAuth = object.hasAuth | 0;
  640. if (object.sendTime != null)
  641. if ($util.Long)
  642. (message.sendTime = $util.Long.fromValue(object.sendTime)).unsigned = false;
  643. else if (typeof object.sendTime === "string")
  644. message.sendTime = parseInt(object.sendTime, 10);
  645. else if (typeof object.sendTime === "number")
  646. message.sendTime = object.sendTime;
  647. else if (typeof object.sendTime === "object")
  648. message.sendTime = new $util.LongBits(object.sendTime.low >>> 0, object.sendTime.high >>> 0).toNumber();
  649. if (object.isRead != null)
  650. message.isRead = object.isRead | 0;
  651. if (object.sender != null) {
  652. if (typeof object.sender !== "object")
  653. throw TypeError(".tutorial.Message.ChatMessage.sender: object expected");
  654. message.sender = $root.tutorial.Message.UserInfo.fromObject(object.sender);
  655. }
  656. return message;
  657. };
  658. /**
  659. * Creates a plain object from a ChatMessage message. Also converts values to other types if specified.
  660. * @function toObject
  661. * @memberof tutorial.Message.ChatMessage
  662. * @static
  663. * @param {tutorial.Message.ChatMessage} message ChatMessage
  664. * @param {$protobuf.IConversionOptions} [options] Conversion options
  665. * @returns {Object.<string,*>} Plain object
  666. */
  667. ChatMessage.toObject = function toObject(message, options) {
  668. if (!options)
  669. options = {};
  670. var object = {};
  671. if (options.defaults) {
  672. if ($util.Long) {
  673. var long = new $util.Long(0, 0, false);
  674. object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  675. } else
  676. object.id = options.longs === String ? "0" : 0;
  677. if ($util.Long) {
  678. var long = new $util.Long(0, 0, false);
  679. object.uid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  680. } else
  681. object.uid = options.longs === String ? "0" : 0;
  682. if ($util.Long) {
  683. var long = new $util.Long(0, 0, false);
  684. object.receiveUid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  685. } else
  686. object.receiveUid = options.longs === String ? "0" : 0;
  687. object.bType = 0;
  688. object.contentType = 0;
  689. object.msg = "";
  690. object.contentLen = 0;
  691. object.hasAuth = 0;
  692. if ($util.Long) {
  693. var long = new $util.Long(0, 0, false);
  694. object.sendTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  695. } else
  696. object.sendTime = options.longs === String ? "0" : 0;
  697. object.isRead = 0;
  698. object.sender = null;
  699. }
  700. if (message.id != null && message.hasOwnProperty("id"))
  701. if (typeof message.id === "number")
  702. object.id = options.longs === String ? String(message.id) : message.id;
  703. else
  704. 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;
  705. if (message.uid != null && message.hasOwnProperty("uid"))
  706. if (typeof message.uid === "number")
  707. object.uid = options.longs === String ? String(message.uid) : message.uid;
  708. else
  709. 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;
  710. if (message.receiveUid != null && message.hasOwnProperty("receiveUid"))
  711. if (typeof message.receiveUid === "number")
  712. object.receiveUid = options.longs === String ? String(message.receiveUid) : message.receiveUid;
  713. else
  714. 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;
  715. if (message.bType != null && message.hasOwnProperty("bType"))
  716. object.bType = message.bType;
  717. if (message.contentType != null && message.hasOwnProperty("contentType"))
  718. object.contentType = message.contentType;
  719. if (message.msg != null && message.hasOwnProperty("msg"))
  720. object.msg = message.msg;
  721. if (message.contentLen != null && message.hasOwnProperty("contentLen"))
  722. object.contentLen = message.contentLen;
  723. if (message.hasAuth != null && message.hasOwnProperty("hasAuth"))
  724. object.hasAuth = message.hasAuth;
  725. if (message.sendTime != null && message.hasOwnProperty("sendTime"))
  726. if (typeof message.sendTime === "number")
  727. object.sendTime = options.longs === String ? String(message.sendTime) : message.sendTime;
  728. else
  729. 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;
  730. if (message.isRead != null && message.hasOwnProperty("isRead"))
  731. object.isRead = message.isRead;
  732. if (message.sender != null && message.hasOwnProperty("sender"))
  733. object.sender = $root.tutorial.Message.UserInfo.toObject(message.sender, options);
  734. return object;
  735. };
  736. /**
  737. * Converts this ChatMessage to JSON.
  738. * @function toJSON
  739. * @memberof tutorial.Message.ChatMessage
  740. * @instance
  741. * @returns {Object.<string,*>} JSON object
  742. */
  743. ChatMessage.prototype.toJSON = function toJSON() {
  744. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  745. };
  746. return ChatMessage;
  747. })();
  748. Message.CommonMessage = (function() {
  749. /**
  750. * Properties of a CommonMessage.
  751. * @memberof tutorial.Message
  752. * @interface ICommonMessage
  753. * @property {string|null} [msg] CommonMessage msg
  754. */
  755. /**
  756. * Constructs a new CommonMessage.
  757. * @memberof tutorial.Message
  758. * @classdesc Represents a CommonMessage.
  759. * @implements ICommonMessage
  760. * @constructor
  761. * @param {tutorial.Message.ICommonMessage=} [properties] Properties to set
  762. */
  763. function CommonMessage(properties) {
  764. if (properties)
  765. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  766. if (properties[keys[i]] != null)
  767. this[keys[i]] = properties[keys[i]];
  768. }
  769. /**
  770. * CommonMessage msg.
  771. * @member {string} msg
  772. * @memberof tutorial.Message.CommonMessage
  773. * @instance
  774. */
  775. CommonMessage.prototype.msg = "";
  776. /**
  777. * Creates a new CommonMessage instance using the specified properties.
  778. * @function create
  779. * @memberof tutorial.Message.CommonMessage
  780. * @static
  781. * @param {tutorial.Message.ICommonMessage=} [properties] Properties to set
  782. * @returns {tutorial.Message.CommonMessage} CommonMessage instance
  783. */
  784. CommonMessage.create = function create(properties) {
  785. return new CommonMessage(properties);
  786. };
  787. /**
  788. * Encodes the specified CommonMessage message. Does not implicitly {@link tutorial.Message.CommonMessage.verify|verify} messages.
  789. * @function encode
  790. * @memberof tutorial.Message.CommonMessage
  791. * @static
  792. * @param {tutorial.Message.ICommonMessage} message CommonMessage message or plain object to encode
  793. * @param {$protobuf.Writer} [writer] Writer to encode to
  794. * @returns {$protobuf.Writer} Writer
  795. */
  796. CommonMessage.encode = function encode(message, writer) {
  797. if (!writer)
  798. writer = $Writer.create();
  799. if (message.msg != null && message.hasOwnProperty("msg"))
  800. writer.uint32(/* id 1, wireType 2 =*/10).string(message.msg);
  801. return writer;
  802. };
  803. /**
  804. * Encodes the specified CommonMessage message, length delimited. Does not implicitly {@link tutorial.Message.CommonMessage.verify|verify} messages.
  805. * @function encodeDelimited
  806. * @memberof tutorial.Message.CommonMessage
  807. * @static
  808. * @param {tutorial.Message.ICommonMessage} message CommonMessage message or plain object to encode
  809. * @param {$protobuf.Writer} [writer] Writer to encode to
  810. * @returns {$protobuf.Writer} Writer
  811. */
  812. CommonMessage.encodeDelimited = function encodeDelimited(message, writer) {
  813. return this.encode(message, writer).ldelim();
  814. };
  815. /**
  816. * Decodes a CommonMessage message from the specified reader or buffer.
  817. * @function decode
  818. * @memberof tutorial.Message.CommonMessage
  819. * @static
  820. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  821. * @param {number} [length] Message length if known beforehand
  822. * @returns {tutorial.Message.CommonMessage} CommonMessage
  823. * @throws {Error} If the payload is not a reader or valid buffer
  824. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  825. */
  826. CommonMessage.decode = function decode(reader, length) {
  827. if (!(reader instanceof $Reader))
  828. reader = $Reader.create(reader);
  829. var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.CommonMessage();
  830. while (reader.pos < end) {
  831. var tag = reader.uint32();
  832. switch (tag >>> 3) {
  833. case 1:
  834. message.msg = reader.string();
  835. break;
  836. default:
  837. reader.skipType(tag & 7);
  838. break;
  839. }
  840. }
  841. return message;
  842. };
  843. /**
  844. * Decodes a CommonMessage message from the specified reader or buffer, length delimited.
  845. * @function decodeDelimited
  846. * @memberof tutorial.Message.CommonMessage
  847. * @static
  848. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  849. * @returns {tutorial.Message.CommonMessage} CommonMessage
  850. * @throws {Error} If the payload is not a reader or valid buffer
  851. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  852. */
  853. CommonMessage.decodeDelimited = function decodeDelimited(reader) {
  854. if (!(reader instanceof $Reader))
  855. reader = new $Reader(reader);
  856. return this.decode(reader, reader.uint32());
  857. };
  858. /**
  859. * Verifies a CommonMessage message.
  860. * @function verify
  861. * @memberof tutorial.Message.CommonMessage
  862. * @static
  863. * @param {Object.<string,*>} message Plain object to verify
  864. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  865. */
  866. CommonMessage.verify = function verify(message) {
  867. if (typeof message !== "object" || message === null)
  868. return "object expected";
  869. if (message.msg != null && message.hasOwnProperty("msg"))
  870. if (!$util.isString(message.msg))
  871. return "msg: string expected";
  872. return null;
  873. };
  874. /**
  875. * Creates a CommonMessage message from a plain object. Also converts values to their respective internal types.
  876. * @function fromObject
  877. * @memberof tutorial.Message.CommonMessage
  878. * @static
  879. * @param {Object.<string,*>} object Plain object
  880. * @returns {tutorial.Message.CommonMessage} CommonMessage
  881. */
  882. CommonMessage.fromObject = function fromObject(object) {
  883. if (object instanceof $root.tutorial.Message.CommonMessage)
  884. return object;
  885. var message = new $root.tutorial.Message.CommonMessage();
  886. if (object.msg != null)
  887. message.msg = String(object.msg);
  888. return message;
  889. };
  890. /**
  891. * Creates a plain object from a CommonMessage message. Also converts values to other types if specified.
  892. * @function toObject
  893. * @memberof tutorial.Message.CommonMessage
  894. * @static
  895. * @param {tutorial.Message.CommonMessage} message CommonMessage
  896. * @param {$protobuf.IConversionOptions} [options] Conversion options
  897. * @returns {Object.<string,*>} Plain object
  898. */
  899. CommonMessage.toObject = function toObject(message, options) {
  900. if (!options)
  901. options = {};
  902. var object = {};
  903. if (options.defaults)
  904. object.msg = "";
  905. if (message.msg != null && message.hasOwnProperty("msg"))
  906. object.msg = message.msg;
  907. return object;
  908. };
  909. /**
  910. * Converts this CommonMessage to JSON.
  911. * @function toJSON
  912. * @memberof tutorial.Message.CommonMessage
  913. * @instance
  914. * @returns {Object.<string,*>} JSON object
  915. */
  916. CommonMessage.prototype.toJSON = function toJSON() {
  917. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  918. };
  919. return CommonMessage;
  920. })();
  921. Message.DataMessage = (function() {
  922. /**
  923. * Properties of a DataMessage.
  924. * @memberof tutorial.Message
  925. * @interface IDataMessage
  926. * @property {number|null} [code] DataMessage code
  927. * @property {number|null} [result] DataMessage result
  928. * @property {string|null} [data] DataMessage data
  929. * @property {string|null} [msg] DataMessage msg
  930. */
  931. /**
  932. * Constructs a new DataMessage.
  933. * @memberof tutorial.Message
  934. * @classdesc Represents a DataMessage.
  935. * @implements IDataMessage
  936. * @constructor
  937. * @param {tutorial.Message.IDataMessage=} [properties] Properties to set
  938. */
  939. function DataMessage(properties) {
  940. if (properties)
  941. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  942. if (properties[keys[i]] != null)
  943. this[keys[i]] = properties[keys[i]];
  944. }
  945. /**
  946. * DataMessage code.
  947. * @member {number} code
  948. * @memberof tutorial.Message.DataMessage
  949. * @instance
  950. */
  951. DataMessage.prototype.code = 0;
  952. /**
  953. * DataMessage result.
  954. * @member {number} result
  955. * @memberof tutorial.Message.DataMessage
  956. * @instance
  957. */
  958. DataMessage.prototype.result = 0;
  959. /**
  960. * DataMessage data.
  961. * @member {string} data
  962. * @memberof tutorial.Message.DataMessage
  963. * @instance
  964. */
  965. DataMessage.prototype.data = "";
  966. /**
  967. * DataMessage msg.
  968. * @member {string} msg
  969. * @memberof tutorial.Message.DataMessage
  970. * @instance
  971. */
  972. DataMessage.prototype.msg = "";
  973. /**
  974. * Creates a new DataMessage instance using the specified properties.
  975. * @function create
  976. * @memberof tutorial.Message.DataMessage
  977. * @static
  978. * @param {tutorial.Message.IDataMessage=} [properties] Properties to set
  979. * @returns {tutorial.Message.DataMessage} DataMessage instance
  980. */
  981. DataMessage.create = function create(properties) {
  982. return new DataMessage(properties);
  983. };
  984. /**
  985. * Encodes the specified DataMessage message. Does not implicitly {@link tutorial.Message.DataMessage.verify|verify} messages.
  986. * @function encode
  987. * @memberof tutorial.Message.DataMessage
  988. * @static
  989. * @param {tutorial.Message.IDataMessage} message DataMessage message or plain object to encode
  990. * @param {$protobuf.Writer} [writer] Writer to encode to
  991. * @returns {$protobuf.Writer} Writer
  992. */
  993. DataMessage.encode = function encode(message, writer) {
  994. if (!writer)
  995. writer = $Writer.create();
  996. if (message.code != null && message.hasOwnProperty("code"))
  997. writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code);
  998. if (message.result != null && message.hasOwnProperty("result"))
  999. writer.uint32(/* id 2, wireType 0 =*/16).int32(message.result);
  1000. if (message.data != null && message.hasOwnProperty("data"))
  1001. writer.uint32(/* id 3, wireType 2 =*/26).string(message.data);
  1002. if (message.msg != null && message.hasOwnProperty("msg"))
  1003. writer.uint32(/* id 4, wireType 2 =*/34).string(message.msg);
  1004. return writer;
  1005. };
  1006. /**
  1007. * Encodes the specified DataMessage message, length delimited. Does not implicitly {@link tutorial.Message.DataMessage.verify|verify} messages.
  1008. * @function encodeDelimited
  1009. * @memberof tutorial.Message.DataMessage
  1010. * @static
  1011. * @param {tutorial.Message.IDataMessage} message DataMessage message or plain object to encode
  1012. * @param {$protobuf.Writer} [writer] Writer to encode to
  1013. * @returns {$protobuf.Writer} Writer
  1014. */
  1015. DataMessage.encodeDelimited = function encodeDelimited(message, writer) {
  1016. return this.encode(message, writer).ldelim();
  1017. };
  1018. /**
  1019. * Decodes a DataMessage message from the specified reader or buffer.
  1020. * @function decode
  1021. * @memberof tutorial.Message.DataMessage
  1022. * @static
  1023. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  1024. * @param {number} [length] Message length if known beforehand
  1025. * @returns {tutorial.Message.DataMessage} DataMessage
  1026. * @throws {Error} If the payload is not a reader or valid buffer
  1027. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  1028. */
  1029. DataMessage.decode = function decode(reader, length) {
  1030. if (!(reader instanceof $Reader))
  1031. reader = $Reader.create(reader);
  1032. var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.DataMessage();
  1033. while (reader.pos < end) {
  1034. var tag = reader.uint32();
  1035. switch (tag >>> 3) {
  1036. case 1:
  1037. message.code = reader.int32();
  1038. break;
  1039. case 2:
  1040. message.result = reader.int32();
  1041. break;
  1042. case 3:
  1043. message.data = reader.string();
  1044. break;
  1045. case 4:
  1046. message.msg = reader.string();
  1047. break;
  1048. default:
  1049. reader.skipType(tag & 7);
  1050. break;
  1051. }
  1052. }
  1053. return message;
  1054. };
  1055. /**
  1056. * Decodes a DataMessage message from the specified reader or buffer, length delimited.
  1057. * @function decodeDelimited
  1058. * @memberof tutorial.Message.DataMessage
  1059. * @static
  1060. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  1061. * @returns {tutorial.Message.DataMessage} DataMessage
  1062. * @throws {Error} If the payload is not a reader or valid buffer
  1063. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  1064. */
  1065. DataMessage.decodeDelimited = function decodeDelimited(reader) {
  1066. if (!(reader instanceof $Reader))
  1067. reader = new $Reader(reader);
  1068. return this.decode(reader, reader.uint32());
  1069. };
  1070. /**
  1071. * Verifies a DataMessage message.
  1072. * @function verify
  1073. * @memberof tutorial.Message.DataMessage
  1074. * @static
  1075. * @param {Object.<string,*>} message Plain object to verify
  1076. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  1077. */
  1078. DataMessage.verify = function verify(message) {
  1079. if (typeof message !== "object" || message === null)
  1080. return "object expected";
  1081. if (message.code != null && message.hasOwnProperty("code"))
  1082. if (!$util.isInteger(message.code))
  1083. return "code: integer expected";
  1084. if (message.result != null && message.hasOwnProperty("result"))
  1085. if (!$util.isInteger(message.result))
  1086. return "result: integer expected";
  1087. if (message.data != null && message.hasOwnProperty("data"))
  1088. if (!$util.isString(message.data))
  1089. return "data: string expected";
  1090. if (message.msg != null && message.hasOwnProperty("msg"))
  1091. if (!$util.isString(message.msg))
  1092. return "msg: string expected";
  1093. return null;
  1094. };
  1095. /**
  1096. * Creates a DataMessage message from a plain object. Also converts values to their respective internal types.
  1097. * @function fromObject
  1098. * @memberof tutorial.Message.DataMessage
  1099. * @static
  1100. * @param {Object.<string,*>} object Plain object
  1101. * @returns {tutorial.Message.DataMessage} DataMessage
  1102. */
  1103. DataMessage.fromObject = function fromObject(object) {
  1104. if (object instanceof $root.tutorial.Message.DataMessage)
  1105. return object;
  1106. var message = new $root.tutorial.Message.DataMessage();
  1107. if (object.code != null)
  1108. message.code = object.code | 0;
  1109. if (object.result != null)
  1110. message.result = object.result | 0;
  1111. if (object.data != null)
  1112. message.data = String(object.data);
  1113. if (object.msg != null)
  1114. message.msg = String(object.msg);
  1115. return message;
  1116. };
  1117. /**
  1118. * Creates a plain object from a DataMessage message. Also converts values to other types if specified.
  1119. * @function toObject
  1120. * @memberof tutorial.Message.DataMessage
  1121. * @static
  1122. * @param {tutorial.Message.DataMessage} message DataMessage
  1123. * @param {$protobuf.IConversionOptions} [options] Conversion options
  1124. * @returns {Object.<string,*>} Plain object
  1125. */
  1126. DataMessage.toObject = function toObject(message, options) {
  1127. if (!options)
  1128. options = {};
  1129. var object = {};
  1130. if (options.defaults) {
  1131. object.code = 0;
  1132. object.result = 0;
  1133. object.data = "";
  1134. object.msg = "";
  1135. }
  1136. if (message.code != null && message.hasOwnProperty("code"))
  1137. object.code = message.code;
  1138. if (message.result != null && message.hasOwnProperty("result"))
  1139. object.result = message.result;
  1140. if (message.data != null && message.hasOwnProperty("data"))
  1141. object.data = message.data;
  1142. if (message.msg != null && message.hasOwnProperty("msg"))
  1143. object.msg = message.msg;
  1144. return object;
  1145. };
  1146. /**
  1147. * Converts this DataMessage to JSON.
  1148. * @function toJSON
  1149. * @memberof tutorial.Message.DataMessage
  1150. * @instance
  1151. * @returns {Object.<string,*>} JSON object
  1152. */
  1153. DataMessage.prototype.toJSON = function toJSON() {
  1154. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  1155. };
  1156. return DataMessage;
  1157. })();
  1158. Message.UserInfo = (function() {
  1159. /**
  1160. * Properties of a UserInfo.
  1161. * @memberof tutorial.Message
  1162. * @interface IUserInfo
  1163. * @property {number|Long|null} [uid] UserInfo uid
  1164. * @property {string|null} [nick] UserInfo nick
  1165. * @property {string|null} [head] UserInfo head
  1166. */
  1167. /**
  1168. * Constructs a new UserInfo.
  1169. * @memberof tutorial.Message
  1170. * @classdesc Represents a UserInfo.
  1171. * @implements IUserInfo
  1172. * @constructor
  1173. * @param {tutorial.Message.IUserInfo=} [properties] Properties to set
  1174. */
  1175. function UserInfo(properties) {
  1176. if (properties)
  1177. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  1178. if (properties[keys[i]] != null)
  1179. this[keys[i]] = properties[keys[i]];
  1180. }
  1181. /**
  1182. * UserInfo uid.
  1183. * @member {number|Long} uid
  1184. * @memberof tutorial.Message.UserInfo
  1185. * @instance
  1186. */
  1187. UserInfo.prototype.uid = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
  1188. /**
  1189. * UserInfo nick.
  1190. * @member {string} nick
  1191. * @memberof tutorial.Message.UserInfo
  1192. * @instance
  1193. */
  1194. UserInfo.prototype.nick = "";
  1195. /**
  1196. * UserInfo head.
  1197. * @member {string} head
  1198. * @memberof tutorial.Message.UserInfo
  1199. * @instance
  1200. */
  1201. UserInfo.prototype.head = "";
  1202. /**
  1203. * Creates a new UserInfo instance using the specified properties.
  1204. * @function create
  1205. * @memberof tutorial.Message.UserInfo
  1206. * @static
  1207. * @param {tutorial.Message.IUserInfo=} [properties] Properties to set
  1208. * @returns {tutorial.Message.UserInfo} UserInfo instance
  1209. */
  1210. UserInfo.create = function create(properties) {
  1211. return new UserInfo(properties);
  1212. };
  1213. /**
  1214. * Encodes the specified UserInfo message. Does not implicitly {@link tutorial.Message.UserInfo.verify|verify} messages.
  1215. * @function encode
  1216. * @memberof tutorial.Message.UserInfo
  1217. * @static
  1218. * @param {tutorial.Message.IUserInfo} message UserInfo message or plain object to encode
  1219. * @param {$protobuf.Writer} [writer] Writer to encode to
  1220. * @returns {$protobuf.Writer} Writer
  1221. */
  1222. UserInfo.encode = function encode(message, writer) {
  1223. if (!writer)
  1224. writer = $Writer.create();
  1225. if (message.uid != null && message.hasOwnProperty("uid"))
  1226. writer.uint32(/* id 1, wireType 0 =*/8).int64(message.uid);
  1227. if (message.nick != null && message.hasOwnProperty("nick"))
  1228. writer.uint32(/* id 2, wireType 2 =*/18).string(message.nick);
  1229. if (message.head != null && message.hasOwnProperty("head"))
  1230. writer.uint32(/* id 3, wireType 2 =*/26).string(message.head);
  1231. return writer;
  1232. };
  1233. /**
  1234. * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link tutorial.Message.UserInfo.verify|verify} messages.
  1235. * @function encodeDelimited
  1236. * @memberof tutorial.Message.UserInfo
  1237. * @static
  1238. * @param {tutorial.Message.IUserInfo} message UserInfo message or plain object to encode
  1239. * @param {$protobuf.Writer} [writer] Writer to encode to
  1240. * @returns {$protobuf.Writer} Writer
  1241. */
  1242. UserInfo.encodeDelimited = function encodeDelimited(message, writer) {
  1243. return this.encode(message, writer).ldelim();
  1244. };
  1245. /**
  1246. * Decodes a UserInfo message from the specified reader or buffer.
  1247. * @function decode
  1248. * @memberof tutorial.Message.UserInfo
  1249. * @static
  1250. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  1251. * @param {number} [length] Message length if known beforehand
  1252. * @returns {tutorial.Message.UserInfo} UserInfo
  1253. * @throws {Error} If the payload is not a reader or valid buffer
  1254. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  1255. */
  1256. UserInfo.decode = function decode(reader, length) {
  1257. if (!(reader instanceof $Reader))
  1258. reader = $Reader.create(reader);
  1259. var end = length === undefined ? reader.len : reader.pos + length, message = new $root.tutorial.Message.UserInfo();
  1260. while (reader.pos < end) {
  1261. var tag = reader.uint32();
  1262. switch (tag >>> 3) {
  1263. case 1:
  1264. message.uid = reader.int64();
  1265. break;
  1266. case 2:
  1267. message.nick = reader.string();
  1268. break;
  1269. case 3:
  1270. message.head = reader.string();
  1271. break;
  1272. default:
  1273. reader.skipType(tag & 7);
  1274. break;
  1275. }
  1276. }
  1277. return message;
  1278. };
  1279. /**
  1280. * Decodes a UserInfo message from the specified reader or buffer, length delimited.
  1281. * @function decodeDelimited
  1282. * @memberof tutorial.Message.UserInfo
  1283. * @static
  1284. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  1285. * @returns {tutorial.Message.UserInfo} UserInfo
  1286. * @throws {Error} If the payload is not a reader or valid buffer
  1287. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  1288. */
  1289. UserInfo.decodeDelimited = function decodeDelimited(reader) {
  1290. if (!(reader instanceof $Reader))
  1291. reader = new $Reader(reader);
  1292. return this.decode(reader, reader.uint32());
  1293. };
  1294. /**
  1295. * Verifies a UserInfo message.
  1296. * @function verify
  1297. * @memberof tutorial.Message.UserInfo
  1298. * @static
  1299. * @param {Object.<string,*>} message Plain object to verify
  1300. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  1301. */
  1302. UserInfo.verify = function verify(message) {
  1303. if (typeof message !== "object" || message === null)
  1304. return "object expected";
  1305. if (message.uid != null && message.hasOwnProperty("uid"))
  1306. if (!$util.isInteger(message.uid) && !(message.uid && $util.isInteger(message.uid.low) && $util.isInteger(message.uid.high)))
  1307. return "uid: integer|Long expected";
  1308. if (message.nick != null && message.hasOwnProperty("nick"))
  1309. if (!$util.isString(message.nick))
  1310. return "nick: string expected";
  1311. if (message.head != null && message.hasOwnProperty("head"))
  1312. if (!$util.isString(message.head))
  1313. return "head: string expected";
  1314. return null;
  1315. };
  1316. /**
  1317. * Creates a UserInfo message from a plain object. Also converts values to their respective internal types.
  1318. * @function fromObject
  1319. * @memberof tutorial.Message.UserInfo
  1320. * @static
  1321. * @param {Object.<string,*>} object Plain object
  1322. * @returns {tutorial.Message.UserInfo} UserInfo
  1323. */
  1324. UserInfo.fromObject = function fromObject(object) {
  1325. if (object instanceof $root.tutorial.Message.UserInfo)
  1326. return object;
  1327. var message = new $root.tutorial.Message.UserInfo();
  1328. if (object.uid != null)
  1329. if ($util.Long)
  1330. (message.uid = $util.Long.fromValue(object.uid)).unsigned = false;
  1331. else if (typeof object.uid === "string")
  1332. message.uid = parseInt(object.uid, 10);
  1333. else if (typeof object.uid === "number")
  1334. message.uid = object.uid;
  1335. else if (typeof object.uid === "object")
  1336. message.uid = new $util.LongBits(object.uid.low >>> 0, object.uid.high >>> 0).toNumber();
  1337. if (object.nick != null)
  1338. message.nick = String(object.nick);
  1339. if (object.head != null)
  1340. message.head = String(object.head);
  1341. return message;
  1342. };
  1343. /**
  1344. * Creates a plain object from a UserInfo message. Also converts values to other types if specified.
  1345. * @function toObject
  1346. * @memberof tutorial.Message.UserInfo
  1347. * @static
  1348. * @param {tutorial.Message.UserInfo} message UserInfo
  1349. * @param {$protobuf.IConversionOptions} [options] Conversion options
  1350. * @returns {Object.<string,*>} Plain object
  1351. */
  1352. UserInfo.toObject = function toObject(message, options) {
  1353. if (!options)
  1354. options = {};
  1355. var object = {};
  1356. if (options.defaults) {
  1357. if ($util.Long) {
  1358. var long = new $util.Long(0, 0, false);
  1359. object.uid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  1360. } else
  1361. object.uid = options.longs === String ? "0" : 0;
  1362. object.nick = "";
  1363. object.head = "";
  1364. }
  1365. if (message.uid != null && message.hasOwnProperty("uid"))
  1366. if (typeof message.uid === "number")
  1367. object.uid = options.longs === String ? String(message.uid) : message.uid;
  1368. else
  1369. 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;
  1370. if (message.nick != null && message.hasOwnProperty("nick"))
  1371. object.nick = message.nick;
  1372. if (message.head != null && message.hasOwnProperty("head"))
  1373. object.head = message.head;
  1374. return object;
  1375. };
  1376. /**
  1377. * Converts this UserInfo to JSON.
  1378. * @function toJSON
  1379. * @memberof tutorial.Message.UserInfo
  1380. * @instance
  1381. * @returns {Object.<string,*>} JSON object
  1382. */
  1383. UserInfo.prototype.toJSON = function toJSON() {
  1384. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  1385. };
  1386. return UserInfo;
  1387. })();
  1388. return Message;
  1389. })();
  1390. return tutorial;
  1391. })();
  1392. return $root;
  1393. });