pyCraft/networking/PacketSenderManager.py

59 lines
1.1 KiB
Python
Raw 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-07-01 08:36:57 +02:00
DataUtil.sendByte(socket, 73)
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
DataUtil.sendString(socket, reason)