416 lines
15 KiB
JavaScript
416 lines
15 KiB
JavaScript
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
|
|
"use strict";
|
|
|
|
var $protobuf = require("protobufjs/minimal");
|
|
|
|
// Common aliases
|
|
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
|
|
|
|
// Exported root namespace
|
|
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
|
|
|
|
$root.ClientMsg = (function() {
|
|
|
|
/**
|
|
* Properties of a ClientMsg.
|
|
* @exports IClientMsg
|
|
* @interface IClientMsg
|
|
* @property {ServiceTypeId|null} [serviceTid] ClientMsg serviceTid
|
|
* @property {string|null} [serviceName] ClientMsg serviceName
|
|
* @property {Long|null} [userId] ClientMsg userId
|
|
* @property {number|null} [msgId] ClientMsg msgId
|
|
* @property {Uint8Array|null} [data] ClientMsg data
|
|
*/
|
|
|
|
/**
|
|
* Constructs a new ClientMsg.
|
|
* @exports ClientMsg
|
|
* @classdesc Represents a ClientMsg.
|
|
* @implements IClientMsg
|
|
* @constructor
|
|
* @param {IClientMsg=} [properties] Properties to set
|
|
*/
|
|
function ClientMsg(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]];
|
|
}
|
|
|
|
/**
|
|
* ClientMsg serviceTid.
|
|
* @member {ServiceTypeId} serviceTid
|
|
* @memberof ClientMsg
|
|
* @instance
|
|
*/
|
|
ClientMsg.prototype.serviceTid = 0;
|
|
|
|
/**
|
|
* ClientMsg serviceName.
|
|
* @member {string} serviceName
|
|
* @memberof ClientMsg
|
|
* @instance
|
|
*/
|
|
ClientMsg.prototype.serviceName = "";
|
|
|
|
/**
|
|
* ClientMsg userId.
|
|
* @member {Long} userId
|
|
* @memberof ClientMsg
|
|
* @instance
|
|
*/
|
|
ClientMsg.prototype.userId = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
|
|
|
|
/**
|
|
* ClientMsg msgId.
|
|
* @member {number} msgId
|
|
* @memberof ClientMsg
|
|
* @instance
|
|
*/
|
|
ClientMsg.prototype.msgId = 0;
|
|
|
|
/**
|
|
* ClientMsg data.
|
|
* @member {Uint8Array} data
|
|
* @memberof ClientMsg
|
|
* @instance
|
|
*/
|
|
ClientMsg.prototype.data = $util.newBuffer([]);
|
|
|
|
/**
|
|
* Creates a new ClientMsg instance using the specified properties.
|
|
* @function create
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {IClientMsg=} [properties] Properties to set
|
|
* @returns {ClientMsg} ClientMsg instance
|
|
*/
|
|
ClientMsg.create = function create(properties) {
|
|
return new ClientMsg(properties);
|
|
};
|
|
|
|
/**
|
|
* Encodes the specified ClientMsg message. Does not implicitly {@link ClientMsg.verify|verify} messages.
|
|
* @function encode
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {IClientMsg} message ClientMsg message or plain object to encode
|
|
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
* @returns {$protobuf.Writer} Writer
|
|
*/
|
|
ClientMsg.encode = function encode(message, writer) {
|
|
if (!writer)
|
|
writer = $Writer.create();
|
|
if (message.serviceTid != null && Object.hasOwnProperty.call(message, "serviceTid"))
|
|
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.serviceTid);
|
|
if (message.serviceName != null && Object.hasOwnProperty.call(message, "serviceName"))
|
|
writer.uint32(/* id 2, wireType 2 =*/18).string(message.serviceName);
|
|
if (message.userId != null && Object.hasOwnProperty.call(message, "userId"))
|
|
writer.uint32(/* id 3, wireType 0 =*/24).int64(message.userId);
|
|
if (message.msgId != null && Object.hasOwnProperty.call(message, "msgId"))
|
|
writer.uint32(/* id 4, wireType 0 =*/32).int32(message.msgId);
|
|
if (message.data != null && Object.hasOwnProperty.call(message, "data"))
|
|
writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.data);
|
|
return writer;
|
|
};
|
|
|
|
/**
|
|
* Encodes the specified ClientMsg message, length delimited. Does not implicitly {@link ClientMsg.verify|verify} messages.
|
|
* @function encodeDelimited
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {IClientMsg} message ClientMsg message or plain object to encode
|
|
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
* @returns {$protobuf.Writer} Writer
|
|
*/
|
|
ClientMsg.encodeDelimited = function encodeDelimited(message, writer) {
|
|
return this.encode(message, writer).ldelim();
|
|
};
|
|
|
|
/**
|
|
* Decodes a ClientMsg message from the specified reader or buffer.
|
|
* @function decode
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
* @param {number} [length] Message length if known beforehand
|
|
* @returns {ClientMsg} ClientMsg
|
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
*/
|
|
ClientMsg.decode = function decode(reader, length, error) {
|
|
if (!(reader instanceof $Reader))
|
|
reader = $Reader.create(reader);
|
|
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ClientMsg();
|
|
while (reader.pos < end) {
|
|
var tag = reader.uint32();
|
|
if (tag === error)
|
|
break;
|
|
switch (tag >>> 3) {
|
|
case 1: {
|
|
message.serviceTid = reader.int32();
|
|
break;
|
|
}
|
|
case 2: {
|
|
message.serviceName = reader.string();
|
|
break;
|
|
}
|
|
case 3: {
|
|
message.userId = reader.int64();
|
|
break;
|
|
}
|
|
case 4: {
|
|
message.msgId = reader.int32();
|
|
break;
|
|
}
|
|
case 5: {
|
|
message.data = reader.bytes();
|
|
break;
|
|
}
|
|
default:
|
|
reader.skipType(tag & 7);
|
|
break;
|
|
}
|
|
}
|
|
return message;
|
|
};
|
|
|
|
/**
|
|
* Decodes a ClientMsg message from the specified reader or buffer, length delimited.
|
|
* @function decodeDelimited
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
* @returns {ClientMsg} ClientMsg
|
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
*/
|
|
ClientMsg.decodeDelimited = function decodeDelimited(reader) {
|
|
if (!(reader instanceof $Reader))
|
|
reader = new $Reader(reader);
|
|
return this.decode(reader, reader.uint32());
|
|
};
|
|
|
|
/**
|
|
* Verifies a ClientMsg message.
|
|
* @function verify
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {Object.<string,*>} message Plain object to verify
|
|
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
|
*/
|
|
ClientMsg.verify = function verify(message) {
|
|
if (typeof message !== "object" || message === null)
|
|
return "object expected";
|
|
if (message.serviceTid != null && message.hasOwnProperty("serviceTid"))
|
|
switch (message.serviceTid) {
|
|
default:
|
|
return "serviceTid: enum value expected";
|
|
case 0:
|
|
case 10000:
|
|
case 10005:
|
|
case 10010:
|
|
case 10015:
|
|
case 10020:
|
|
case 20000:
|
|
case 20005:
|
|
case 30000:
|
|
break;
|
|
}
|
|
if (message.serviceName != null && message.hasOwnProperty("serviceName"))
|
|
if (!$util.isString(message.serviceName))
|
|
return "serviceName: string expected";
|
|
if (message.userId != null && message.hasOwnProperty("userId"))
|
|
if (!$util.isInteger(message.userId) && !(message.userId && $util.isInteger(message.userId.low) && $util.isInteger(message.userId.high)))
|
|
return "userId: integer|Long expected";
|
|
if (message.msgId != null && message.hasOwnProperty("msgId"))
|
|
if (!$util.isInteger(message.msgId))
|
|
return "msgId: integer expected";
|
|
if (message.data != null && message.hasOwnProperty("data"))
|
|
if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data)))
|
|
return "data: buffer expected";
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Creates a ClientMsg message from a plain object. Also converts values to their respective internal types.
|
|
* @function fromObject
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {Object.<string,*>} object Plain object
|
|
* @returns {ClientMsg} ClientMsg
|
|
*/
|
|
ClientMsg.fromObject = function fromObject(object) {
|
|
if (object instanceof $root.ClientMsg)
|
|
return object;
|
|
var message = new $root.ClientMsg();
|
|
switch (object.serviceTid) {
|
|
default:
|
|
if (typeof object.serviceTid === "number") {
|
|
message.serviceTid = object.serviceTid;
|
|
break;
|
|
}
|
|
break;
|
|
case "STI_Unknown":
|
|
case 0:
|
|
message.serviceTid = 0;
|
|
break;
|
|
case "STI_Login":
|
|
case 10000:
|
|
message.serviceTid = 10000;
|
|
break;
|
|
case "STI_Chat":
|
|
case 10005:
|
|
message.serviceTid = 10005;
|
|
break;
|
|
case "STI_Match":
|
|
case 10010:
|
|
message.serviceTid = 10010;
|
|
break;
|
|
case "STI_Lobby":
|
|
case 10015:
|
|
message.serviceTid = 10015;
|
|
break;
|
|
case "STI_Admin":
|
|
case 10020:
|
|
message.serviceTid = 10020;
|
|
break;
|
|
case "STI_Gate":
|
|
case 20000:
|
|
message.serviceTid = 20000;
|
|
break;
|
|
case "STI_ColorGame":
|
|
case 20005:
|
|
message.serviceTid = 20005;
|
|
break;
|
|
case "STI_DB":
|
|
case 30000:
|
|
message.serviceTid = 30000;
|
|
break;
|
|
}
|
|
if (object.serviceName != null)
|
|
message.serviceName = String(object.serviceName);
|
|
if (object.userId != null)
|
|
if ($util.Long)
|
|
(message.userId = $util.Long.fromValue(object.userId)).unsigned = false;
|
|
else if (typeof object.userId === "string")
|
|
message.userId = parseInt(object.userId, 10);
|
|
else if (typeof object.userId === "number")
|
|
message.userId = object.userId;
|
|
else if (typeof object.userId === "object")
|
|
message.userId = new $util.LongBits(object.userId.low >>> 0, object.userId.high >>> 0).toNumber();
|
|
if (object.msgId != null)
|
|
message.msgId = object.msgId | 0;
|
|
if (object.data != null)
|
|
if (typeof object.data === "string")
|
|
$util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
|
|
else if (object.data.length >= 0)
|
|
message.data = object.data;
|
|
return message;
|
|
};
|
|
|
|
/**
|
|
* Creates a plain object from a ClientMsg message. Also converts values to other types if specified.
|
|
* @function toObject
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {ClientMsg} message ClientMsg
|
|
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
|
* @returns {Object.<string,*>} Plain object
|
|
*/
|
|
ClientMsg.toObject = function toObject(message, options) {
|
|
if (!options)
|
|
options = {};
|
|
var object = {};
|
|
if (options.defaults) {
|
|
object.serviceTid = options.enums === String ? "STI_Unknown" : 0;
|
|
object.serviceName = "";
|
|
if ($util.Long) {
|
|
var long = new $util.Long(0, 0, false);
|
|
object.userId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
|
} else
|
|
object.userId = options.longs === String ? "0" : 0;
|
|
object.msgId = 0;
|
|
if (options.bytes === String)
|
|
object.data = "";
|
|
else {
|
|
object.data = [];
|
|
if (options.bytes !== Array)
|
|
object.data = $util.newBuffer(object.data);
|
|
}
|
|
}
|
|
if (message.serviceTid != null && message.hasOwnProperty("serviceTid"))
|
|
object.serviceTid = options.enums === String ? $root.ServiceTypeId[message.serviceTid] === undefined ? message.serviceTid : $root.ServiceTypeId[message.serviceTid] : message.serviceTid;
|
|
if (message.serviceName != null && message.hasOwnProperty("serviceName"))
|
|
object.serviceName = message.serviceName;
|
|
if (message.userId != null && message.hasOwnProperty("userId"))
|
|
if (typeof message.userId === "number")
|
|
object.userId = options.longs === String ? String(message.userId) : message.userId;
|
|
else
|
|
object.userId = options.longs === String ? $util.Long.prototype.toString.call(message.userId) : options.longs === Number ? new $util.LongBits(message.userId.low >>> 0, message.userId.high >>> 0).toNumber() : message.userId;
|
|
if (message.msgId != null && message.hasOwnProperty("msgId"))
|
|
object.msgId = message.msgId;
|
|
if (message.data != null && message.hasOwnProperty("data"))
|
|
object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data;
|
|
return object;
|
|
};
|
|
|
|
/**
|
|
* Converts this ClientMsg to JSON.
|
|
* @function toJSON
|
|
* @memberof ClientMsg
|
|
* @instance
|
|
* @returns {Object.<string,*>} JSON object
|
|
*/
|
|
ClientMsg.prototype.toJSON = function toJSON() {
|
|
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
};
|
|
|
|
/**
|
|
* Gets the default type url for ClientMsg
|
|
* @function getTypeUrl
|
|
* @memberof ClientMsg
|
|
* @static
|
|
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
|
* @returns {string} The default type url
|
|
*/
|
|
ClientMsg.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
|
if (typeUrlPrefix === undefined) {
|
|
typeUrlPrefix = "type.googleapis.com";
|
|
}
|
|
return typeUrlPrefix + "/ClientMsg";
|
|
};
|
|
|
|
return ClientMsg;
|
|
})();
|
|
|
|
/**
|
|
* ServiceTypeId enum.
|
|
* @exports ServiceTypeId
|
|
* @enum {number}
|
|
* @property {number} STI_Unknown=0 STI_Unknown value
|
|
* @property {number} STI_Login=10000 STI_Login value
|
|
* @property {number} STI_Chat=10005 STI_Chat value
|
|
* @property {number} STI_Match=10010 STI_Match value
|
|
* @property {number} STI_Lobby=10015 STI_Lobby value
|
|
* @property {number} STI_Admin=10020 STI_Admin value
|
|
* @property {number} STI_Gate=20000 STI_Gate value
|
|
* @property {number} STI_ColorGame=20005 STI_ColorGame value
|
|
* @property {number} STI_DB=30000 STI_DB value
|
|
*/
|
|
$root.ServiceTypeId = (function() {
|
|
var valuesById = {}, values = Object.create(valuesById);
|
|
values[valuesById[0] = "STI_Unknown"] = 0;
|
|
values[valuesById[10000] = "STI_Login"] = 10000;
|
|
values[valuesById[10005] = "STI_Chat"] = 10005;
|
|
values[valuesById[10010] = "STI_Match"] = 10010;
|
|
values[valuesById[10015] = "STI_Lobby"] = 10015;
|
|
values[valuesById[10020] = "STI_Admin"] = 10020;
|
|
values[valuesById[20000] = "STI_Gate"] = 20000;
|
|
values[valuesById[20005] = "STI_ColorGame"] = 20005;
|
|
values[valuesById[30000] = "STI_DB"] = 30000;
|
|
return values;
|
|
})();
|
|
|
|
module.exports = $root;
|