pyCraft/networking/PacketSenderManager.py

94 lines
1.9 KiB
Python
Raw Permalink Normal View History

import DataUtil
2012-04-15 18:49:47 +02:00
def send00(socket, KAid):
#packet id
socket.send("\x00")
2012-12-25 21:38:02 +01:00
#int - keep alive id
DataUtil.sendInt(socket, KAid)
2012-12-25 21:38:02 +01:00
def sendHandshake(socket, username, host, port):
#packet id
socket.send("\x02")
2012-12-25 21:38:02 +01:00
#byte - protocol version
2013-09-22 17:50:38 +02:00
DataUtil.sendByte(socket, 78)
2012-12-25 21:38:02 +01:00
#string - username
DataUtil.sendString(socket, username)
2012-12-25 21:38:02 +01:00
#string - server host
DataUtil.sendString(socket, host)
2012-12-25 21:38:02 +01:00
#int - server port
DataUtil.sendInt(socket, port)
2012-12-25 21:38:02 +01:00
2012-04-15 18:49:47 +02:00
def send03(socket, message):
#packet id
2012-04-15 18:49:47 +02:00
socket.send("\x03")
2012-12-25 21:38:02 +01:00
#-----string - message-----#
DataUtil.sendString(socket, message)
2012-12-25 21:38:02 +01:00
def sendCD(socket, payload):
#packet id
socket.send("\xCD")
2012-12-25 21:38:02 +01:00
#payload - byte
DataUtil.sendByte(socket, payload)
2012-12-25 21:38:02 +01:00
def sendFC(socket, secret, token):
#packet id
socket.send("\xFC")
2012-12-25 21:38:02 +01:00
#shared secret
DataUtil.sendShort(socket, secret.__len__()) #length
socket.send(secret)
2012-12-25 21:38:02 +01:00
#token
DataUtil.sendShort(socket, token.__len__())
socket.send(token)
2012-12-25 21:38:02 +01:00
def sendFF(socket, reason):
#string - disconnect reason
2013-07-24 18:02:17 +02:00
DataUtil.sendString(socket, reason)
#====
def send0B(socket, x, y, z, stance, onGround):
#packet id
socket.send("\x0B")
DataUtil.sendDouble(socket, x)
DataUtil.sendDouble(socket, y)
DataUtil.sendDouble(socket, stance)
DataUtil.sendDouble(socket, z)
DataUtil.sendBoolean(socket, onGround)
def send0D(socket, x, y, z, stance, yaw, pitch, onGround):
#packet id
socket.send("\x0D")
DataUtil.sendDouble(socket, x)
DataUtil.sendDouble(socket, y)
DataUtil.sendDouble(socket, stance)
DataUtil.sendDouble(socket, z)
DataUtil.sendFloat(socket, yaw)
DataUtil.sendFloat(socket, pitch)
DataUtil.sendBoolean(socket, onGround)
def sendCA(socket, flags, flySpeed, walkSpeed):
#packet id
socket.send("\xCA")
DataUtil.sendByte(socket, flags)
DataUtil.sendFloat(socket, flySpeed)
DataUtil.sendFloat(socket, walkSpeed)