diff --git a/apps/arena/lib/arena/game_socket_handler.ex b/apps/arena/lib/arena/game_socket_handler.ex index 35afd3a2f..45c8b43e0 100644 --- a/apps/arena/lib/arena/game_socket_handler.ex +++ b/apps/arena/lib/arena/game_socket_handler.ex @@ -85,16 +85,6 @@ defmodule Arena.GameSocketHandler do {:ok, Map.put(state, :enable, true)} end - @impl true - def websocket_info({:ping, game_state}, state) do - {:reply, {:binary, game_state}, state} - end - - @impl true - def websocket_info({:ping_update, game_state}, state) do - {:reply, {:binary, game_state}, state} - end - @impl true def websocket_info({:game_update, game_state}, state) do # Logger.info("Websocket info, Message: GAME UPDATE") @@ -214,9 +204,6 @@ defmodule Arena.GameSocketHandler do defp handle_decoded_message(%{action_type: {:select_bounty, bounty_params}}, state), do: GameUpdater.select_bounty(state.game_pid, state.player_id, bounty_params.bounty_quest_id) - defp handle_decoded_message(%{action_type: {:pong, pong_params}}, state), - do: GameUpdater.pong(state.game_pid, self(), pong_params.ping_timestamp) - defp handle_decoded_message(%{action_type: {:toggle_zone, _zone_params}}, state), do: GameUpdater.toggle_zone(state.game_pid) diff --git a/apps/arena/lib/arena/game_updater.ex b/apps/arena/lib/arena/game_updater.ex index 95794fb11..5d02cafec 100644 --- a/apps/arena/lib/arena/game_updater.ex +++ b/apps/arena/lib/arena/game_updater.ex @@ -17,8 +17,6 @@ defmodule Arena.GameUpdater do alias Arena.Serialization.GameState alias Arena.Serialization.GameFinished alias Arena.Serialization.ToggleBots - alias Arena.Serialization.PingUpdate - alias Arena.Serialization.Ping alias Phoenix.PubSub alias Arena.Game.Trap @@ -57,10 +55,6 @@ defmodule Arena.GameUpdater do GenServer.cast(game_pid, {:change_tickrate, tickrate}) end - def pong(game_pid, client_pid, ping_timestamp) do - GenServer.cast(game_pid, {:pong, client_pid, ping_timestamp}) - end - ########################## # END API ########################## @@ -74,7 +68,6 @@ defmodule Arena.GameUpdater do match_id = Ecto.UUID.generate() send(self(), :update_game) - send(self(), :send_ping) bounties_enabled? = game_config.game.bounty_pick_time_ms > 0 @@ -220,20 +213,6 @@ defmodule Arena.GameUpdater do {:noreply, put_in(state, [:game_config, :game, :tick_rate_ms], tickrate)} end - def handle_cast({:pong, client_pid, ping_timestamp}, state) do - now = DateTime.utc_now() |> DateTime.to_unix(:millisecond) - latency = now - ping_timestamp - - encoded_msg = - GameEvent.encode(%GameEvent{ - event: {:ping_update, %PingUpdate{latency: latency}} - }) - - send(client_pid, {:ping_update, encoded_msg}) - - {:noreply, state} - end - ########################## # END API Callbacks ########################## @@ -313,12 +292,6 @@ defmodule Arena.GameUpdater do {:noreply, %{state | game_state: game_state, last_broadcasted_game_state: last_broadcasted_game_state}} end - def handle_info(:send_ping, state) do - Process.send_after(self(), :send_ping, 500) - broadcast_ping(state.game_state) - {:noreply, state} - end - def handle_info(:selecting_bounty, state) do Process.send_after(self(), :game_start, state.game_config.game.start_game_time_ms) Process.send_after(self(), :pick_default_bounty_for_missing_players, state.game_config.game.start_game_time_ms) @@ -758,17 +731,6 @@ defmodule Arena.GameUpdater do PubSub.broadcast(Arena.PubSub, game_id, {:game_update, encoded_state}) end - defp broadcast_ping(state) do - now = DateTime.utc_now() |> DateTime.to_unix(:millisecond) - - encoded_state = - GameEvent.encode(%GameEvent{ - event: {:ping, %Ping{timestamp_now: now}} - }) - - PubSub.broadcast(Arena.PubSub, state.game_id, {:ping, encoded_state}) - end - defp broadcast_game_ended(winner, state) do game_state = %GameFinished{ winner: complete_entity(winner, :player), diff --git a/apps/arena/lib/arena/serialization/messages.pb.ex b/apps/arena/lib/arena/serialization/messages.pb.ex index bc986770f..cde9be837 100644 --- a/apps/arena/lib/arena/serialization/messages.pb.ex +++ b/apps/arena/lib/arena/serialization/messages.pb.ex @@ -140,33 +140,15 @@ defmodule Arena.Serialization.GameEvent do field(:joined, 1, type: Arena.Serialization.GameJoined, oneof: 0) field(:update, 2, type: Arena.Serialization.GameState, oneof: 0) field(:finished, 3, type: Arena.Serialization.GameFinished, oneof: 0) - field(:ping_update, 4, type: Arena.Serialization.PingUpdate, json_name: "pingUpdate", oneof: 0) - field(:toggle_bots, 5, type: Arena.Serialization.ToggleBots, json_name: "toggleBots", oneof: 0) - field(:ping, 6, type: Arena.Serialization.Ping, oneof: 0) + field(:toggle_bots, 4, type: Arena.Serialization.ToggleBots, json_name: "toggleBots", oneof: 0) - field(:bounty_selected, 7, + field(:bounty_selected, 5, type: Arena.Serialization.BountySelected, json_name: "bountySelected", oneof: 0 ) end -defmodule Arena.Serialization.Ping do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:timestamp_now, 1, type: :int64, json_name: "timestampNow") -end - -defmodule Arena.Serialization.PingUpdate do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:latency, 1, type: :uint64) -end - defmodule Arena.Serialization.BountySelected do @moduledoc false @@ -749,18 +731,9 @@ defmodule Arena.Serialization.GameAction do oneof: 0 ) - field(:pong, 9, type: Arena.Serialization.Pong, oneof: 0) field(:timestamp, 3, type: :int64) end -defmodule Arena.Serialization.Pong do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:ping_timestamp, 1, type: :int64, json_name: "pingTimestamp") -end - defmodule Arena.Serialization.Zone do @moduledoc false diff --git a/apps/arena/mix.exs b/apps/arena/mix.exs index 14aedd518..b8e940e56 100644 --- a/apps/arena/mix.exs +++ b/apps/arena/mix.exs @@ -4,7 +4,7 @@ defmodule Arena.MixProject do def project do [ app: :arena, - version: "0.7.1", + version: "0.8.1", build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", diff --git a/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex b/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex index 06bf28e06..ab4a654fd 100644 --- a/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex +++ b/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex @@ -141,43 +141,19 @@ defmodule ArenaLoadTest.Serialization.GameEvent do field(:update, 2, type: ArenaLoadTest.Serialization.GameState, oneof: 0) field(:finished, 3, type: ArenaLoadTest.Serialization.GameFinished, oneof: 0) - field(:ping_update, 4, - type: ArenaLoadTest.Serialization.PingUpdate, - json_name: "pingUpdate", - oneof: 0 - ) - - field(:toggle_bots, 5, + field(:toggle_bots, 4, type: ArenaLoadTest.Serialization.ToggleBots, json_name: "toggleBots", oneof: 0 ) - field(:ping, 6, type: ArenaLoadTest.Serialization.Ping, oneof: 0) - - field(:bounty_selected, 7, + field(:bounty_selected, 5, type: ArenaLoadTest.Serialization.BountySelected, json_name: "bountySelected", oneof: 0 ) end -defmodule ArenaLoadTest.Serialization.Ping do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:timestamp_now, 1, type: :int64, json_name: "timestampNow") -end - -defmodule ArenaLoadTest.Serialization.PingUpdate do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:latency, 1, type: :uint64) -end - defmodule ArenaLoadTest.Serialization.BountySelected do @moduledoc false @@ -812,18 +788,9 @@ defmodule ArenaLoadTest.Serialization.GameAction do oneof: 0 ) - field(:pong, 9, type: ArenaLoadTest.Serialization.Pong, oneof: 0) field(:timestamp, 3, type: :int64) end -defmodule ArenaLoadTest.Serialization.Pong do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:ping_timestamp, 1, type: :int64, json_name: "pingTimestamp") -end - defmodule ArenaLoadTest.Serialization.Zone do @moduledoc false diff --git a/apps/bot_manager/lib/protobuf/messages.pb.ex b/apps/bot_manager/lib/protobuf/messages.pb.ex index f0884762c..26773cf2c 100644 --- a/apps/bot_manager/lib/protobuf/messages.pb.ex +++ b/apps/bot_manager/lib/protobuf/messages.pb.ex @@ -140,33 +140,15 @@ defmodule BotManager.Protobuf.GameEvent do field(:joined, 1, type: BotManager.Protobuf.GameJoined, oneof: 0) field(:update, 2, type: BotManager.Protobuf.GameState, oneof: 0) field(:finished, 3, type: BotManager.Protobuf.GameFinished, oneof: 0) - field(:ping_update, 4, type: BotManager.Protobuf.PingUpdate, json_name: "pingUpdate", oneof: 0) - field(:toggle_bots, 5, type: BotManager.Protobuf.ToggleBots, json_name: "toggleBots", oneof: 0) - field(:ping, 6, type: BotManager.Protobuf.Ping, oneof: 0) + field(:toggle_bots, 4, type: BotManager.Protobuf.ToggleBots, json_name: "toggleBots", oneof: 0) - field(:bounty_selected, 7, + field(:bounty_selected, 5, type: BotManager.Protobuf.BountySelected, json_name: "bountySelected", oneof: 0 ) end -defmodule BotManager.Protobuf.Ping do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:timestamp_now, 1, type: :int64, json_name: "timestampNow") -end - -defmodule BotManager.Protobuf.PingUpdate do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:latency, 1, type: :uint64) -end - defmodule BotManager.Protobuf.BountySelected do @moduledoc false @@ -749,18 +731,9 @@ defmodule BotManager.Protobuf.GameAction do oneof: 0 ) - field(:pong, 9, type: BotManager.Protobuf.Pong, oneof: 0) field(:timestamp, 3, type: :int64) end -defmodule BotManager.Protobuf.Pong do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:ping_timestamp, 1, type: :int64, json_name: "pingTimestamp") -end - defmodule BotManager.Protobuf.Zone do @moduledoc false diff --git a/apps/game_client/assets/js/protobuf/messages_pb.js b/apps/game_client/assets/js/protobuf/messages_pb.js index 47dd3a303..3bb44d878 100644 --- a/apps/game_client/assets/js/protobuf/messages_pb.js +++ b/apps/game_client/assets/js/protobuf/messages_pb.js @@ -59,12 +59,9 @@ goog.exportSymbol('proto.LobbyEvent', null, global); goog.exportSymbol('proto.LobbyEvent.EventCase', null, global); goog.exportSymbol('proto.Move', null, global); goog.exportSymbol('proto.Obstacle', null, global); -goog.exportSymbol('proto.Ping', null, global); -goog.exportSymbol('proto.PingUpdate', null, global); goog.exportSymbol('proto.Player', null, global); goog.exportSymbol('proto.PlayerAction', null, global); goog.exportSymbol('proto.PlayerActionType', null, global); -goog.exportSymbol('proto.Pong', null, global); goog.exportSymbol('proto.Pool', null, global); goog.exportSymbol('proto.PoolStatus', null, global); goog.exportSymbol('proto.Position', null, global); @@ -247,48 +244,6 @@ if (goog.DEBUG && !COMPILED) { */ proto.GameEvent.displayName = 'proto.GameEvent'; } -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.Ping = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.Ping, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.Ping.displayName = 'proto.Ping'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.PingUpdate = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.PingUpdate, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.PingUpdate.displayName = 'proto.PingUpdate'; -} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -961,27 +916,6 @@ if (goog.DEBUG && !COMPILED) { */ proto.GameAction.displayName = 'proto.GameAction'; } -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.Pong = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.Pong, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.Pong.displayName = 'proto.Pong'; -} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -2262,7 +2196,7 @@ proto.JoinedLobby.serializeBinaryToWriter = function(message, writer) { * @private {!Array>} * @const */ -proto.GameEvent.oneofGroups_ = [[1,2,3,4,5,6,7]]; +proto.GameEvent.oneofGroups_ = [[1,2,3,4,5]]; /** * @enum {number} @@ -2272,10 +2206,8 @@ proto.GameEvent.EventCase = { JOINED: 1, UPDATE: 2, FINISHED: 3, - PING_UPDATE: 4, - TOGGLE_BOTS: 5, - PING: 6, - BOUNTY_SELECTED: 7 + TOGGLE_BOTS: 4, + BOUNTY_SELECTED: 5 }; /** @@ -2319,9 +2251,7 @@ proto.GameEvent.toObject = function(includeInstance, msg) { joined: (f = msg.getJoined()) && proto.GameJoined.toObject(includeInstance, f), update: (f = msg.getUpdate()) && proto.GameState.toObject(includeInstance, f), finished: (f = msg.getFinished()) && proto.GameFinished.toObject(includeInstance, f), - pingUpdate: (f = msg.getPingUpdate()) && proto.PingUpdate.toObject(includeInstance, f), toggleBots: (f = msg.getToggleBots()) && proto.ToggleBots.toObject(includeInstance, f), - ping: (f = msg.getPing()) && proto.Ping.toObject(includeInstance, f), bountySelected: (f = msg.getBountySelected()) && proto.BountySelected.toObject(includeInstance, f) }; @@ -2375,21 +2305,11 @@ proto.GameEvent.deserializeBinaryFromReader = function(msg, reader) { msg.setFinished(value); break; case 4: - var value = new proto.PingUpdate; - reader.readMessage(value,proto.PingUpdate.deserializeBinaryFromReader); - msg.setPingUpdate(value); - break; - case 5: var value = new proto.ToggleBots; reader.readMessage(value,proto.ToggleBots.deserializeBinaryFromReader); msg.setToggleBots(value); break; - case 6: - var value = new proto.Ping; - reader.readMessage(value,proto.Ping.deserializeBinaryFromReader); - msg.setPing(value); - break; - case 7: + case 5: var value = new proto.BountySelected; reader.readMessage(value,proto.BountySelected.deserializeBinaryFromReader); msg.setBountySelected(value); @@ -2447,34 +2367,18 @@ proto.GameEvent.serializeBinaryToWriter = function(message, writer) { proto.GameFinished.serializeBinaryToWriter ); } - f = message.getPingUpdate(); - if (f != null) { - writer.writeMessage( - 4, - f, - proto.PingUpdate.serializeBinaryToWriter - ); - } f = message.getToggleBots(); if (f != null) { writer.writeMessage( - 5, + 4, f, proto.ToggleBots.serializeBinaryToWriter ); } - f = message.getPing(); - if (f != null) { - writer.writeMessage( - 6, - f, - proto.Ping.serializeBinaryToWriter - ); - } f = message.getBountySelected(); if (f != null) { writer.writeMessage( - 7, + 5, f, proto.BountySelected.serializeBinaryToWriter ); @@ -2594,49 +2498,12 @@ proto.GameEvent.prototype.hasFinished = function() { /** - * optional PingUpdate ping_update = 4; - * @return {?proto.PingUpdate} - */ -proto.GameEvent.prototype.getPingUpdate = function() { - return /** @type{?proto.PingUpdate} */ ( - jspb.Message.getWrapperField(this, proto.PingUpdate, 4)); -}; - - -/** - * @param {?proto.PingUpdate|undefined} value - * @return {!proto.GameEvent} returns this -*/ -proto.GameEvent.prototype.setPingUpdate = function(value) { - return jspb.Message.setOneofWrapperField(this, 4, proto.GameEvent.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.GameEvent} returns this - */ -proto.GameEvent.prototype.clearPingUpdate = function() { - return this.setPingUpdate(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.GameEvent.prototype.hasPingUpdate = function() { - return jspb.Message.getField(this, 4) != null; -}; - - -/** - * optional ToggleBots toggle_bots = 5; + * optional ToggleBots toggle_bots = 4; * @return {?proto.ToggleBots} */ proto.GameEvent.prototype.getToggleBots = function() { return /** @type{?proto.ToggleBots} */ ( - jspb.Message.getWrapperField(this, proto.ToggleBots, 5)); + jspb.Message.getWrapperField(this, proto.ToggleBots, 4)); }; @@ -2645,7 +2512,7 @@ proto.GameEvent.prototype.getToggleBots = function() { * @return {!proto.GameEvent} returns this */ proto.GameEvent.prototype.setToggleBots = function(value) { - return jspb.Message.setOneofWrapperField(this, 5, proto.GameEvent.oneofGroups_[0], value); + return jspb.Message.setOneofWrapperField(this, 4, proto.GameEvent.oneofGroups_[0], value); }; @@ -2663,54 +2530,17 @@ proto.GameEvent.prototype.clearToggleBots = function() { * @return {boolean} */ proto.GameEvent.prototype.hasToggleBots = function() { - return jspb.Message.getField(this, 5) != null; -}; - - -/** - * optional Ping ping = 6; - * @return {?proto.Ping} - */ -proto.GameEvent.prototype.getPing = function() { - return /** @type{?proto.Ping} */ ( - jspb.Message.getWrapperField(this, proto.Ping, 6)); -}; - - -/** - * @param {?proto.Ping|undefined} value - * @return {!proto.GameEvent} returns this -*/ -proto.GameEvent.prototype.setPing = function(value) { - return jspb.Message.setOneofWrapperField(this, 6, proto.GameEvent.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.GameEvent} returns this - */ -proto.GameEvent.prototype.clearPing = function() { - return this.setPing(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.GameEvent.prototype.hasPing = function() { - return jspb.Message.getField(this, 6) != null; + return jspb.Message.getField(this, 4) != null; }; /** - * optional BountySelected bounty_selected = 7; + * optional BountySelected bounty_selected = 5; * @return {?proto.BountySelected} */ proto.GameEvent.prototype.getBountySelected = function() { return /** @type{?proto.BountySelected} */ ( - jspb.Message.getWrapperField(this, proto.BountySelected, 7)); + jspb.Message.getWrapperField(this, proto.BountySelected, 5)); }; @@ -2719,7 +2549,7 @@ proto.GameEvent.prototype.getBountySelected = function() { * @return {!proto.GameEvent} returns this */ proto.GameEvent.prototype.setBountySelected = function(value) { - return jspb.Message.setOneofWrapperField(this, 7, proto.GameEvent.oneofGroups_[0], value); + return jspb.Message.setOneofWrapperField(this, 5, proto.GameEvent.oneofGroups_[0], value); }; @@ -2737,267 +2567,7 @@ proto.GameEvent.prototype.clearBountySelected = function() { * @return {boolean} */ proto.GameEvent.prototype.hasBountySelected = function() { - return jspb.Message.getField(this, 7) != null; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.Ping.prototype.toObject = function(opt_includeInstance) { - return proto.Ping.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.Ping} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.Ping.toObject = function(includeInstance, msg) { - var f, obj = { - timestampNow: jspb.Message.getFieldWithDefault(msg, 1, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.Ping} - */ -proto.Ping.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.Ping; - return proto.Ping.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.Ping} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.Ping} - */ -proto.Ping.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readInt64()); - msg.setTimestampNow(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.Ping.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.Ping.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.Ping} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.Ping.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getTimestampNow(); - if (f !== 0) { - writer.writeInt64( - 1, - f - ); - } -}; - - -/** - * optional int64 timestamp_now = 1; - * @return {number} - */ -proto.Ping.prototype.getTimestampNow = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.Ping} returns this - */ -proto.Ping.prototype.setTimestampNow = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.PingUpdate.prototype.toObject = function(opt_includeInstance) { - return proto.PingUpdate.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.PingUpdate} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.PingUpdate.toObject = function(includeInstance, msg) { - var f, obj = { - latency: jspb.Message.getFieldWithDefault(msg, 1, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.PingUpdate} - */ -proto.PingUpdate.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.PingUpdate; - return proto.PingUpdate.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.PingUpdate} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.PingUpdate} - */ -proto.PingUpdate.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setLatency(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.PingUpdate.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.PingUpdate.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.PingUpdate} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.PingUpdate.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getLatency(); - if (f !== 0) { - writer.writeUint64( - 1, - f - ); - } -}; - - -/** - * optional uint64 latency = 1; - * @return {number} - */ -proto.PingUpdate.prototype.getLatency = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.PingUpdate} returns this - */ -proto.PingUpdate.prototype.setLatency = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); + return jspb.Message.getField(this, 5) != null; }; @@ -11495,7 +11065,7 @@ proto.ChangeTickrate.prototype.setTickrate = function(value) { * @private {!Array>} * @const */ -proto.GameAction.oneofGroups_ = [[1,2,4,5,6,7,8,9]]; +proto.GameAction.oneofGroups_ = [[1,2,4,5,6,7,8]]; /** * @enum {number} @@ -11508,8 +11078,7 @@ proto.GameAction.ActionTypeCase = { SELECT_BOUNTY: 5, TOGGLE_ZONE: 6, TOGGLE_BOTS: 7, - CHANGE_TICKRATE: 8, - PONG: 9 + CHANGE_TICKRATE: 8 }; /** @@ -11557,7 +11126,6 @@ proto.GameAction.toObject = function(includeInstance, msg) { toggleZone: (f = msg.getToggleZone()) && proto.ToggleZone.toObject(includeInstance, f), toggleBots: (f = msg.getToggleBots()) && proto.ToggleBots.toObject(includeInstance, f), changeTickrate: (f = msg.getChangeTickrate()) && proto.ChangeTickrate.toObject(includeInstance, f), - pong: (f = msg.getPong()) && proto.Pong.toObject(includeInstance, f), timestamp: jspb.Message.getFieldWithDefault(msg, 3, 0) }; @@ -11630,11 +11198,6 @@ proto.GameAction.deserializeBinaryFromReader = function(msg, reader) { reader.readMessage(value,proto.ChangeTickrate.deserializeBinaryFromReader); msg.setChangeTickrate(value); break; - case 9: - var value = new proto.Pong; - reader.readMessage(value,proto.Pong.deserializeBinaryFromReader); - msg.setPong(value); - break; case 3: var value = /** @type {number} */ (reader.readInt64()); msg.setTimestamp(value); @@ -11724,14 +11287,6 @@ proto.GameAction.serializeBinaryToWriter = function(message, writer) { proto.ChangeTickrate.serializeBinaryToWriter ); } - f = message.getPong(); - if (f != null) { - writer.writeMessage( - 9, - f, - proto.Pong.serializeBinaryToWriter - ); - } f = message.getTimestamp(); if (f !== 0) { writer.writeInt64( @@ -12001,43 +11556,6 @@ proto.GameAction.prototype.hasChangeTickrate = function() { }; -/** - * optional Pong pong = 9; - * @return {?proto.Pong} - */ -proto.GameAction.prototype.getPong = function() { - return /** @type{?proto.Pong} */ ( - jspb.Message.getWrapperField(this, proto.Pong, 9)); -}; - - -/** - * @param {?proto.Pong|undefined} value - * @return {!proto.GameAction} returns this -*/ -proto.GameAction.prototype.setPong = function(value) { - return jspb.Message.setOneofWrapperField(this, 9, proto.GameAction.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.GameAction} returns this - */ -proto.GameAction.prototype.clearPong = function() { - return this.setPong(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.GameAction.prototype.hasPong = function() { - return jspb.Message.getField(this, 9) != null; -}; - - /** * optional int64 timestamp = 3; * @return {number} @@ -12059,136 +11577,6 @@ proto.GameAction.prototype.setTimestamp = function(value) { -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.Pong.prototype.toObject = function(opt_includeInstance) { - return proto.Pong.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.Pong} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.Pong.toObject = function(includeInstance, msg) { - var f, obj = { - pingTimestamp: jspb.Message.getFieldWithDefault(msg, 1, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.Pong} - */ -proto.Pong.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.Pong; - return proto.Pong.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.Pong} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.Pong} - */ -proto.Pong.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readInt64()); - msg.setPingTimestamp(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.Pong.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.Pong.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.Pong} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.Pong.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPingTimestamp(); - if (f !== 0) { - writer.writeInt64( - 1, - f - ); - } -}; - - -/** - * optional int64 ping_timestamp = 1; - * @return {number} - */ -proto.Pong.prototype.getPingTimestamp = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.Pong} returns this - */ -proto.Pong.prototype.setPingTimestamp = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - - - - if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. diff --git a/apps/game_client/lib/game_client/protobuf/messages.pb.ex b/apps/game_client/lib/game_client/protobuf/messages.pb.ex index c296116ba..5fc21af4c 100644 --- a/apps/game_client/lib/game_client/protobuf/messages.pb.ex +++ b/apps/game_client/lib/game_client/protobuf/messages.pb.ex @@ -140,33 +140,15 @@ defmodule GameClient.Protobuf.GameEvent do field(:joined, 1, type: GameClient.Protobuf.GameJoined, oneof: 0) field(:update, 2, type: GameClient.Protobuf.GameState, oneof: 0) field(:finished, 3, type: GameClient.Protobuf.GameFinished, oneof: 0) - field(:ping_update, 4, type: GameClient.Protobuf.PingUpdate, json_name: "pingUpdate", oneof: 0) - field(:toggle_bots, 5, type: GameClient.Protobuf.ToggleBots, json_name: "toggleBots", oneof: 0) - field(:ping, 6, type: GameClient.Protobuf.Ping, oneof: 0) + field(:toggle_bots, 4, type: GameClient.Protobuf.ToggleBots, json_name: "toggleBots", oneof: 0) - field(:bounty_selected, 7, + field(:bounty_selected, 5, type: GameClient.Protobuf.BountySelected, json_name: "bountySelected", oneof: 0 ) end -defmodule GameClient.Protobuf.Ping do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:timestamp_now, 1, type: :int64, json_name: "timestampNow") -end - -defmodule GameClient.Protobuf.PingUpdate do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:latency, 1, type: :uint64) -end - defmodule GameClient.Protobuf.BountySelected do @moduledoc false @@ -749,18 +731,9 @@ defmodule GameClient.Protobuf.GameAction do oneof: 0 ) - field(:pong, 9, type: GameClient.Protobuf.Pong, oneof: 0) field(:timestamp, 3, type: :int64) end -defmodule GameClient.Protobuf.Pong do - @moduledoc false - - use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - - field(:ping_timestamp, 1, type: :int64, json_name: "pingTimestamp") -end - defmodule GameClient.Protobuf.Zone do @moduledoc false diff --git a/apps/game_client/lib/game_client_web/live/pages/board/show.ex b/apps/game_client/lib/game_client_web/live/pages/board/show.ex index b43762315..81e172314 100644 --- a/apps/game_client/lib/game_client_web/live/pages/board/show.ex +++ b/apps/game_client/lib/game_client_web/live/pages/board/show.ex @@ -114,7 +114,7 @@ defmodule GameClientWeb.BoardLive.Show do end defp handle_game_event({noop_event, _}, socket) - when noop_event in [:toggle_bots, :ping, :ping_update, :bounty_selected] do + when noop_event in [:toggle_bots, :bounty_selected] do {:noreply, socket} end diff --git a/apps/serialization/messages.proto b/apps/serialization/messages.proto index ec680b13c..1704a9a89 100644 --- a/apps/serialization/messages.proto +++ b/apps/serialization/messages.proto @@ -42,21 +42,11 @@ message GameEvent { GameJoined joined = 1; GameState update = 2; GameFinished finished = 3; - PingUpdate ping_update = 4; - ToggleBots toggle_bots = 5; - Ping ping = 6; - BountySelected bounty_selected = 7; + ToggleBots toggle_bots = 4; + BountySelected bounty_selected = 5; } } -message Ping { - int64 timestamp_now = 1; -} - -message PingUpdate { - uint64 latency = 1; -} - message BountySelected { BountyInfo bounty = 1; } @@ -357,15 +347,10 @@ message GameAction { ToggleZone toggle_zone = 6; ToggleBots toggle_bots = 7; ChangeTickrate change_tickrate = 8; - Pong pong = 9; } int64 timestamp = 3; } -message Pong { - int64 ping_timestamp = 1; -} - message Zone { float radius = 1; bool enabled = 2;