Slow Connections
This commit is contained in:
parent
9729fb0c09
commit
db419d3b47
2 changed files with 11 additions and 9 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -5,8 +5,6 @@ mod omega;
|
||||||
mod rho;
|
mod rho;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
use ansi_term::Color;
|
|
||||||
use crossterm::style::PrintStyledContent;
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
@ -21,13 +19,14 @@ use crate::{
|
||||||
util::print::line_err,
|
util::print::line_err,
|
||||||
util::print::print_start_message,
|
util::print::print_start_message,
|
||||||
};
|
};
|
||||||
#[tokio::main]
|
|
||||||
|
|
||||||
|
#[tokio::main(flavor = "multi_thread", worker_threads = 32)]
|
||||||
|
#[allow(unused_must_uscae, dead_code)]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
print_start_message();
|
print_start_message();
|
||||||
|
tokio::spawn(async move {
|
||||||
OmegaConnection::new().connect().await;
|
OmegaConnection::new().connect().await;
|
||||||
|
});
|
||||||
let listener = TcpListener::bind("0.0.0.0:959").await.unwrap();
|
let listener = TcpListener::bind("0.0.0.0:959").await.unwrap();
|
||||||
line(
|
line(
|
||||||
PrintType::OmegaIn,
|
PrintType::OmegaIn,
|
||||||
|
|
@ -64,8 +63,9 @@ async fn main() {
|
||||||
match msg_result {
|
match msg_result {
|
||||||
Some(Ok(msg)) => {
|
Some(Ok(msg)) => {
|
||||||
if msg.is_text() {
|
if msg.is_text() {
|
||||||
let text = msg.into_text().unwrap();
|
let text = msg.into_text();
|
||||||
client_conn.clone().handle_message(text).await;
|
let cc = client_conn.clone();
|
||||||
|
cc.handle_message(text.unwrap()).await;
|
||||||
} else if msg.is_close() {
|
} else if msg.is_close() {
|
||||||
line(PrintType::ClientIn, "Client disconnected");
|
line(PrintType::ClientIn, "Client disconnected");
|
||||||
client_conn.handle_close().await;
|
client_conn.handle_close().await;
|
||||||
|
|
@ -97,7 +97,8 @@ async fn main() {
|
||||||
Some(Ok(msg)) => {
|
Some(Ok(msg)) => {
|
||||||
if msg.is_text() {
|
if msg.is_text() {
|
||||||
let text = msg.into_text().unwrap();
|
let text = msg.into_text().unwrap();
|
||||||
iota_conn.clone().handle_message(text).await;
|
let ic = iota_conn.clone();
|
||||||
|
ic.handle_message(text).await;
|
||||||
} else if msg.is_close() {
|
} else if msg.is_close() {
|
||||||
line(PrintType::IotaIn, "Iota disconnected");
|
line(PrintType::IotaIn, "Iota disconnected");
|
||||||
iota_conn.handle_close().await;
|
iota_conn.handle_close().await;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use dashmap::DashMap;
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use tokio::io::unix::AsyncFd;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
|
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue