-
Notifications
You must be signed in to change notification settings - Fork 2
BNCS Client
David edited this page Oct 5, 2018
·
1 revision
-
BncsClient()- creates a new BNCS client
-
connect(host, [port])- connects to the specified host and port (default port is 6112) -
disconnect()- disconnects the client -
send_packet(id, payload)- sends a packet with the given ID and payload -
wait_for_packet(id, [timeout])- blocks until a packet with the given ID is received, or the timeout is exceeded- Returns the received packet as a DataReader object
-
authenticate(product, [keys], [owner], [bnls server])- authenticates as the specified product- For products requiring CD keys, 'keys' should be a list of the keys as strings
- 'Owner' is the name displayed if someone tries to login with your key while you're using it.
- 'bnls server' is the server to use for performing the authentication. Default is jbls.davnit.net
- Returns True/False and a message explaining the result
-
login(username, password)- logs into an account- Returns True/False and a message explaining the result
-
create_account(username, password)- attempts to create an account- Returns True/False and a message explaining the result
-
enter_chat()- enters the chat environment and joins the default channel -
leave_chat()- leaves the chat environment without disconnecting from the server -
chat_command(text)- sends a chat command to the server
-
connected()- returns TRUE if the client is connected to a server -
verified()- returns TRUE if the server has been verified as an official Blizzard server -
authenticated()- returns TRUE if the client has authenticated with the server (passed version check) -
logged_on()- returns TRUE if the client has logged into an account -
in_chat()- returns TRUE if the client is in the chat environment -
get_username()- returns the client's active username- This may be different from the name used to login
-
packet_handlers- a map of packet ID's to handler functions (see below)
The client can be extended with custom packet handling by adding packet ID's to the packet_handlers property and assigning a function the them.
- The function should have 2 arguments:
packet_idandpayload. - 'packet_id' will be the byte ID of the packet received (useful if multiple packets can be handled by the same handler function)
- 'payload' is the DataReader object containing the packet's data (with the read position at the start of the payload).
def _handle_message_box(packet_id, payload):
payload.get_dword()
text = payload.get_string()
caption = payload.get_string()
print("MSG - %s: %s" % (caption, text))
client = BncsClient()
client.packet_handlers[SID_MESSAGEBOX] = _handle_message_boxA sample program implementing this client can be found here: https://github.com/Davnit/bncs.py/blob/master/scripts/bncs_client.py