Skip to content

Commit

Permalink
fix shit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrecknt committed Jan 14, 2024
1 parent debe2b6 commit a282691
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ use snowstorm::{
};
use std::{
collections::LinkedList,
sync::{mpsc::channel, Arc},
sync::{
mpsc::{channel, Sender},
Arc,
},
thread,
time::{Duration, Instant},
};
use tokio::sync::Mutex;
use tokio::{runtime::Runtime, sync::Mutex};

#[tokio::main]
async fn main() -> eyre::Result<()> {
Expand Down Expand Up @@ -73,14 +77,18 @@ async fn main() -> eyre::Result<()> {
const CHANNEL_COUNT: usize = 8;

let ping_handlers = {
let mut handlers = Vec::with_capacity(CHANNEL_COUNT);
let mut handlers: Vec<Sender<_>> = Vec::with_capacity(CHANNEL_COUNT);
for _ in 0..CHANNEL_COUNT {
let db = db.clone();
let (w, r) = channel::<(PingResult, Vec<PlayerInfo>)>();
handlers.push(w);
tokio::spawn(async move {
thread::spawn(move || {
let r = r;
while let Ok(mut values) = r.recv() {
values.push(&db.pool).await.unwrap();
Runtime::new()
.unwrap()
.block_on(values.push(&db.pool))
.unwrap();
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions web/src/routes/admin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
});
ws.addEventListener('message', (message) => {
const obj = JSON.parse(message.data) as ActionResponse;
if (!obj.success) {
console.log('An error occurred!', obj.msg);
return;
}
if (obj.queue) {
let queueItems: { type: string; duration: Duration }[] = [];
for (let item of obj.queue) {
Expand Down

0 comments on commit a282691

Please sign in to comment.