Poked around a bit, broke It kinda :)
I fixed some issues, but broke more :)
This commit is contained in:
parent
f206d6172d
commit
68e1ec5460
2 changed files with 6 additions and 12 deletions
|
@ -52,26 +52,23 @@ impl MyApp {
|
||||||
let score_arc = Arc::clone(&self.score);
|
let score_arc = Arc::clone(&self.score);
|
||||||
let x = self.x;
|
let x = self.x;
|
||||||
let upgd_cost = self.upgd_cost;
|
let upgd_cost = self.upgd_cost;
|
||||||
|
let tx = network();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
println!("Send help send help send help Yasmina's holding me hostageeeeee");
|
println!("Send help send help send help Yasmina's holding me hostageeeeee");
|
||||||
thread::sleep(Duration::from_secs(1));
|
thread::sleep(Duration::from_secs(1));
|
||||||
network();
|
network();
|
||||||
let tx = network();
|
// let tx = network();
|
||||||
let current_score = {
|
let current_score = {
|
||||||
let guard = score_arc.lock().unwrap();
|
let guard = score_arc.lock().unwrap();
|
||||||
*guard
|
*guard
|
||||||
};
|
};
|
||||||
|
|
||||||
send_score(tx, x, upgd_cost, current_score);
|
send_score(tx.clone(), x, upgd_cost, current_score);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
pub mod networking {
|
|
||||||
|
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::net::UdpSocket;
|
use std::net::UdpSocket;
|
||||||
|
@ -13,8 +11,8 @@ pub fn network() -> Sender<Vec<i64>> {
|
||||||
let tx: Sender<Vec<i64>> = tx.clone();
|
let tx: Sender<Vec<i64>> = tx.clone();
|
||||||
|
|
||||||
thread::spawn( move || {
|
thread::spawn( move || {
|
||||||
let mut net_active = true;
|
let mut net_active = 1;
|
||||||
while net_active {
|
while net_active == 1 {
|
||||||
let server_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
let server_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||||
let target = "100.127.105.90:4000";
|
let target = "100.127.105.90:4000";
|
||||||
let dat = rx.recv().unwrap();
|
let dat = rx.recv().unwrap();
|
||||||
|
@ -27,7 +25,7 @@ pub fn network() -> Sender<Vec<i64>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if dat[0] == 0 { // code 0, kills thread
|
if dat[0] == 0 { // code 0, kills thread
|
||||||
net_active = false;
|
net_active = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
if dat[0] == 1 {
|
if dat[0] == 1 {
|
||||||
|
@ -74,5 +72,4 @@ pub fn debug(tx: Sender<Vec<i64>>) -> Sender<Vec<i64>> {
|
||||||
tx
|
tx
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue