|
|
@ -102,8 +102,12 @@ impl Shared { |
|
|
|
{
|
|
|
|
let client = self.clients.get_mut(addr).unwrap();
|
|
|
|
client.partner = None;
|
|
|
|
client.send_status("Waiting for another person...".to_owned()).unwrap();
|
|
|
|
if client.send_status("Waiting for another person...".to_owned()).is_err() {
|
|
|
|
// we aren't valid
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match self.single {
|
|
|
|
Some(x) => {
|
|
|
|
if x == *addr { return; } // don't match with ourselves
|
|
|
@ -113,13 +117,20 @@ impl Shared { |
|
|
|
{
|
|
|
|
let client = self.clients.get_mut(addr).unwrap();
|
|
|
|
client.partner = Some(x);
|
|
|
|
client.send_success(format!("You are now connected to {}.", their_username)).unwrap();
|
|
|
|
if client.send_success(format!("You are now connected to {}.", their_username)).is_err() {
|
|
|
|
// we aren't valid
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
let partner = self.clients.get_mut(&x).unwrap();
|
|
|
|
partner.partner = Some(*addr);
|
|
|
|
partner.send_success(format!("You are now connected to {}.", our_username)).unwrap();
|
|
|
|
if partner.send_success(format!("You are now connected to {}.", our_username)).is_err() {
|
|
|
|
// they aren't valid
|
|
|
|
self.single = Some(addr.to_owned());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self.single = None;
|
|
|
|