[ the jinxbot project :: home | community forum | bn# | controls | mbncsutil | get the source ]

[This is preliminary documentation and is subject to change.]

BN# is a utility library designed to simplify the creation of Battle.net client applications by abstracting away the underlying connection protocols and allowing the user to worry about implementing client functionality. BN# can be as simple as you need, by dropping it into your project and creating settings for it to use, or it can be incredibly flexible, allowing custom packet handling, parsing priorities, and assigning priorities to event handlers. It uses a sophisticated threading model under the hood to allow peak performance without forcing the user to handle that directly.

BN# has a series of optimizations in place. To prevent heap fragmentation, data buffers are preallocated at fixed sizes and are reused over the lifetime of the application, allowing these buffers to not be garbage-collected until the the clients using them are closed.

For more information about getting started with BN#, take a look at the JinxBot Wiki, including the article How to develop a Battle.net client in 10 minutes.

Release Notes - BN# Beta 2

New Features

  • Support for Warden has been partially implemented in the BNSharp.MBNCSUtil namespace in the class WardenEncryptionContext. The end-user is still required to implement the IWardenModule interface. However, developing the implementation should be significantly improved. This contribution was a joint effort by Warrior[x86] and MyndFyre.
  • Several changes that were related to Warden have been implemented and rolled into the BattleNetClient class. These issues did not necessarily prevent correct implementation of Warden, but they did not follow the documentation and were corrected in this release.
  • Corrected an issue that caused an exception on the parsing thread during friend updates on Starcraft and Brood War.

What's coming for Beta 3

  • Support for Warcraft III profiles and clan information lookups.
  • Built-in support for ad messages.
  • Support for setting e-mail interactively during login.
  • Sanity checking for passing the IBattleNetSettings interface.
  • The ability to change the server on ConnectionBase without reinstantiating the class.
  • Binary Join Channel command function.
  • Support for chat message throttling via the ICommandQueueProvider interface.
  • All remaining internal connection status strings will be removed into the localizable file format.

Release Notes - BN# Beta 1

New Features

  • Most appropriate classes has have WCF attributes applied to them and can be serialized with a DataContractSerializer.
  • Added the ability to request user profiles.
  • Friends support was added in this release
  • BN# exposes a new event called EventExceptionThrown. The purpose of this event is to allow a host application to know when a specific plugin or feature set is causing an error and handle it gracefully. JinxBot will handle this condition, for example, by allowing the user to unload plugins on-demand if they are causing many exceptions.
  • Additional clan support was added; BN# now understands and supports events for clan functions such as formation, chieftan change, new formation searching, and disband. Corresponding new functions include BeginClanCandidateSearch, InviteUsersToNewClan, RespondToNewClanInvitation, DisbandClan, and DesignateClanChieftan. Corresponding new events include ClanCandidatesSearchCompleted, ClanFormationCompleted, ClanFormationInvitationReceived, ClanDisbandCompleted, ClanInvitationReceived, ClanInvitationResponseReceived, ClanRemovalResponse, LeftClan, and ClanChangeChieftanCompleted.
  • A new interface is supported for the ordering of packet parsing priority. This would allow, for example, a moderation plugin to require that ChatEvent packets are processed first (to receive UserJoined events). To support this functionality, implement the IPacketPriorityProvider interface in the BNSharp.Plugins namespace, and call BattleNetClient.RegisterCustomPacketPriorities/UnregisterCustomPacketPriorities.
  • A demonstration project of a JinxBot plugin for adding MCP (Realm Server) support to BN# is available in the repository. It obeys some JinxBot contracts, but extends BN# to include handling for realm servers.
  • A new method was added to BattleNetClient called CreateAccount. If the login process fails, you can attempt to create the account by calling CreateAccount; it will use the information provided in the Settings object (this information can be changed dynamically at run-time). CreateAccount will result in the AccountCreated or AccountCreationFailed events to be raised; if AccountCreated is raised, the client will automatically log in.
  • The client no longer automatically disconnects because of an account login failure. (CD key or versioning failure still results in an automatic disconnect).
  • To support the no auto-disconnect policy, a new method was added to BattleNetClient called ContinueLogin(). This method allows the user to change the Settings object to modify the username and password of the desired login and then begin logging in again.

Breaking Changes

  • By default, BNSharp requires support for .NET 3.0 because it references System.Runtime.Serialization version 3.0.0.0. For details on compiling without support for WCF data contract serialization, see the article Compiling BN# for .NET 2.0.
  • IBattleNetSettings now requires a new property, PingType, which allows the connection to attempt to drive a 0ms, -1ms, or standard ping type. Old code will need to add this property to the IBattleNetSettings implementation class.
  • Users now automatically have a Stats property that contains a reference to a class derived from UserStats. This change is breaking and will impact code written for an older CTP release. If using the latest code, this will be compatible with handling code from r15 or newer.
  • The LoginFailed event is no longer prototyped as EventHandler but LoginFailedEventHandler. The LoginFailedEventArgs class contains contextual information about the reason for login failure.

Non-Breaking Changes

  • BN# includes the attributes used for data contract serialization as internal, stub attributes that will enable cross-versioning compatbility. For more information, see the article on compiling for .NET 2.0. This also removes the #if !NET_2_0 conditionals wrapping the attribute declarations throughout the data code.
  • BN# now guarantees events are fired in the correct order by creating additional threads and event queues. This should increase the reliability of the order of events when joining a channel, for example. (Previously, joining a channel could cause a user to be listed as joined before the ChannelJoined event fired due to a race condition, which could cause the user to be added to the user list and then removed).
  • Events on a BattleNetClient now have dedicated threads for Normal- and Low-priority event handlers. High-priority events are still executed on the Parse() loop. All Normal-priority event handlers are executed before outstanding Low-priority event handlers are executed.
  • Added a new Position property to the MBNCSUtil DataReader class.
  • Modified the non-Lockdown version of CheckRevision to use approximately 25mb less of memory allocations and reallocations, saving 3-4 gen-0 garbage collections. The Lockdown version of CheckRevision uses significantly less memory and will be updated in a future version of BN#.
  • Began adding namespace documentation.

Bug Fixes

  • Corrected a defect in which a Warcraft 3 statstring would be incorrectly parsed due to a server defect.
  • Corrected the IBattleNetEvents interface and the EventSink interface to expose all events.
  • Comments had been made that the Disconnected event did not always fire correctly. I believe I have corrected this defect. If you see it happen, please report it in the JinxBot Forums.

Classes

  ClassDescription
AccountCreationEventArgs
Contains information about an attempted account creation event.
AccountCreationFailedEventArgs
Contains information about an account creation attempt that failed.
BaseEventArgs
Provides the base class from which all BN# event argument class should derive.
BattleNetClientResources
Provides global resources preallocated for performance.
ChannelListEventArgs
Specifies the channel list event arguments.
ChatEventArgs
Provides the base information about a chat event.
ChatMessageEventArgs
Represents the event information associated with a chat event with a given user and communication.
ClientCheckFailedEventArgs
Specifies the arguments for a client versioning check failure event.
EnteredChatEventArgs
Specifies the event arguments for when the client entered chat.
ErrorEventArgs
Specifies error event information.
EventExceptionEventArgs
Contains information about when a BN# connection event handler callback raises an exception.
InformationEventArgs
Specifies informational event arguments.
LoginFailedEventArgs
Contains information about a situation in which the client failed to log into Battle.net.
PriorityQueue<(Of <(T>)>)
Implements a basic priority queue.
ServerChatEventArgs
Specifies event information for chat events that do not involve another user.
UserEventArgs
Specifies event information for chat events that involve another user, but not specifically communication.

Interfaces

  InterfaceDescription
IBattleNetSettings
When implemented, provides the necessary settings to establish a Battle.net client connection.

Delegates

  DelegateDescription
AccountCreationEventHandler
Specifies the contract for handlers wishing to listen for account creation events.
AccountCreationFailedEventHandler
Specifies the contract for handlers wishing to listen for account creation failure events.
ChannelListEventHandler
Specifies the contract for clients wishing to register for the channel list event.
ChatMessageEventHandler
Specifies the contract for chat events that involve another user and communication.
ClientCheckFailedEventHandler
Specifies the contract for event handlers that want to handle the client versioning check failure event.
EnteredChatEventHandler
Specifies the contract for event handlers wishing to listen to the entered chat event.
ErrorEventHandler
Specifies the contract for event handlers wishing to listen to the error event.
EventExceptionEventHandler
Specifies the contract for handlers wishing to listen for event exception events.
InformationEventHandler
Specifies the contract for event handlers that want to listen to the Information event.
LoginFailedEventHandler
Specifies the contract for handlers wishing to listen for login failure events.
ServerChatEventHandler
Specifies the contract for chat events that do not involve another user.
UserEventHandler
Specifies the contract for chat events that involve another user, but not specifically communication.

Enumerations

  EnumerationDescription
BncsPacketId
Specifies symbolic name IDs for Battle.net binary protocol messages.
ChannelFlags
Specifies the flags that can be applied to channel-related chat events.
ChatEventType
Specifies types of chat events that may occur.
ClientCheckFailureCause
Specifies the causes of client versioning failure reported by Battle.net.
CreationFailureReason
Specifies the reasons for which an account may fail to be created.
LoginFailureReason
Specifies the known reasons for a login failure to have occurred.
Priority
Specifies priorities for data handling.
UserFlags
Specifies the flags that can be related to user-specific chat events.