bilibili.proto.js

完全由pbjs生成的bilibili分段弹幕处理库

目前为 2020-08-03 提交的版本,查看 最新版本

此脚本不应直接安装,它是供其他脚本使用的外部库。如果你需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/408096/833352/bilibiliprotojs.js

  1. // ==UserScript==
  2. // @name bilibili.proto.js
  3. // @version 0.1
  4. // @description 完全由pbjs生成的bilibili分段弹幕处理库
  5. // @author You
  6. // @match https://bilibili.com/video/*
  7. // @match https://bilibili.com/bangumi/*
  8. // @run-at document-start
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function ($protobuf) {
  13. // Common aliases
  14. var $Reader = $protobuf.Reader,
  15. $Writer = $protobuf.Writer,
  16. $util = $protobuf.util;
  17.  
  18. // Exported root namespace
  19. var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
  20.  
  21. $root.DanmakuElem = (function () {
  22.  
  23. /**
  24. * Properties of a DanmakuElem.
  25. * @exports IDanmakuElem
  26. * @interface IDanmakuElem
  27. * @property {number|Long|null} [id] DanmakuElem id
  28. * @property {number|null} [progress] DanmakuElem progress
  29. * @property {number|null} [mode] DanmakuElem mode
  30. * @property {number|null} [fontsize] DanmakuElem fontsize
  31. * @property {number|null} [color] DanmakuElem color
  32. * @property {string|null} [midHash] DanmakuElem midHash
  33. * @property {string|null} [content] DanmakuElem content
  34. * @property {number|Long|null} [ctime] DanmakuElem ctime
  35. * @property {number|null} [weight] DanmakuElem weight
  36. * @property {string|null} [action] DanmakuElem action
  37. * @property {number|null} [pool] DanmakuElem pool
  38. * @property {string|null} [idStr] DanmakuElem idStr
  39. */
  40.  
  41. /**
  42. * Constructs a new DanmakuElem.
  43. * @exports DanmakuElem
  44. * @classdesc Represents a DanmakuElem.
  45. * @implements IDanmakuElem
  46. * @constructor
  47. * @param {IDanmakuElem=} [properties] Properties to set
  48. */
  49. function DanmakuElem(properties) {
  50. if (properties)
  51. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  52. if (properties[keys[i]] != null)
  53. this[keys[i]] = properties[keys[i]];
  54. }
  55.  
  56. /**
  57. * DanmakuElem id.
  58. * @member {number|Long} id
  59. * @memberof DanmakuElem
  60. * @instance
  61. */
  62. DanmakuElem.prototype.id = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
  63.  
  64. /**
  65. * DanmakuElem progress.
  66. * @member {number} progress
  67. * @memberof DanmakuElem
  68. * @instance
  69. */
  70. DanmakuElem.prototype.progress = 0;
  71.  
  72. /**
  73. * DanmakuElem mode.
  74. * @member {number} mode
  75. * @memberof DanmakuElem
  76. * @instance
  77. */
  78. DanmakuElem.prototype.mode = 0;
  79.  
  80. /**
  81. * DanmakuElem fontsize.
  82. * @member {number} fontsize
  83. * @memberof DanmakuElem
  84. * @instance
  85. */
  86. DanmakuElem.prototype.fontsize = 0;
  87.  
  88. /**
  89. * DanmakuElem color.
  90. * @member {number} color
  91. * @memberof DanmakuElem
  92. * @instance
  93. */
  94. DanmakuElem.prototype.color = 0;
  95.  
  96. /**
  97. * DanmakuElem midHash.
  98. * @member {string} midHash
  99. * @memberof DanmakuElem
  100. * @instance
  101. */
  102. DanmakuElem.prototype.midHash = "";
  103.  
  104. /**
  105. * DanmakuElem content.
  106. * @member {string} content
  107. * @memberof DanmakuElem
  108. * @instance
  109. */
  110. DanmakuElem.prototype.content = "";
  111.  
  112. /**
  113. * DanmakuElem ctime.
  114. * @member {number|Long} ctime
  115. * @memberof DanmakuElem
  116. * @instance
  117. */
  118. DanmakuElem.prototype.ctime = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
  119.  
  120. /**
  121. * DanmakuElem weight.
  122. * @member {number} weight
  123. * @memberof DanmakuElem
  124. * @instance
  125. */
  126. DanmakuElem.prototype.weight = 0;
  127.  
  128. /**
  129. * DanmakuElem action.
  130. * @member {string} action
  131. * @memberof DanmakuElem
  132. * @instance
  133. */
  134. DanmakuElem.prototype.action = "";
  135.  
  136. /**
  137. * DanmakuElem pool.
  138. * @member {number} pool
  139. * @memberof DanmakuElem
  140. * @instance
  141. */
  142. DanmakuElem.prototype.pool = 0;
  143.  
  144. /**
  145. * DanmakuElem idStr.
  146. * @member {string} idStr
  147. * @memberof DanmakuElem
  148. * @instance
  149. */
  150. DanmakuElem.prototype.idStr = "";
  151.  
  152. /**
  153. * Creates a new DanmakuElem instance using the specified properties.
  154. * @function create
  155. * @memberof DanmakuElem
  156. * @static
  157. * @param {IDanmakuElem=} [properties] Properties to set
  158. * @returns {DanmakuElem} DanmakuElem instance
  159. */
  160. DanmakuElem.create = function create(properties) {
  161. return new DanmakuElem(properties);
  162. };
  163.  
  164. /**
  165. * Encodes the specified DanmakuElem message. Does not implicitly {@link DanmakuElem.verify|verify} messages.
  166. * @function encode
  167. * @memberof DanmakuElem
  168. * @static
  169. * @param {IDanmakuElem} message DanmakuElem message or plain object to encode
  170. * @param {$protobuf.Writer} [writer] Writer to encode to
  171. * @returns {$protobuf.Writer} Writer
  172. */
  173. DanmakuElem.encode = function encode(message, writer) {
  174. if (!writer)
  175. writer = $Writer.create();
  176. if (message.id != null && Object.hasOwnProperty.call(message, "id"))
  177. writer.uint32( /* id 1, wireType 0 =*/ 8).int64(message.id);
  178. if (message.progress != null && Object.hasOwnProperty.call(message, "progress"))
  179. writer.uint32( /* id 2, wireType 0 =*/ 16).int32(message.progress);
  180. if (message.mode != null && Object.hasOwnProperty.call(message, "mode"))
  181. writer.uint32( /* id 3, wireType 0 =*/ 24).int32(message.mode);
  182. if (message.fontsize != null && Object.hasOwnProperty.call(message, "fontsize"))
  183. writer.uint32( /* id 4, wireType 0 =*/ 32).int32(message.fontsize);
  184. if (message.color != null && Object.hasOwnProperty.call(message, "color"))
  185. writer.uint32( /* id 5, wireType 0 =*/ 40).uint32(message.color);
  186. if (message.midHash != null && Object.hasOwnProperty.call(message, "midHash"))
  187. writer.uint32( /* id 6, wireType 2 =*/ 50).string(message.midHash);
  188. if (message.content != null && Object.hasOwnProperty.call(message, "content"))
  189. writer.uint32( /* id 7, wireType 2 =*/ 58).string(message.content);
  190. if (message.ctime != null && Object.hasOwnProperty.call(message, "ctime"))
  191. writer.uint32( /* id 8, wireType 0 =*/ 64).int64(message.ctime);
  192. if (message.weight != null && Object.hasOwnProperty.call(message, "weight"))
  193. writer.uint32( /* id 9, wireType 0 =*/ 72).int32(message.weight);
  194. if (message.action != null && Object.hasOwnProperty.call(message, "action"))
  195. writer.uint32( /* id 10, wireType 2 =*/ 82).string(message.action);
  196. if (message.pool != null && Object.hasOwnProperty.call(message, "pool"))
  197. writer.uint32( /* id 11, wireType 0 =*/ 88).int32(message.pool);
  198. if (message.idStr != null && Object.hasOwnProperty.call(message, "idStr"))
  199. writer.uint32( /* id 12, wireType 2 =*/ 98).string(message.idStr);
  200. return writer;
  201. };
  202.  
  203. /**
  204. * Encodes the specified DanmakuElem message, length delimited. Does not implicitly {@link DanmakuElem.verify|verify} messages.
  205. * @function encodeDelimited
  206. * @memberof DanmakuElem
  207. * @static
  208. * @param {IDanmakuElem} message DanmakuElem message or plain object to encode
  209. * @param {$protobuf.Writer} [writer] Writer to encode to
  210. * @returns {$protobuf.Writer} Writer
  211. */
  212. DanmakuElem.encodeDelimited = function encodeDelimited(message, writer) {
  213. return this.encode(message, writer).ldelim();
  214. };
  215.  
  216. /**
  217. * Decodes a DanmakuElem message from the specified reader or buffer.
  218. * @function decode
  219. * @memberof DanmakuElem
  220. * @static
  221. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  222. * @param {number} [length] Message length if known beforehand
  223. * @returns {DanmakuElem} DanmakuElem
  224. * @throws {Error} If the payload is not a reader or valid buffer
  225. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  226. */
  227. DanmakuElem.decode = function decode(reader, length) {
  228. if (!(reader instanceof $Reader))
  229. reader = $Reader.create(reader);
  230. var end = length === undefined ? reader.len : reader.pos + length,
  231. message = new $root.DanmakuElem();
  232. while (reader.pos < end) {
  233. var tag = reader.uint32();
  234. switch (tag >>> 3) {
  235. case 1:
  236. message.id = reader.int64();
  237. break;
  238. case 2:
  239. message.progress = reader.int32();
  240. break;
  241. case 3:
  242. message.mode = reader.int32();
  243. break;
  244. case 4:
  245. message.fontsize = reader.int32();
  246. break;
  247. case 5:
  248. message.color = reader.uint32();
  249. break;
  250. case 6:
  251. message.midHash = reader.string();
  252. break;
  253. case 7:
  254. message.content = reader.string();
  255. break;
  256. case 8:
  257. message.ctime = reader.int64();
  258. break;
  259. case 9:
  260. message.weight = reader.int32();
  261. break;
  262. case 10:
  263. message.action = reader.string();
  264. break;
  265. case 11:
  266. message.pool = reader.int32();
  267. break;
  268. case 12:
  269. message.idStr = reader.string();
  270. break;
  271. default:
  272. reader.skipType(tag & 7);
  273. break;
  274. }
  275. }
  276. return message;
  277. };
  278.  
  279. /**
  280. * Decodes a DanmakuElem message from the specified reader or buffer, length delimited.
  281. * @function decodeDelimited
  282. * @memberof DanmakuElem
  283. * @static
  284. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  285. * @returns {DanmakuElem} DanmakuElem
  286. * @throws {Error} If the payload is not a reader or valid buffer
  287. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  288. */
  289. DanmakuElem.decodeDelimited = function decodeDelimited(reader) {
  290. if (!(reader instanceof $Reader))
  291. reader = new $Reader(reader);
  292. return this.decode(reader, reader.uint32());
  293. };
  294.  
  295. /**
  296. * Verifies a DanmakuElem message.
  297. * @function verify
  298. * @memberof DanmakuElem
  299. * @static
  300. * @param {Object.<string,*>} message Plain object to verify
  301. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  302. */
  303. DanmakuElem.verify = function verify(message) {
  304. if (typeof message !== "object" || message === null)
  305. return "object expected";
  306. if (message.id != null && message.hasOwnProperty("id"))
  307. if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high)))
  308. return "id: integer|Long expected";
  309. if (message.progress != null && message.hasOwnProperty("progress"))
  310. if (!$util.isInteger(message.progress))
  311. return "progress: integer expected";
  312. if (message.mode != null && message.hasOwnProperty("mode"))
  313. if (!$util.isInteger(message.mode))
  314. return "mode: integer expected";
  315. if (message.fontsize != null && message.hasOwnProperty("fontsize"))
  316. if (!$util.isInteger(message.fontsize))
  317. return "fontsize: integer expected";
  318. if (message.color != null && message.hasOwnProperty("color"))
  319. if (!$util.isInteger(message.color))
  320. return "color: integer expected";
  321. if (message.midHash != null && message.hasOwnProperty("midHash"))
  322. if (!$util.isString(message.midHash))
  323. return "midHash: string expected";
  324. if (message.content != null && message.hasOwnProperty("content"))
  325. if (!$util.isString(message.content))
  326. return "content: string expected";
  327. if (message.ctime != null && message.hasOwnProperty("ctime"))
  328. if (!$util.isInteger(message.ctime) && !(message.ctime && $util.isInteger(message.ctime.low) && $util.isInteger(message.ctime.high)))
  329. return "ctime: integer|Long expected";
  330. if (message.weight != null && message.hasOwnProperty("weight"))
  331. if (!$util.isInteger(message.weight))
  332. return "weight: integer expected";
  333. if (message.action != null && message.hasOwnProperty("action"))
  334. if (!$util.isString(message.action))
  335. return "action: string expected";
  336. if (message.pool != null && message.hasOwnProperty("pool"))
  337. if (!$util.isInteger(message.pool))
  338. return "pool: integer expected";
  339. if (message.idStr != null && message.hasOwnProperty("idStr"))
  340. if (!$util.isString(message.idStr))
  341. return "idStr: string expected";
  342. return null;
  343. };
  344.  
  345. /**
  346. * Creates a DanmakuElem message from a plain object. Also converts values to their respective internal types.
  347. * @function fromObject
  348. * @memberof DanmakuElem
  349. * @static
  350. * @param {Object.<string,*>} object Plain object
  351. * @returns {DanmakuElem} DanmakuElem
  352. */
  353. DanmakuElem.fromObject = function fromObject(object) {
  354. if (object instanceof $root.DanmakuElem)
  355. return object;
  356. var message = new $root.DanmakuElem();
  357. if (object.id != null)
  358. if ($util.Long)
  359. (message.id = $util.Long.fromValue(object.id)).unsigned = false;
  360. else if (typeof object.id === "string")
  361. message.id = parseInt(object.id, 10);
  362. else if (typeof object.id === "number")
  363. message.id = object.id;
  364. else if (typeof object.id === "object")
  365. message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber();
  366. if (object.progress != null)
  367. message.progress = object.progress | 0;
  368. if (object.mode != null)
  369. message.mode = object.mode | 0;
  370. if (object.fontsize != null)
  371. message.fontsize = object.fontsize | 0;
  372. if (object.color != null)
  373. message.color = object.color >>> 0;
  374. if (object.midHash != null)
  375. message.midHash = String(object.midHash);
  376. if (object.content != null)
  377. message.content = String(object.content);
  378. if (object.ctime != null)
  379. if ($util.Long)
  380. (message.ctime = $util.Long.fromValue(object.ctime)).unsigned = false;
  381. else if (typeof object.ctime === "string")
  382. message.ctime = parseInt(object.ctime, 10);
  383. else if (typeof object.ctime === "number")
  384. message.ctime = object.ctime;
  385. else if (typeof object.ctime === "object")
  386. message.ctime = new $util.LongBits(object.ctime.low >>> 0, object.ctime.high >>> 0).toNumber();
  387. if (object.weight != null)
  388. message.weight = object.weight | 0;
  389. if (object.action != null)
  390. message.action = String(object.action);
  391. if (object.pool != null)
  392. message.pool = object.pool | 0;
  393. if (object.idStr != null)
  394. message.idStr = String(object.idStr);
  395. return message;
  396. };
  397.  
  398. /**
  399. * Creates a plain object from a DanmakuElem message. Also converts values to other types if specified.
  400. * @function toObject
  401. * @memberof DanmakuElem
  402. * @static
  403. * @param {DanmakuElem} message DanmakuElem
  404. * @param {$protobuf.IConversionOptions} [options] Conversion options
  405. * @returns {Object.<string,*>} Plain object
  406. */
  407. DanmakuElem.toObject = function toObject(message, options) {
  408. if (!options)
  409. options = {};
  410. var object = {};
  411. if (options.defaults) {
  412. if ($util.Long) {
  413. var long = new $util.Long(0, 0, false);
  414. object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  415. } else
  416. object.id = options.longs === String ? "0" : 0;
  417. object.progress = 0;
  418. object.mode = 0;
  419. object.fontsize = 0;
  420. object.color = 0;
  421. object.midHash = "";
  422. object.content = "";
  423. if ($util.Long) {
  424. var long = new $util.Long(0, 0, false);
  425. object.ctime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
  426. } else
  427. object.ctime = options.longs === String ? "0" : 0;
  428. object.weight = 0;
  429. object.action = "";
  430. object.pool = 0;
  431. object.idStr = "";
  432. }
  433. if (message.id != null && message.hasOwnProperty("id"))
  434. if (typeof message.id === "number")
  435. object.id = options.longs === String ? String(message.id) : message.id;
  436. else
  437. 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;
  438. if (message.progress != null && message.hasOwnProperty("progress"))
  439. object.progress = message.progress;
  440. if (message.mode != null && message.hasOwnProperty("mode"))
  441. object.mode = message.mode;
  442. if (message.fontsize != null && message.hasOwnProperty("fontsize"))
  443. object.fontsize = message.fontsize;
  444. if (message.color != null && message.hasOwnProperty("color"))
  445. object.color = message.color;
  446. if (message.midHash != null && message.hasOwnProperty("midHash"))
  447. object.midHash = message.midHash;
  448. if (message.content != null && message.hasOwnProperty("content"))
  449. object.content = message.content;
  450. if (message.ctime != null && message.hasOwnProperty("ctime"))
  451. if (typeof message.ctime === "number")
  452. object.ctime = options.longs === String ? String(message.ctime) : message.ctime;
  453. else
  454. object.ctime = options.longs === String ? $util.Long.prototype.toString.call(message.ctime) : options.longs === Number ? new $util.LongBits(message.ctime.low >>> 0, message.ctime.high >>> 0).toNumber() : message.ctime;
  455. if (message.weight != null && message.hasOwnProperty("weight"))
  456. object.weight = message.weight;
  457. if (message.action != null && message.hasOwnProperty("action"))
  458. object.action = message.action;
  459. if (message.pool != null && message.hasOwnProperty("pool"))
  460. object.pool = message.pool;
  461. if (message.idStr != null && message.hasOwnProperty("idStr"))
  462. object.idStr = message.idStr;
  463. return object;
  464. };
  465.  
  466. /**
  467. * Converts this DanmakuElem to JSON.
  468. * @function toJSON
  469. * @memberof DanmakuElem
  470. * @instance
  471. * @returns {Object.<string,*>} JSON object
  472. */
  473. DanmakuElem.prototype.toJSON = function toJSON() {
  474. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  475. };
  476.  
  477. return DanmakuElem;
  478. })();
  479.  
  480. $root.DmSegMobileReply = (function () {
  481.  
  482. /**
  483. * Properties of a DmSegMobileReply.
  484. * @exports IDmSegMobileReply
  485. * @interface IDmSegMobileReply
  486. * @property {Array.<IDanmakuElem>|null} [elems] DmSegMobileReply elems
  487. */
  488.  
  489. /**
  490. * Constructs a new DmSegMobileReply.
  491. * @exports DmSegMobileReply
  492. * @classdesc Represents a DmSegMobileReply.
  493. * @implements IDmSegMobileReply
  494. * @constructor
  495. * @param {IDmSegMobileReply=} [properties] Properties to set
  496. */
  497. function DmSegMobileReply(properties) {
  498. this.elems = [];
  499. if (properties)
  500. for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
  501. if (properties[keys[i]] != null)
  502. this[keys[i]] = properties[keys[i]];
  503. }
  504.  
  505. /**
  506. * DmSegMobileReply elems.
  507. * @member {Array.<IDanmakuElem>} elems
  508. * @memberof DmSegMobileReply
  509. * @instance
  510. */
  511. DmSegMobileReply.prototype.elems = $util.emptyArray;
  512.  
  513. /**
  514. * Creates a new DmSegMobileReply instance using the specified properties.
  515. * @function create
  516. * @memberof DmSegMobileReply
  517. * @static
  518. * @param {IDmSegMobileReply=} [properties] Properties to set
  519. * @returns {DmSegMobileReply} DmSegMobileReply instance
  520. */
  521. DmSegMobileReply.create = function create(properties) {
  522. return new DmSegMobileReply(properties);
  523. };
  524.  
  525. /**
  526. * Encodes the specified DmSegMobileReply message. Does not implicitly {@link DmSegMobileReply.verify|verify} messages.
  527. * @function encode
  528. * @memberof DmSegMobileReply
  529. * @static
  530. * @param {IDmSegMobileReply} message DmSegMobileReply message or plain object to encode
  531. * @param {$protobuf.Writer} [writer] Writer to encode to
  532. * @returns {$protobuf.Writer} Writer
  533. */
  534. DmSegMobileReply.encode = function encode(message, writer) {
  535. if (!writer)
  536. writer = $Writer.create();
  537. if (message.elems != null && message.elems.length)
  538. for (var i = 0; i < message.elems.length; ++i)
  539. $root.DanmakuElem.encode(message.elems[i], writer.uint32( /* id 1, wireType 2 =*/ 10).fork()).ldelim();
  540. return writer;
  541. };
  542.  
  543. /**
  544. * Encodes the specified DmSegMobileReply message, length delimited. Does not implicitly {@link DmSegMobileReply.verify|verify} messages.
  545. * @function encodeDelimited
  546. * @memberof DmSegMobileReply
  547. * @static
  548. * @param {IDmSegMobileReply} message DmSegMobileReply message or plain object to encode
  549. * @param {$protobuf.Writer} [writer] Writer to encode to
  550. * @returns {$protobuf.Writer} Writer
  551. */
  552. DmSegMobileReply.encodeDelimited = function encodeDelimited(message, writer) {
  553. return this.encode(message, writer).ldelim();
  554. };
  555.  
  556. /**
  557. * Decodes a DmSegMobileReply message from the specified reader or buffer.
  558. * @function decode
  559. * @memberof DmSegMobileReply
  560. * @static
  561. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  562. * @param {number} [length] Message length if known beforehand
  563. * @returns {DmSegMobileReply} DmSegMobileReply
  564. * @throws {Error} If the payload is not a reader or valid buffer
  565. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  566. */
  567. DmSegMobileReply.decode = function decode(reader, length) {
  568. if (!(reader instanceof $Reader))
  569. reader = $Reader.create(reader);
  570. var end = length === undefined ? reader.len : reader.pos + length,
  571. message = new $root.DmSegMobileReply();
  572. while (reader.pos < end) {
  573. var tag = reader.uint32();
  574. switch (tag >>> 3) {
  575. case 1:
  576. if (!(message.elems && message.elems.length))
  577. message.elems = [];
  578. message.elems.push($root.DanmakuElem.decode(reader, reader.uint32()));
  579. break;
  580. default:
  581. reader.skipType(tag & 7);
  582. break;
  583. }
  584. }
  585. return message;
  586. };
  587.  
  588. /**
  589. * Decodes a DmSegMobileReply message from the specified reader or buffer, length delimited.
  590. * @function decodeDelimited
  591. * @memberof DmSegMobileReply
  592. * @static
  593. * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
  594. * @returns {DmSegMobileReply} DmSegMobileReply
  595. * @throws {Error} If the payload is not a reader or valid buffer
  596. * @throws {$protobuf.util.ProtocolError} If required fields are missing
  597. */
  598. DmSegMobileReply.decodeDelimited = function decodeDelimited(reader) {
  599. if (!(reader instanceof $Reader))
  600. reader = new $Reader(reader);
  601. return this.decode(reader, reader.uint32());
  602. };
  603.  
  604. /**
  605. * Verifies a DmSegMobileReply message.
  606. * @function verify
  607. * @memberof DmSegMobileReply
  608. * @static
  609. * @param {Object.<string,*>} message Plain object to verify
  610. * @returns {string|null} `null` if valid, otherwise the reason why it is not
  611. */
  612. DmSegMobileReply.verify = function verify(message) {
  613. if (typeof message !== "object" || message === null)
  614. return "object expected";
  615. if (message.elems != null && message.hasOwnProperty("elems")) {
  616. if (!Array.isArray(message.elems))
  617. return "elems: array expected";
  618. for (var i = 0; i < message.elems.length; ++i) {
  619. var error = $root.DanmakuElem.verify(message.elems[i]);
  620. if (error)
  621. return "elems." + error;
  622. }
  623. }
  624. return null;
  625. };
  626.  
  627. /**
  628. * Creates a DmSegMobileReply message from a plain object. Also converts values to their respective internal types.
  629. * @function fromObject
  630. * @memberof DmSegMobileReply
  631. * @static
  632. * @param {Object.<string,*>} object Plain object
  633. * @returns {DmSegMobileReply} DmSegMobileReply
  634. */
  635. DmSegMobileReply.fromObject = function fromObject(object) {
  636. if (object instanceof $root.DmSegMobileReply)
  637. return object;
  638. var message = new $root.DmSegMobileReply();
  639. if (object.elems) {
  640. if (!Array.isArray(object.elems))
  641. throw TypeError(".DmSegMobileReply.elems: array expected");
  642. message.elems = [];
  643. for (var i = 0; i < object.elems.length; ++i) {
  644. if (typeof object.elems[i] !== "object")
  645. throw TypeError(".DmSegMobileReply.elems: object expected");
  646. message.elems[i] = $root.DanmakuElem.fromObject(object.elems[i]);
  647. }
  648. }
  649. return message;
  650. };
  651.  
  652. /**
  653. * Creates a plain object from a DmSegMobileReply message. Also converts values to other types if specified.
  654. * @function toObject
  655. * @memberof DmSegMobileReply
  656. * @static
  657. * @param {DmSegMobileReply} message DmSegMobileReply
  658. * @param {$protobuf.IConversionOptions} [options] Conversion options
  659. * @returns {Object.<string,*>} Plain object
  660. */
  661. DmSegMobileReply.toObject = function toObject(message, options) {
  662. if (!options)
  663. options = {};
  664. var object = {};
  665. if (options.arrays || options.defaults)
  666. object.elems = [];
  667. if (message.elems && message.elems.length) {
  668. object.elems = [];
  669. for (var j = 0; j < message.elems.length; ++j)
  670. object.elems[j] = $root.DanmakuElem.toObject(message.elems[j], options);
  671. }
  672. return object;
  673. };
  674.  
  675. /**
  676. * Converts this DmSegMobileReply to JSON.
  677. * @function toJSON
  678. * @memberof DmSegMobileReply
  679. * @instance
  680. * @returns {Object.<string,*>} JSON object
  681. */
  682. DmSegMobileReply.prototype.toJSON = function toJSON() {
  683. return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
  684. };
  685.  
  686. return DmSegMobileReply;
  687. })();
  688. })(protobuf);