diff --git a/proto/ClientServerMessage.d.ts b/proto/ClientServerMessage.d.ts index b2571b3..23ba875 100644 --- a/proto/ClientServerMessage.d.ts +++ b/proto/ClientServerMessage.d.ts @@ -126,6 +126,9 @@ export interface IClientServer { /** ClientServer player */ player?: (IPlayer|null); + /** ClientServer authentication */ + authentication?: (IAuthentication|null); + /** ClientServer playerData */ playerData?: (IPlayerData|null); @@ -157,6 +160,9 @@ export class ClientServer implements IClientServer { /** ClientServer player. */ public player?: (IPlayer|null); + /** ClientServer authentication. */ + public authentication?: (IAuthentication|null); + /** ClientServer playerData. */ public playerData?: (IPlayerData|null); @@ -167,7 +173,7 @@ export class ClientServer implements IClientServer { public chat?: (IChat|null); /** ClientServer message. */ - public message?: ("handshake"|"ping"|"player"|"playerData"|"metaData"|"chat"); + public message?: ("handshake"|"ping"|"player"|"authentication"|"playerData"|"metaData"|"chat"); /** * Creates a new ClientServer instance using the specified properties. @@ -248,6 +254,7 @@ export namespace ClientServer { HANDSHAKE = 2, PING = 3, PLAYER_UPDATE = 6, + AUTHENTICATION = 7, PLAYER_DATA = 128, META_DATA = 129, CHAT = 130 @@ -542,6 +549,96 @@ export class Player implements IPlayer { public toJSON(): { [k: string]: any }; } +/** Properties of an Authentication. */ +export interface IAuthentication { + + /** Authentication password */ + password?: (string|null); +} + +/** Represents an Authentication. */ +export class Authentication implements IAuthentication { + + /** + * Constructs a new Authentication. + * @param [properties] Properties to set + */ + constructor(properties?: IAuthentication); + + /** Authentication password. */ + public password: string; + + /** + * Creates a new Authentication instance using the specified properties. + * @param [properties] Properties to set + * @returns Authentication instance + */ + public static create(properties?: IAuthentication): Authentication; + + /** + * Encodes the specified Authentication message. Does not implicitly {@link Authentication.verify|verify} messages. + * @param message Authentication message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IAuthentication, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Authentication message, length delimited. Does not implicitly {@link Authentication.verify|verify} messages. + * @param message Authentication message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IAuthentication, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Authentication message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Authentication; + + /** + * Decodes an Authentication message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Authentication; + + /** + * Verifies an Authentication message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Authentication message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Authentication + */ + public static fromObject(object: { [k: string]: any }): Authentication; + + /** + * Creates a plain object from an Authentication message. Also converts values to other types if specified. + * @param message Authentication + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: Authentication, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Authentication to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + /** Properties of a PlayerData. */ export interface IPlayerData { diff --git a/proto/ClientServerMessage.js b/proto/ClientServerMessage.js index 9bfb401..a6f577f 100644 --- a/proto/ClientServerMessage.js +++ b/proto/ClientServerMessage.js @@ -325,6 +325,7 @@ $root.ClientServer = (function() { * @property {IClientHandshake|null} [handshake] ClientServer handshake * @property {IPing|null} [ping] ClientServer ping * @property {IPlayer|null} [player] ClientServer player + * @property {IAuthentication|null} [authentication] ClientServer authentication * @property {IPlayerData|null} [playerData] ClientServer playerData * @property {IMetaData|null} [metaData] ClientServer metaData * @property {IChat|null} [chat] ClientServer chat @@ -377,6 +378,14 @@ $root.ClientServer = (function() { */ ClientServer.prototype.player = null; + /** + * ClientServer authentication. + * @member {IAuthentication|null|undefined} authentication + * @memberof ClientServer + * @instance + */ + ClientServer.prototype.authentication = null; + /** * ClientServer playerData. * @member {IPlayerData|null|undefined} playerData @@ -406,12 +415,12 @@ $root.ClientServer = (function() { /** * ClientServer message. - * @member {"handshake"|"ping"|"player"|"playerData"|"metaData"|"chat"|undefined} message + * @member {"handshake"|"ping"|"player"|"authentication"|"playerData"|"metaData"|"chat"|undefined} message * @memberof ClientServer * @instance */ Object.defineProperty(ClientServer.prototype, "message", { - get: $util.oneOfGetter($oneOfFields = ["handshake", "ping", "player", "playerData", "metaData", "chat"]), + get: $util.oneOfGetter($oneOfFields = ["handshake", "ping", "player", "authentication", "playerData", "metaData", "chat"]), set: $util.oneOfSetter($oneOfFields) }); @@ -447,6 +456,8 @@ $root.ClientServer = (function() { $root.Ping.encode(message.ping, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.player != null && message.hasOwnProperty("player")) $root.Player.encode(message.player, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.authentication != null && message.hasOwnProperty("authentication")) + $root.Authentication.encode(message.authentication, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.playerData != null && message.hasOwnProperty("playerData")) $root.PlayerData.encode(message.playerData, writer.uint32(/* id 128, wireType 2 =*/1026).fork()).ldelim(); if (message.metaData != null && message.hasOwnProperty("metaData")) @@ -499,6 +510,9 @@ $root.ClientServer = (function() { case 6: message.player = $root.Player.decode(reader, reader.uint32()); break; + case 7: + message.authentication = $root.Authentication.decode(reader, reader.uint32()); + break; case 128: message.playerData = $root.PlayerData.decode(reader, reader.uint32()); break; @@ -552,6 +566,7 @@ $root.ClientServer = (function() { case 2: case 3: case 6: + case 7: case 128: case 129: case 130: @@ -585,6 +600,16 @@ $root.ClientServer = (function() { return "player." + error; } } + if (message.authentication != null && message.hasOwnProperty("authentication")) { + if (properties.message === 1) + return "message: multiple values"; + properties.message = 1; + { + var error = $root.Authentication.verify(message.authentication); + if (error) + return "authentication." + error; + } + } if (message.playerData != null && message.hasOwnProperty("playerData")) { if (properties.message === 1) return "message: multiple values"; @@ -647,6 +672,10 @@ $root.ClientServer = (function() { case 6: message.messageType = 6; break; + case "AUTHENTICATION": + case 7: + message.messageType = 7; + break; case "PLAYER_DATA": case 128: message.messageType = 128; @@ -675,6 +704,11 @@ $root.ClientServer = (function() { throw TypeError(".ClientServer.player: object expected"); message.player = $root.Player.fromObject(object.player); } + if (object.authentication != null) { + if (typeof object.authentication !== "object") + throw TypeError(".ClientServer.authentication: object expected"); + message.authentication = $root.Authentication.fromObject(object.authentication); + } if (object.playerData != null) { if (typeof object.playerData !== "object") throw TypeError(".ClientServer.playerData: object expected"); @@ -725,6 +759,11 @@ $root.ClientServer = (function() { if (options.oneofs) object.message = "player"; } + if (message.authentication != null && message.hasOwnProperty("authentication")) { + object.authentication = $root.Authentication.toObject(message.authentication, options); + if (options.oneofs) + object.message = "authentication"; + } if (message.playerData != null && message.hasOwnProperty("playerData")) { object.playerData = $root.PlayerData.toObject(message.playerData, options); if (options.oneofs) @@ -762,6 +801,7 @@ $root.ClientServer = (function() { * @property {number} HANDSHAKE=2 HANDSHAKE value * @property {number} PING=3 PING value * @property {number} PLAYER_UPDATE=6 PLAYER_UPDATE value + * @property {number} AUTHENTICATION=7 AUTHENTICATION value * @property {number} PLAYER_DATA=128 PLAYER_DATA value * @property {number} META_DATA=129 META_DATA value * @property {number} CHAT=130 CHAT value @@ -772,6 +812,7 @@ $root.ClientServer = (function() { values[valuesById[2] = "HANDSHAKE"] = 2; values[valuesById[3] = "PING"] = 3; values[valuesById[6] = "PLAYER_UPDATE"] = 6; + values[valuesById[7] = "AUTHENTICATION"] = 7; values[valuesById[128] = "PLAYER_DATA"] = 128; values[valuesById[129] = "META_DATA"] = 129; values[valuesById[130] = "CHAT"] = 130; @@ -1405,6 +1446,193 @@ $root.Player = (function() { return Player; })(); +$root.Authentication = (function() { + + /** + * Properties of an Authentication. + * @exports IAuthentication + * @interface IAuthentication + * @property {string|null} [password] Authentication password + */ + + /** + * Constructs a new Authentication. + * @exports Authentication + * @classdesc Represents an Authentication. + * @implements IAuthentication + * @constructor + * @param {IAuthentication=} [properties] Properties to set + */ + function Authentication(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]]; + } + + /** + * Authentication password. + * @member {string} password + * @memberof Authentication + * @instance + */ + Authentication.prototype.password = ""; + + /** + * Creates a new Authentication instance using the specified properties. + * @function create + * @memberof Authentication + * @static + * @param {IAuthentication=} [properties] Properties to set + * @returns {Authentication} Authentication instance + */ + Authentication.create = function create(properties) { + return new Authentication(properties); + }; + + /** + * Encodes the specified Authentication message. Does not implicitly {@link Authentication.verify|verify} messages. + * @function encode + * @memberof Authentication + * @static + * @param {IAuthentication} message Authentication message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Authentication.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.password != null && message.hasOwnProperty("password")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.password); + return writer; + }; + + /** + * Encodes the specified Authentication message, length delimited. Does not implicitly {@link Authentication.verify|verify} messages. + * @function encodeDelimited + * @memberof Authentication + * @static + * @param {IAuthentication} message Authentication message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Authentication.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Authentication message from the specified reader or buffer. + * @function decode + * @memberof Authentication + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {Authentication} Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Authentication.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Authentication(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.password = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Authentication message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof Authentication + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Authentication} Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Authentication.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Authentication message. + * @function verify + * @memberof Authentication + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Authentication.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.password != null && message.hasOwnProperty("password")) + if (!$util.isString(message.password)) + return "password: string expected"; + return null; + }; + + /** + * Creates an Authentication message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof Authentication + * @static + * @param {Object.} object Plain object + * @returns {Authentication} Authentication + */ + Authentication.fromObject = function fromObject(object) { + if (object instanceof $root.Authentication) + return object; + var message = new $root.Authentication(); + if (object.password != null) + message.password = String(object.password); + return message; + }; + + /** + * Creates a plain object from an Authentication message. Also converts values to other types if specified. + * @function toObject + * @memberof Authentication + * @static + * @param {Authentication} message Authentication + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Authentication.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.password = ""; + if (message.password != null && message.hasOwnProperty("password")) + object.password = message.password; + return object; + }; + + /** + * Converts this Authentication to JSON. + * @function toJSON + * @memberof Authentication + * @instance + * @returns {Object.} JSON object + */ + Authentication.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Authentication; +})(); + $root.PlayerData = (function() { /** diff --git a/proto/ServerClientMessage.d.ts b/proto/ServerClientMessage.d.ts index cf66a7c..959a2a7 100644 --- a/proto/ServerClientMessage.d.ts +++ b/proto/ServerClientMessage.d.ts @@ -297,6 +297,9 @@ export interface IServerHandshake { /** ServerHandshake gameMode */ gameMode?: (GameModeType|null); + + /** ServerHandshake passwordRequired */ + passwordRequired?: (boolean|null); } /** Represents a ServerHandshake. */ @@ -335,6 +338,9 @@ export class ServerHandshake implements IServerHandshake { /** ServerHandshake gameMode. */ public gameMode: GameModeType; + /** ServerHandshake passwordRequired. */ + public passwordRequired: boolean; + /** * Creates a new ServerHandshake instance using the specified properties. * @param [properties] Properties to set @@ -891,6 +897,9 @@ export interface IServerMessage { /** ServerMessage error */ error?: (IError|null); + + /** ServerMessage authentication */ + authentication?: (IAuthentication|null); } /** Represents a ServerMessage. */ @@ -917,8 +926,11 @@ export class ServerMessage implements IServerMessage { /** ServerMessage error. */ public error?: (IError|null); + /** ServerMessage authentication. */ + public authentication?: (IAuthentication|null); + /** ServerMessage message. */ - public message?: ("connectionDenied"|"gameMode"|"playerReorder"|"error"); + public message?: ("connectionDenied"|"gameMode"|"playerReorder"|"error"|"authentication"); /** * Creates a new ServerMessage instance using the specified properties. @@ -998,7 +1010,8 @@ export namespace ServerMessage { CONNECTION_DENIED = 0, GAME_MODE = 1, PLAYER_REORDER = 2, - ERROR = 3 + ERROR = 3, + AUTHENTICATION = 4 } } @@ -1206,6 +1219,111 @@ export namespace Error { } } +/** Properties of an Authentication. */ +export interface IAuthentication { + + /** Authentication status */ + status?: (Authentication.Status|null); + + /** Authentication throttle */ + throttle?: (number|null); +} + +/** Represents an Authentication. */ +export class Authentication implements IAuthentication { + + /** + * Constructs a new Authentication. + * @param [properties] Properties to set + */ + constructor(properties?: IAuthentication); + + /** Authentication status. */ + public status: Authentication.Status; + + /** Authentication throttle. */ + public throttle: number; + + /** + * Creates a new Authentication instance using the specified properties. + * @param [properties] Properties to set + * @returns Authentication instance + */ + public static create(properties?: IAuthentication): Authentication; + + /** + * Encodes the specified Authentication message. Does not implicitly {@link Authentication.verify|verify} messages. + * @param message Authentication message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IAuthentication, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Authentication message, length delimited. Does not implicitly {@link Authentication.verify|verify} messages. + * @param message Authentication message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IAuthentication, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Authentication message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Authentication; + + /** + * Decodes an Authentication message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Authentication; + + /** + * Verifies an Authentication message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Authentication message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Authentication + */ + public static fromObject(object: { [k: string]: any }): Authentication; + + /** + * Creates a plain object from an Authentication message. Also converts values to other types if specified. + * @param message Authentication + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: Authentication, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Authentication to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +export namespace Authentication { + + /** Status enum. */ + enum Status { + ACCEPTED = 0, + DENIED = 1 + } +} + /** Properties of a ConnectionDenied. */ export interface IConnectionDenied { diff --git a/proto/ServerClientMessage.js b/proto/ServerClientMessage.js index 3c68063..12234a8 100644 --- a/proto/ServerClientMessage.js +++ b/proto/ServerClientMessage.js @@ -878,6 +878,7 @@ $root.ServerHandshake = (function() { * @property {IPlayerListUpdate|null} [playerList] ServerHandshake playerList * @property {string|null} [countryCode] ServerHandshake countryCode * @property {GameModeType|null} [gameMode] ServerHandshake gameMode + * @property {boolean|null} [passwordRequired] ServerHandshake passwordRequired */ /** @@ -967,6 +968,14 @@ $root.ServerHandshake = (function() { */ ServerHandshake.prototype.gameMode = 0; + /** + * ServerHandshake passwordRequired. + * @member {boolean} passwordRequired + * @memberof ServerHandshake + * @instance + */ + ServerHandshake.prototype.passwordRequired = false; + /** * Creates a new ServerHandshake instance using the specified properties. * @function create @@ -1009,6 +1018,8 @@ $root.ServerHandshake = (function() { writer.uint32(/* id 8, wireType 2 =*/66).string(message.countryCode); if (message.gameMode != null && message.hasOwnProperty("gameMode")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.gameMode); + if (message.passwordRequired != null && message.hasOwnProperty("passwordRequired")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.passwordRequired); return writer; }; @@ -1070,6 +1081,9 @@ $root.ServerHandshake = (function() { case 9: message.gameMode = reader.int32(); break; + case 10: + message.passwordRequired = reader.bool(); + break; default: reader.skipType(tag & 7); break; @@ -1145,6 +1159,9 @@ $root.ServerHandshake = (function() { case 8: break; } + if (message.passwordRequired != null && message.hasOwnProperty("passwordRequired")) + if (typeof message.passwordRequired !== "boolean") + return "passwordRequired: boolean expected"; return null; }; @@ -1213,6 +1230,8 @@ $root.ServerHandshake = (function() { message.gameMode = 8; break; } + if (object.passwordRequired != null) + message.passwordRequired = Boolean(object.passwordRequired); return message; }; @@ -1239,6 +1258,7 @@ $root.ServerHandshake = (function() { object.playerList = null; object.countryCode = ""; object.gameMode = options.enums === String ? "NONE" : 0; + object.passwordRequired = false; } if (message.playerId != null && message.hasOwnProperty("playerId")) object.playerId = message.playerId; @@ -1258,6 +1278,8 @@ $root.ServerHandshake = (function() { object.countryCode = message.countryCode; if (message.gameMode != null && message.hasOwnProperty("gameMode")) object.gameMode = options.enums === String ? $root.GameModeType[message.gameMode] : message.gameMode; + if (message.passwordRequired != null && message.hasOwnProperty("passwordRequired")) + object.passwordRequired = message.passwordRequired; return object; }; @@ -2335,6 +2357,7 @@ $root.ServerMessage = (function() { * @property {IGameMode|null} [gameMode] ServerMessage gameMode * @property {IPlayerReorder|null} [playerReorder] ServerMessage playerReorder * @property {IError|null} [error] ServerMessage error + * @property {IAuthentication|null} [authentication] ServerMessage authentication */ /** @@ -2392,17 +2415,25 @@ $root.ServerMessage = (function() { */ ServerMessage.prototype.error = null; + /** + * ServerMessage authentication. + * @member {IAuthentication|null|undefined} authentication + * @memberof ServerMessage + * @instance + */ + ServerMessage.prototype.authentication = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; /** * ServerMessage message. - * @member {"connectionDenied"|"gameMode"|"playerReorder"|"error"|undefined} message + * @member {"connectionDenied"|"gameMode"|"playerReorder"|"error"|"authentication"|undefined} message * @memberof ServerMessage * @instance */ Object.defineProperty(ServerMessage.prototype, "message", { - get: $util.oneOfGetter($oneOfFields = ["connectionDenied", "gameMode", "playerReorder", "error"]), + get: $util.oneOfGetter($oneOfFields = ["connectionDenied", "gameMode", "playerReorder", "error", "authentication"]), set: $util.oneOfSetter($oneOfFields) }); @@ -2440,6 +2471,8 @@ $root.ServerMessage = (function() { $root.PlayerReorder.encode(message.playerReorder, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.error != null && message.hasOwnProperty("error")) $root.Error.encode(message.error, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.authentication != null && message.hasOwnProperty("authentication")) + $root.Authentication.encode(message.authentication, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -2489,6 +2522,9 @@ $root.ServerMessage = (function() { case 5: message.error = $root.Error.decode(reader, reader.uint32()); break; + case 6: + message.authentication = $root.Authentication.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -2533,6 +2569,7 @@ $root.ServerMessage = (function() { case 1: case 2: case 3: + case 4: break; } if (message.connectionDenied != null && message.hasOwnProperty("connectionDenied")) { @@ -2573,6 +2610,16 @@ $root.ServerMessage = (function() { return "error." + error; } } + if (message.authentication != null && message.hasOwnProperty("authentication")) { + if (properties.message === 1) + return "message: multiple values"; + properties.message = 1; + { + var error = $root.Authentication.verify(message.authentication); + if (error) + return "authentication." + error; + } + } return null; }; @@ -2605,6 +2652,10 @@ $root.ServerMessage = (function() { case 3: message.messageType = 3; break; + case "AUTHENTICATION": + case 4: + message.messageType = 4; + break; } if (object.connectionDenied != null) { if (typeof object.connectionDenied !== "object") @@ -2626,6 +2677,11 @@ $root.ServerMessage = (function() { throw TypeError(".ServerMessage.error: object expected"); message.error = $root.Error.fromObject(object.error); } + if (object.authentication != null) { + if (typeof object.authentication !== "object") + throw TypeError(".ServerMessage.authentication: object expected"); + message.authentication = $root.Authentication.fromObject(object.authentication); + } return message; }; @@ -2666,6 +2722,11 @@ $root.ServerMessage = (function() { if (options.oneofs) object.message = "error"; } + if (message.authentication != null && message.hasOwnProperty("authentication")) { + object.authentication = $root.Authentication.toObject(message.authentication, options); + if (options.oneofs) + object.message = "authentication"; + } return object; }; @@ -2688,6 +2749,7 @@ $root.ServerMessage = (function() { * @property {number} GAME_MODE=1 GAME_MODE value * @property {number} PLAYER_REORDER=2 PLAYER_REORDER value * @property {number} ERROR=3 ERROR value + * @property {number} AUTHENTICATION=4 AUTHENTICATION value */ ServerMessage.MessageType = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -2695,6 +2757,7 @@ $root.ServerMessage = (function() { values[valuesById[1] = "GAME_MODE"] = 1; values[valuesById[2] = "PLAYER_REORDER"] = 2; values[valuesById[3] = "ERROR"] = 3; + values[valuesById[4] = "AUTHENTICATION"] = 4; return values; })(); @@ -3169,6 +3232,243 @@ $root.Error = (function() { return Error; })(); +$root.Authentication = (function() { + + /** + * Properties of an Authentication. + * @exports IAuthentication + * @interface IAuthentication + * @property {Authentication.Status|null} [status] Authentication status + * @property {number|null} [throttle] Authentication throttle + */ + + /** + * Constructs a new Authentication. + * @exports Authentication + * @classdesc Represents an Authentication. + * @implements IAuthentication + * @constructor + * @param {IAuthentication=} [properties] Properties to set + */ + function Authentication(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]]; + } + + /** + * Authentication status. + * @member {Authentication.Status} status + * @memberof Authentication + * @instance + */ + Authentication.prototype.status = 0; + + /** + * Authentication throttle. + * @member {number} throttle + * @memberof Authentication + * @instance + */ + Authentication.prototype.throttle = 0; + + /** + * Creates a new Authentication instance using the specified properties. + * @function create + * @memberof Authentication + * @static + * @param {IAuthentication=} [properties] Properties to set + * @returns {Authentication} Authentication instance + */ + Authentication.create = function create(properties) { + return new Authentication(properties); + }; + + /** + * Encodes the specified Authentication message. Does not implicitly {@link Authentication.verify|verify} messages. + * @function encode + * @memberof Authentication + * @static + * @param {IAuthentication} message Authentication message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Authentication.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.status != null && message.hasOwnProperty("status")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.status); + if (message.throttle != null && message.hasOwnProperty("throttle")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.throttle); + return writer; + }; + + /** + * Encodes the specified Authentication message, length delimited. Does not implicitly {@link Authentication.verify|verify} messages. + * @function encodeDelimited + * @memberof Authentication + * @static + * @param {IAuthentication} message Authentication message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Authentication.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Authentication message from the specified reader or buffer. + * @function decode + * @memberof Authentication + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {Authentication} Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Authentication.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Authentication(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.status = reader.int32(); + break; + case 2: + message.throttle = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Authentication message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof Authentication + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Authentication} Authentication + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Authentication.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Authentication message. + * @function verify + * @memberof Authentication + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Authentication.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.status != null && message.hasOwnProperty("status")) + switch (message.status) { + default: + return "status: enum value expected"; + case 0: + case 1: + break; + } + if (message.throttle != null && message.hasOwnProperty("throttle")) + if (!$util.isInteger(message.throttle)) + return "throttle: integer expected"; + return null; + }; + + /** + * Creates an Authentication message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof Authentication + * @static + * @param {Object.} object Plain object + * @returns {Authentication} Authentication + */ + Authentication.fromObject = function fromObject(object) { + if (object instanceof $root.Authentication) + return object; + var message = new $root.Authentication(); + switch (object.status) { + case "ACCEPTED": + case 0: + message.status = 0; + break; + case "DENIED": + case 1: + message.status = 1; + break; + } + if (object.throttle != null) + message.throttle = object.throttle >>> 0; + return message; + }; + + /** + * Creates a plain object from an Authentication message. Also converts values to other types if specified. + * @function toObject + * @memberof Authentication + * @static + * @param {Authentication} message Authentication + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Authentication.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.status = options.enums === String ? "ACCEPTED" : 0; + object.throttle = 0; + } + if (message.status != null && message.hasOwnProperty("status")) + object.status = options.enums === String ? $root.Authentication.Status[message.status] : message.status; + if (message.throttle != null && message.hasOwnProperty("throttle")) + object.throttle = message.throttle; + return object; + }; + + /** + * Converts this Authentication to JSON. + * @function toJSON + * @memberof Authentication + * @instance + * @returns {Object.} JSON object + */ + Authentication.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Status enum. + * @name Authentication.Status + * @enum {string} + * @property {number} ACCEPTED=0 ACCEPTED value + * @property {number} DENIED=1 DENIED value + */ + Authentication.Status = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ACCEPTED"] = 0; + values[valuesById[1] = "DENIED"] = 1; + return values; + })(); + + return Authentication; +})(); + $root.ConnectionDenied = (function() { /** diff --git a/proto/client-server/Authentication.proto b/proto/client-server/Authentication.proto new file mode 100644 index 0000000..c0739ed --- /dev/null +++ b/proto/client-server/Authentication.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +message Authentication { + string password = 1; +} \ No newline at end of file diff --git a/proto/client-server/ClientServer.proto b/proto/client-server/ClientServer.proto index 31b9a24..1b85320 100644 --- a/proto/client-server/ClientServer.proto +++ b/proto/client-server/ClientServer.proto @@ -3,6 +3,7 @@ syntax = "proto3"; import "client-server/ClientHandshake.proto"; import "shared/Ping.proto"; import "shared/Player.proto"; +import "client-server/Authentication.proto"; import "shared/PlayerData.proto"; import "shared/MetaData.proto"; import "shared/Chat.proto"; @@ -13,6 +14,7 @@ message ClientServer { HANDSHAKE = 2; PING = 3; PLAYER_UPDATE = 6; + AUTHENTICATION = 7; PLAYER_DATA = 128; META_DATA = 129; CHAT = 130; @@ -22,6 +24,7 @@ message ClientServer { ClientHandshake handshake = 2; Ping ping = 3; Player player = 6; + Authentication authentication = 7; PlayerData player_data = 128; MetaData meta_data = 129; Chat chat = 130; diff --git a/proto/server-client/ServerHandshake.proto b/proto/server-client/ServerHandshake.proto index 2618ad9..527e1be 100644 --- a/proto/server-client/ServerHandshake.proto +++ b/proto/server-client/ServerHandshake.proto @@ -11,6 +11,7 @@ message ServerHandshake { string name = 5; string description = 6; PlayerListUpdate player_list = 7; - string countryCode = 8; + string country_code = 8; GameModeType game_mode = 9; + bool password_required = 10; } \ No newline at end of file diff --git a/proto/server-client/ServerMessage.proto b/proto/server-client/ServerMessage.proto index be941da..eb7e080 100644 --- a/proto/server-client/ServerMessage.proto +++ b/proto/server-client/ServerMessage.proto @@ -9,6 +9,7 @@ message ServerMessage { GAME_MODE = 1; PLAYER_REORDER = 2; ERROR = 3; + AUTHENTICATION = 4; } MessageType message_type = 1; oneof message { @@ -16,6 +17,7 @@ message ServerMessage { GameMode game_mode = 3; PlayerReorder player_reorder = 4; Error error = 5; + Authentication authentication = 6; } } @@ -34,4 +36,13 @@ message Error { } ErrorType error_type = 1; string message = 2; +} + +message Authentication { + enum Status { + ACCEPTED = 0; + DENIED = 1; + } + Status status = 1; + uint32 throttle = 2; } \ No newline at end of file