Permalink
Browse files

Minor

  • Loading branch information...
1 parent 218a5d9 commit 4356a6e1944e15a80f42f607c9ad179129dca8aa @Strilanc committed Jun 6, 2012
Showing with 10 additions and 13 deletions.
  1. +5 −5 Bnet/Bnet Client Component.vb
  2. +4 −4 Bnet/BnetClientControl.vb
  3. +1 −2 Bnet/ClientCredentials.vb
  4. +0 −2 Bnet/Revision Check.vb
@@ -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
@@ -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)
@@ -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
@@ -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
@@ -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
View
@@ -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
@@ -44,7 +43,6 @@ Namespace Bnet
&H7927D27EUI,
&H2FEC8733UI
}
-#End Region
'''<summary>Selects a seed based on the index string.</summary>
<Pure()>

0 comments on commit 4356a6e

Please sign in to comment.