some changes blob
This commit is contained in:
parent
e2cc99dfb7
commit
d39ee60729
4 changed files with 66 additions and 91 deletions
|
@ -7,34 +7,27 @@ use rust_mc_proto::{Packet, ProtocolError, MCConnTcp, DataBufferReader, DataBuff
|
|||
|
||||
*/
|
||||
|
||||
fn send_handshake(conn: &mut MCConnTcp,
|
||||
protocol_version: u16,
|
||||
server_address: &str,
|
||||
server_port: u16,
|
||||
next_state: u8) -> Result<(), ProtocolError> {
|
||||
let mut packet = Packet::empty(0x00);
|
||||
|
||||
packet.write_u16_varint(protocol_version)?;
|
||||
packet.write_string(server_address)?;
|
||||
packet.write_unsigned_short(server_port)?;
|
||||
packet.write_u8_varint(next_state)?;
|
||||
|
||||
conn.write_packet(&packet)?;
|
||||
|
||||
Ok(())
|
||||
fn send_handshake(
|
||||
conn: &mut MCConnTcp,
|
||||
protocol_version: u16,
|
||||
server_address: &str,
|
||||
server_port: u16,
|
||||
next_state: u8
|
||||
) -> Result<(), ProtocolError> {
|
||||
conn.write_packet(&Packet::build(0x00, |packet| {
|
||||
packet.write_u16_varint(protocol_version)?;
|
||||
packet.write_string(server_address)?;
|
||||
packet.write_unsigned_short(server_port)?;
|
||||
packet.write_u8_varint(next_state)
|
||||
})?)
|
||||
}
|
||||
|
||||
fn send_status_request(conn: &mut MCConnTcp) -> Result<(), ProtocolError> {
|
||||
let packet = Packet::empty(0x00);
|
||||
conn.write_packet(&packet)?;
|
||||
|
||||
Ok(())
|
||||
conn.write_packet(&Packet::empty(0x00))
|
||||
}
|
||||
|
||||
fn read_status_response(conn: &mut MCConnTcp) -> Result<String, ProtocolError> {
|
||||
let mut packet = conn.read_packet()?;
|
||||
|
||||
packet.read_string()
|
||||
conn.read_packet()?.read_string()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue