net: create session() function that returns an Arc pointer to session

This commit is contained in:
lunar-mining
2022-07-02 13:29:55 +02:00
parent 967f9ec770
commit 2f6909ab6a
2 changed files with 7 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ use crate::{
use super::{
message,
message_subscriber::{MessageSubscription, MessageSubsystem},
SessionWeakPtr, TransportStream,
Session, SessionWeakPtr, TransportStream,
};
/// Atomic pointer to async channel.
@@ -104,10 +104,6 @@ impl Channel {
self.info.lock().await.get_info().await
}
//async fn session_type_id(&self) -> Result<()> {
// //
//}
/// Starts the channel. Runs a receive loop to start receiving messages or
/// handles a network failure.
pub fn start(self: Arc<Self>, executor: Arc<Executor<'_>>) {
@@ -327,4 +323,8 @@ impl Channel {
}
debug!(target: "net", "Channel::handle_stop() [END, address={}]", self.address());
}
fn session(&self) -> Arc<dyn Session> {
self.session.upgrade().unwrap()
}
}

View File

@@ -97,7 +97,8 @@ pub use message_subscriber::MessageSubscription;
pub use p2p::{P2p, P2pPtr};
pub use protocol::{ProtocolBase, ProtocolBasePtr, ProtocolJobsManager, ProtocolJobsManagerPtr};
pub use session::{
SessionWeakPtr, SESSION_ALL, SESSION_INBOUND, SESSION_MANUAL, SESSION_OUTBOUND, SESSION_SEED,
Session, SessionWeakPtr, SESSION_ALL, SESSION_INBOUND, SESSION_MANUAL, SESSION_OUTBOUND,
SESSION_SEED,
};
pub use settings::{Settings, SettingsPtr};
pub use transport::{