Initial connection interface stubs, emit NewConnection signal
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -4,11 +4,12 @@ mod telepathy;
|
||||
use anyhow::{anyhow, Result};
|
||||
use dbus::{
|
||||
blocking::{stdintf::org_freedesktop_dbus::RequestNameReply, LocalConnection},
|
||||
channel::Sender,
|
||||
tree::Factory,
|
||||
};
|
||||
use padfoot::{
|
||||
Connection, ConnectionManager, Protocol, CM_BUS_NAME, CM_CONN_BUS_NAME, CM_OBJECT_PATH,
|
||||
CONN_BUS_NAME, PROTO_BUS_NAME, PROTO_OBJECT_PATH,
|
||||
ConnectionManager, Protocol, CM_BUS_NAME, CM_CONN_BUS_NAME, CM_OBJECT_PATH, CONN_BUS_NAME,
|
||||
PROTO_BUS_NAME, PROTO_OBJECT_PATH,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -30,7 +31,9 @@ impl dbus::tree::DataType for TData {
|
||||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let cm = ConnectionManager::new();
|
||||
let (msg_s, msg_r) = std::sync::mpsc::channel::<dbus::message::Message>();
|
||||
let cm = ConnectionManager::new(Some(msg_s));
|
||||
|
||||
let proto = Protocol {};
|
||||
let data = Arc::new(TData { cm: cm, p: proto });
|
||||
|
||||
@@ -79,7 +82,16 @@ fn run() -> Result<()> {
|
||||
}
|
||||
|
||||
loop {
|
||||
c.process(Duration::from_secs(1))?;
|
||||
c.process(Duration::from_millis(100))?;
|
||||
|
||||
// Spend a bit of time sending any outgoing messages - signals, mostly
|
||||
for msg in msg_r.try_iter().take(10) {
|
||||
print!("Sending message...");
|
||||
match c.send(msg) {
|
||||
Err(e) => println!("error!"),
|
||||
_ => println!("OK!"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user