added ability to read VarInt off socket
This commit is contained in:
parent
e8d27ca4b7
commit
5b00b69216
1 changed files with 9 additions and 0 deletions
|
@ -62,6 +62,15 @@ class VarInt(Type):
|
||||||
_pytype : type = int
|
_pytype : type = int
|
||||||
_maxBytes = 5
|
_maxBytes = 5
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
async def read(cls, stream: asyncio.StreamReader) -> int:
|
||||||
|
buf = 0b10000000
|
||||||
|
off = 0
|
||||||
|
while (buf & 0b0000000) != 0:
|
||||||
|
buf |= (await stream.read(1)) >> (7*off)
|
||||||
|
off += 1
|
||||||
|
return buf
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def serialize(cls, data:int) -> bytes:
|
def serialize(cls, data:int) -> bytes:
|
||||||
res : bytearray = bytearray()
|
res : bytearray = bytearray()
|
||||||
|
|
Loading…
Reference in a new issue