pub type StartupMessageCallback = Box<dyn Fn(ResponseMessage) + Send + Sync>;Expand description
Callback for handling unsolicited messages during connection setup.
When TWS sends messages like OpenOrder or OrderStatus during the connection
handshake, this callback is invoked to allow the application to process them
instead of discarding them.
§Example
ⓘ
use ibapi::{Client, StartupMessageCallback};
use ibapi::messages::IncomingMessages;
use std::sync::{Arc, Mutex};
#[tokio::main]
async fn main() {
let orders = Arc::new(Mutex::new(Vec::new()));
let orders_clone = orders.clone();
let callback: StartupMessageCallback = Box::new(move |msg| {
match msg.message_type() {
IncomingMessages::OpenOrder | IncomingMessages::OrderStatus => {
orders_clone.lock().unwrap().push(msg);
}
_ => {}
}
});
let client = Client::connect_with_callback("127.0.0.1:4002", 100, Some(callback))
.await
.expect("connection failed");
println!("Received {} startup orders", orders.lock().unwrap().len());
}Callback for handling unsolicited messages during connection setup.
When TWS sends messages like OpenOrder or OrderStatus during the connection
handshake, this callback is invoked to allow the application to process them
instead of discarding them.
Aliased Type§
pub struct StartupMessageCallback(/* private fields */);