Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Jun 6, 2012
1 parent 218a5d9 commit 4356a6e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Bnet/Bnet Client Component.vb
Expand Up @@ -16,15 +16,15 @@ Namespace Bnet
Private ReadOnly _name As InvariantString
Private ReadOnly _client As Bnet.Client
Private _control As Control
Private ReadOnly _hooks As New List(Of Task(Of IDisposable))
Private ReadOnly _life As New CancellationTokenSource()
Private ReadOnly _userGameSetMap As New Dictionary(Of BotUser, WC3.GameSet)

<ContractInvariantMethod()> Private Sub ObjectInvariant()
Contract.Invariant(inQueue IsNot Nothing)
Contract.Invariant(_userGameSetMap IsNot Nothing)
Contract.Invariant(_bot IsNot Nothing)
Contract.Invariant(_client IsNot Nothing)
Contract.Invariant(_hooks IsNot Nothing)
Contract.Invariant(_life IsNot Nothing)
Contract.Invariant(_control IsNot Nothing)
Contract.Invariant(_commands IsNot Nothing)
End Sub
Expand All @@ -36,7 +36,7 @@ Namespace Bnet
component._control = Await BnetClientControl.FromComponentAsync(component)

Dim ct = New CancellationTokenSource()
component._hooks.Add(DirectCast(New DelegatedDisposable(Sub() ct.Cancel()), IDisposable).AsTask())
component._life.Token.Register(Sub() ct.Cancel())
client.IncludePacketHandlerAsync(Protocol.Packets.ServerToClient.ChatEvent,
Function(vals) component.OnReceivedChatEvent(vals),
ct.Token)
Expand Down Expand Up @@ -230,8 +230,8 @@ Namespace Bnet

Protected Overrides Function PerformDispose(finalizing As Boolean) As Task
_client.Dispose()
Call Async Sub() Await _control.DisposeControlAsync()
Return _hooks.DisposeAllAsync()
_life.Cancel()
Return _control.DisposeControlAsync()
End Function
End Class
End Namespace
8 changes: 4 additions & 4 deletions Bnet/BnetClientControl.vb
Expand Up @@ -41,10 +41,10 @@ Namespace Bnet
Dim state = Await _client.GetStateAsync()
OnClientStateChangedAsync(_client, state, state)
End Sub
AddHandler Me._client.StateChanged, AddressOf OnClientStateChangedAsync
AddHandler Me._client.AdvertisedGame, AddressOf OnClientAdvertisedGameAsync
_life.Token.Register(Sub() RemoveHandler Me._client.StateChanged, AddressOf OnClientStateChangedAsync)
_life.Token.Register(Sub() RemoveHandler Me._client.AdvertisedGame, AddressOf OnClientAdvertisedGameAsync)
AddHandler _client.StateChanged, AddressOf OnClientStateChangedAsync
AddHandler _client.AdvertisedGame, AddressOf OnClientAdvertisedGameAsync
_life.Token.Register(Sub() RemoveHandler _client.StateChanged, AddressOf OnClientStateChangedAsync)
_life.Token.Register(Sub() RemoveHandler _client.AdvertisedGame, AddressOf OnClientAdvertisedGameAsync)
End Sub

Private Sub BnetClientControl_Disposed() Handles Me.Disposed
Expand Down
3 changes: 1 addition & 2 deletions Bnet/ClientCredentials.vb
Expand Up @@ -37,8 +37,7 @@ Namespace Bnet
Contract.Assume(N >= 0)
Dim hash1 = G.ToUnsignedBytes.SHA1
Dim hash2 = N.ToUnsignedBytes.SHA1
Return From pair In hash1.Zip(hash2)
Select pair.Item1 Xor pair.Item2
Return hash1.Zip(hash2, Function(e1, e2) e1 xor e2)
End Get
End Property

Expand Down
2 changes: 0 additions & 2 deletions Bnet/Revision Check.vb
Expand Up @@ -22,7 +22,6 @@ Namespace Bnet
''' The operations and initial state of the hash are specified in the challenge.
''' </summary>
Public Module RevisionCheck
#Region "Data"
Private Const SeedVar As Char = "A"c
Private Const ResultVar As Char = "C"c
Private Const InputVar As Char = "S"c
Expand All @@ -44,7 +43,6 @@ Namespace Bnet
&H7927D27EUI,
&H2FEC8733UI
}
#End Region

'''<summary>Selects a seed based on the index string.</summary>
<Pure()>
Expand Down

0 comments on commit 4356a6e

Please sign in to comment.