-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataBuffer] Scripting can now use .SendData and .GetDataAndAppend
The bot has been refactored such that the interfaces for sending and receiving packets through the DataBuffer can now be used through scripting in the same way the bot does. API: Buffer.SendData(Socket, [PacketID], [ServerType], [HeaderType]) - By default, this sends the buffer over the socket unchanged. - If the HeaderType supports it, PacketID will be used in a pre-pended header. HeaderType values: 0 = phtNONE: no header 3 = phtMCP: MCP/BNLS-like 3-byte header 4 = phtBNCS: BNCS-like 4-byte header - If ServerType is non-zero, the packet will be logged to your packet log and cache. Buffer.GetDataAndAppend(Socket, Length) - Reads up to Length bytes off the socket as a Byte(). This is locale-independent. - Appends them to the end of Buffer. Packet.GetPacketLength(HeaderLenStart) - Returns an Integer (16-bit value) from position 0, 1, or 2 from the start of the packet. Returns 0 for any other HeaderLenStart. Does not change the value of the Buffer.Position property. For the use of several Battle.net-like binary protocols. Buffer.IsFullPacket(HeaderLenStart) - Returns True if this is a full packet, False if not, if invalid HeaderLenStart, or if empty buffer. Does not change the value of the Buffer.Position property. For the use of several Battle.net-like binary protocols. Buffer.TakePacket(HeaderLenStart) - Returns a new DataBuffer with a completed packet. The DataBuffer is empty if IsFullPacket() would have failed. For the use of several Battle.net-like binary protocols. Suggested usage: ' Example: Data buffering in a script made to connect to vL's BotNet service ' Headers are of the form: ' (UINT8) Protocol version (0x01) ' (UINT8) Packet ID ' (UINT16) Packet length Sub BotNetSock_DataArrival(Length) Dim Packet RecvBuffer.GetDataAndAppend BotNetSock, Length Do While RecvBuffer.IsFullPacket(2) Set Packet = RecvBuffer.TakePacket(2) Call Recv_PacketSwitch(Packet) Set Packet = Nothing Loop End Sub
- Loading branch information
Showing
5 changed files
with
92 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters