diff --git a/CHANGELOG.md b/CHANGELOG.md index be50302..1439dad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Request uses `dcs.common.v0.ObjectCategory[]` and `SearchVolume` (with `InputPosition` for geo points). - Response returns `dcs.common.v0.Target[]` for consistent object union across services. - Lua implementation unwraps grpcui oneof wrapper (`volume.shape`) and supports both wrapped and flattened shapes. +- Added `coalition`, `player_name`, and `to_all` fields to `PlayerSendChatEvent`. ## [0.8.1] 2024-11-05 diff --git a/lua/DCS-gRPC/grpc-hook.lua b/lua/DCS-gRPC/grpc-hook.lua index 419a7f4..0295c64 100644 --- a/lua/DCS-gRPC/grpc-hook.lua +++ b/lua/DCS-gRPC/grpc-hook.lua @@ -45,19 +45,29 @@ end -- None of these methods should return anything as doing so breaks other scripts attempting to -- react to the hook as well. -function handler.onPlayerTrySendChat(playerID, msg) +function handler.onPlayerTrySendChat(playerID, msg, all) -- note: currently `all` (third parameter) will always `=true` regardless if the target is to the coalition/team -- or to everybody. When ED fixes this, implementation should determine the dcs.common.v0.Coalition - + local playerInfo = net.get_player_info(playerID) + local coalition, playerName + if playerInfo ~= nil then + coalition = net.get_player_info(playerID, "side") + playerName = net.get_player_info(playerID, "name") + end + local toAll = true + if coalition ~= nil then coalition = coalition + 1 end + if all == -2 then toAll = false end grpc.event({ time = DCS.getModelTime(), event = { type = "playerSendChat", playerId = playerID, - message = msg + message = msg, + coalition = coalition, + playerName = playerName, + toAll = toAll }, }) - end function handler.onPlayerTryConnect(addr, name, ucid, id) diff --git a/protos/dcs/mission/v0/mission.proto b/protos/dcs/mission/v0/mission.proto index 11ed890..beada7c 100644 --- a/protos/dcs/mission/v0/mission.proto +++ b/protos/dcs/mission/v0/mission.proto @@ -387,6 +387,12 @@ message StreamEventsResponse { uint32 player_id = 1; // what was typed string message = 2; + // player's coalition + dcs.common.v0.Coalition coalition = 3; + // player's name + string player_name = 4; + // sent to all chat + bool to_all = 5; } // fired when the player changes across to a slot diff --git a/src/authentication.rs b/src/authentication.rs index 5c37db9..66299b4 100644 --- a/src/authentication.rs +++ b/src/authentication.rs @@ -26,11 +26,12 @@ impl RequestInterceptor for AuthInterceptor { } } - if client.is_some() { - log::debug!("Authenticated client: {}", client.unwrap()); - Ok(req) - } else { - Err(Status::unauthenticated("Unauthenticated")) + match client { + Some(client_name) => { + log::debug!("Authenticated client: {}", client_name); + Ok(req) + } + _ => Err(Status::unauthenticated("Unauthenticated")), } } _ => Err(Status::unauthenticated("Unauthenticated")), diff --git a/src/rpc/custom.rs b/src/rpc/custom.rs index 336c3a6..1acfe7a 100644 --- a/src/rpc/custom.rs +++ b/src/rpc/custom.rs @@ -52,6 +52,7 @@ impl CustomService for MissionRpc { Ok(Response::new(custom::v0::EvalResponse { json })) } + #[allow(clippy::result_large_err)] async fn get_magnetic_declination( &self, request: Request,