-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use other protobufs? #14
Comments
You have to use the steam-vent-proto-build path/to/protos path/to/output/sources The output structs from that should work directly without any further work. |
I see, thanks! I cloned the repo locally and generated For example This example using |
For GC messages you can create a |
Right, I'm modelling it after the backpack example... however in the backpack example, the messages being sent still implement use steam_vent::{
auth::{
AuthConfirmationHandler as _, ConsoleAuthConfirmationHandler, DeviceConfirmationHandler,
FileGuardDataStore,
},
proto::deadlock::citadel_gcmessages_client::CMsgClientToGCSpectateLobby,
Connection, ConnectionTrait, GameCoordinator, ServerList,
};
// pub struct
pub async fn run() -> anyhow::Result<()> {
let username = std::env::var("STEAM_USERNAME").expect("STEAM_USERNAME env var must be set");
let password = std::env::var("STEAM_PASSWORD").expect("STEAM_PASSWORD env var must be set");
let server_list = ServerList::discover().await?;
let connection = Connection::login(
&server_list,
&username,
&password,
FileGuardDataStore::user_cache(),
ConsoleAuthConfirmationHandler::default().or(DeviceConfirmationHandler),
)
.await?;
println!("starting game coordinator");
let game_coordinator = GameCoordinator::new(&connection, 1422450).await?;
let spectate_message = CMsgClientToGCSpectateLobby {
lobby_id: Some(101038497616221460),
..Default::default()
};
let res = game_coordinator.job(spectate_message).await?;
Ok(())
}
pub fn run_sync() -> anyhow::Result<()> {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(run())
} |
Looks like the logic for matching the protobuf structs to the type/kind isn't working for (all of) the deadlock structs. I'll see about better supporting messages that don't have the kind mapped. You can manually set the mapping by implementing |
Ah ok, makes sense, thanks! |
So, implementing this workaround manually in the crate was pretty easy: mod generated;
pub use generated::*;
use steam_vent_proto_common::{MsgKindEnum, RpcMessageWithKind};
use crate::citadel_gcmessages_client::EGCCitadelClientMessages;
impl MsgKindEnum for EGCCitadelClientMessages {}
impl RpcMessageWithKind for generated::citadel_gcmessages_client::CMsgClientToGCSpectateLobby {
type KindEnum = EGCCitadelClientMessages;
const KIND: Self::KindEnum = EGCCitadelClientMessages::k_EMsgClientToGCSpectateLobby;
}
impl RpcMessageWithKind
for generated::citadel_gcmessages_client::CMsgClientToGCSpectateLobbyResponse
{
type KindEnum = EGCCitadelClientMessages;
const KIND: Self::KindEnum = EGCCitadelClientMessages::k_EMsgClientToGCSpectateLobbyResponse;
} However, before that I tried to implement it using the NewType pattern in my crate because these are all foreign types... which was basically impossible given all the traits needed to be implement. Just for the future, it might be worth implementing some "bailout" methods that can just accept the raw stuff needed, kind of like the |
Thanks for the feedback |
@icewind1991 I managed to get the diff --git a/protobuf/build/src/main.rs b/protobuf/build/src/main.rs
index 22df538..00fa3c4 100644
--- a/protobuf/build/src/main.rs
+++ b/protobuf/build/src/main.rs
@@ -338,8 +338,10 @@ impl CustomizeCallback for ServiceGenerator {
let kind_enums: Vec<_> = file
.enums()
.filter_map(|enum_type| {
- (enum_type.name().starts_with("E") && enum_type.name().ends_with("Msg"))
- .then(|| enum_type.name().to_string())
+ (enum_type.name().starts_with("E")
+ && (enum_type.name().ends_with("Msg")
+ || enum_type.name().ends_with("Messages")))
+ .then(|| enum_type.name().to_string())
})
.collect();
@@ -423,7 +425,10 @@ fn get_kinds(base: &Path, protos: &[PathBuf]) -> Vec<Kind> {
.iter_mut()
.map(move |e| (mod_name.clone(), e))
})
- .filter(|(_, e)| e.name().starts_with("E") && e.name().ends_with("Msg"));
+ .filter(|(_, e)| {
+ e.name().starts_with("E")
+ && (e.name().ends_with("Msg") || e.name().ends_with("Messages"))
+ });
let mut kinds = kinds_enums
.flat_map(|(mod_name, kinds_enum)| {
@@ -436,14 +441,17 @@ fn get_kinds(base: &Path, protos: &[PathBuf]) -> Vec<Kind> {
let prefix = prefix[0..prefix.len() - 1].to_string();
let variant_prefix = format!("k_EMsg{}", prefix);
let variant_prefix_alt = format!("k_E{}Msg_", prefix);
+ let variant_prefix_alt2 = "k_EMsg".to_string();
let enum_prefix = prefix.to_ascii_lowercase();
let enum_name = kinds_enum.take_name();
+
kinds_enum.value.iter_mut().map(move |opt| Kind {
mod_name: mod_name.clone(),
enum_name: enum_name.clone(),
enum_prefix: enum_prefix.clone(),
variant_prefix: variant_prefix.clone(),
variant_prefix_alt: variant_prefix_alt.clone(),
+ variant_prefix_alt2: variant_prefix_alt2.clone(),
variant: opt.take_name(),
struct_name_prefix_alt_len: prefix.len(),
})
@@ -462,6 +470,7 @@ struct Kind {
enum_prefix: String,
variant_prefix: String,
variant_prefix_alt: String,
+ variant_prefix_alt2: String,
variant: String,
struct_name_prefix_alt_len: usize,
}
@@ -474,6 +483,7 @@ impl Kind {
.variant
.strip_prefix(&self.variant_prefix)
.or_else(|| self.variant.strip_prefix(&self.variant_prefix_alt))
+ .or_else(|| self.variant.strip_prefix(&self.variant_prefix_alt2))
else {
return false;
}; The two main issues are:
I hope this helps fix in a more robust way 🙏 I'm not sure if it's related, but I haven't been able to use let res = game_coordinator
.job::<CMsgClientToGCSpectateLobby, CMsgClientToGCSpectateLobbyResponse>(
spectate_message,
)
.await?; always times out, despite the fact I see both the |
3fa7376 allows sending types implementing |
Merged the protobuf builder changes with 2874fce thanks for the patch. |
Does the response have the job id set correctly? Can you show the relevant log lines from running with |
I tracked down the issue - https://github.com/icewind1991/steam-vent/blob/main/src/connection/mod.rs#L397 Specifically Adding logging there, I noticed the source job id was like EDIT: I think it's something else actually? This seems to just be working coincidentally as its the hardcoded NONE job id... when there are no other messages potentially interfering concurrently it works, but I imagine it'll break easily. |
Ok, I think I actually identified the issue - it's this function: https://github.com/icewind1991/steam-vent/blob/main/src/game_coordinator.rs#L165-L188 Specifically, the
with
then it all seems to work. The job id gets properly sent, and the server responds in kind. This is also consistent with the behavior of node-steam-user afaict, which is what I've been comparing against to debug this. |
Can you try it with msg.process_header(&mut nested_header); before the |
That doesn't seem to change anything in this case |
As noted in the readme, this project should be able to work with other protobufs not generated from steam-vent... it would be great to have an example :) E.g I don't know if I'm supposed to wrap my own protobuf-encoded body with something like a
CMsgProtobufWrapped
... it could make sense, but I'm not sure. My protobufs are currently generated with Prost.The text was updated successfully, but these errors were encountered: