Send new handshake on reconnect
This commit is contained in:
parent
809bad5ff5
commit
fe9ca39736
|
@ -79,7 +79,15 @@ pub trait Listener {
|
|||
Err(e) => {
|
||||
println!("Received error {:} when decoding message. Pausing for 5 seconds then reconnecting.", e);
|
||||
timer::sleep(5000);
|
||||
sock.reconnect();
|
||||
// Reconnect
|
||||
sock.reconnect()
|
||||
// Create version message
|
||||
.and_then(|_| sock.version_message(0))
|
||||
// Send it out
|
||||
.and_then(|msg| sock.send_message(msg))
|
||||
// For now, not much we can do on error
|
||||
.unwrap_or_else(|e| println!("Error {} when reconnecting.", e));
|
||||
handshake_complete = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,9 +283,9 @@ impl Serializable for VarInt {
|
|||
fn serialize(&self) -> Vec<u8> {
|
||||
match *self {
|
||||
VarU8(n) => Vec::from_slice(&[n]),
|
||||
VarU16(n) => { let mut rv = n.serialize(); rv.unshift(0xFD); rv },
|
||||
VarU32(n) => { let mut rv = n.serialize(); rv.unshift(0xFE); rv },
|
||||
VarU64(n) => { let mut rv = n.serialize(); rv.unshift(0xFF); rv },
|
||||
VarU16(n) => { let mut rv = n.serialize(); rv.insert(0, 0xFD); rv },
|
||||
VarU32(n) => { let mut rv = n.serialize(); rv.insert(0, 0xFE); rv },
|
||||
VarU64(n) => { let mut rv = n.serialize(); rv.insert(0, 0xFF); rv },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue