Handshake!

This commit is contained in:
Gregor Reitzenstein 2020-11-20 15:55:04 +01:00
parent f561cc7df1
commit d46bdbbab5
2 changed files with 4 additions and 3 deletions

View File

@ -45,7 +45,7 @@ pub fn bootstrap(log: Logger, stream: TcpStream) -> (RpcSystem<Side>, API) {
return (rpc, API::new(log, client)); return (rpc, API::new(log, client));
} }
async fn handshake(log: &Logger, mut stream: &mut TcpStream) -> Result<(), io::Error> { pub async fn handshake(log: &Logger, mut stream: &mut TcpStream) -> Result<(), io::Error> {
let host = "localhost"; let host = "localhost";
let program = format!("{}-{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")); let program = format!("{}-{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
let version = (0u32,1u32); let version = (0u32,1u32);

View File

@ -9,7 +9,7 @@ use smol::net::AsyncToSocketAddrs;
use slog::Logger; use slog::Logger;
use crate::schema::{bootstrap, API, Authentication}; use crate::schema::{handshake, bootstrap, API, Authentication};
pub struct Session { pub struct Session {
pub bootstrap: API, pub bootstrap: API,
@ -19,7 +19,8 @@ pub struct Session {
impl Session { impl Session {
pub async fn connect<A: AsyncToSocketAddrs>(log: Logger, addr: A) -> Result<Session> { pub async fn connect<A: AsyncToSocketAddrs>(log: Logger, addr: A) -> Result<Session> {
let stream = TcpStream::connect(addr).await?; let mut stream = TcpStream::connect(addr).await?;
handshake(&log, &mut stream).await;
let (rpc_system, api) = bootstrap(log, stream); let (rpc_system, api) = bootstrap(log, stream);
Ok(Session { Ok(Session {