Fixing
This commit is contained in:
parent
04356f991a
commit
d37d949513
7 changed files with 18 additions and 37 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use base64::encode;
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use futures::{StreamExt, TryFutureExt};
|
||||
use http_body_util::Full;
|
||||
use hyper::body::Bytes;
|
||||
|
|
@ -206,7 +207,7 @@ fn calculate_accept_key(key: &str) -> String {
|
|||
sha1.update(key.as_bytes());
|
||||
sha1.update(websocket_guid.as_bytes());
|
||||
let result = sha1.finalize();
|
||||
encode(result) // Base64 encode the result
|
||||
STANDARD.encode(result) // Base64 encode the result
|
||||
}
|
||||
fn load_tls_config() -> Result<Arc<ServerConfig>, Box<dyn Error>> {
|
||||
// Load certificate file
|
||||
|
|
|
|||
|
|
@ -7,12 +7,7 @@ use futures::stream::SplitStream;
|
|||
use hyper::upgrade::Upgraded;
|
||||
use hyper_util::rt::TokioIo;
|
||||
use std::sync::Arc;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio_util::compat::{Compat, TokioAsyncReadCompatExt};
|
||||
use tungstenite::{
|
||||
Message, Utf8Bytes,
|
||||
handshake::server::{Request, Response},
|
||||
};
|
||||
use tungstenite::Message;
|
||||
|
||||
pub fn handle(
|
||||
path: String,
|
||||
|
|
@ -22,7 +17,9 @@ pub fn handle(
|
|||
tokio::spawn(async move {
|
||||
if path.starts_with("/ws/community/") {
|
||||
let community_id = path.split("/").nth(3).unwrap();
|
||||
log_message(format!("Community: {}", community_id));
|
||||
if let Some(community) = community_manager::get_community(community_id).await {
|
||||
log_message("Connected");
|
||||
let community_conn: Arc<CommunityConnection> =
|
||||
Arc::from(CommunityConnection::new(writer, reader, community));
|
||||
loop {
|
||||
|
|
@ -51,6 +48,7 @@ pub fn handle(
|
|||
return;
|
||||
}
|
||||
None => {
|
||||
log_message("Closed Session me!");
|
||||
community_conn.handle_close().await;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue