-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch more components to leak bus implementation.
- Loading branch information
Showing
31 changed files
with
317 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
namespace Leak.Core.Cando | ||
using Leak.Core.Core; | ||
|
||
namespace Leak.Core.Cando | ||
{ | ||
public class CandoConfiguration | ||
{ | ||
public CandoBuilder Extensions { get; set; } | ||
|
||
public CandoCallback Callback { get; set; } | ||
|
||
public LeakBus Bus { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Leak.Core.Common; | ||
|
||
namespace Leak.Core.Cando.Events | ||
{ | ||
public class ExtensionExchanged | ||
{ | ||
public PeerHash Peer; | ||
|
||
public string[] Extensions; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Leak.Core.Collector.Events; | ||
using Leak.Core.Common; | ||
using Leak.Core.Network; | ||
|
||
namespace Leak.Core.Collector | ||
{ | ||
public class PeerCollectorSubscriber | ||
{ | ||
private readonly PeerCollectorContext context; | ||
|
||
public PeerCollectorSubscriber(PeerCollectorContext context) | ||
{ | ||
this.context = context; | ||
} | ||
|
||
public void Handle(string name, dynamic payload) | ||
{ | ||
switch (name) | ||
{ | ||
case "listener-accepted": | ||
HandleConnected(payload.Connection); | ||
break; | ||
} | ||
} | ||
|
||
private void HandleConnected(NetworkConnection connection) | ||
{ | ||
int total = 0; | ||
bool accepted = false; | ||
|
||
lock (context.Synchronized) | ||
{ | ||
if (context.Bouncer.AcceptRemote(connection)) | ||
{ | ||
accepted = true; | ||
total = context.Bouncer.Count(); | ||
} | ||
} | ||
|
||
if (accepted) | ||
{ | ||
PeerAddress peer = connection.Remote; | ||
PeerCollectorConnected connected = new PeerCollectorConnected(peer, total); | ||
|
||
context.Callback.OnConnectedFrom(connected); | ||
} | ||
else | ||
{ | ||
connection.Terminate(); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Leak.Core.Common; | ||
using Leak.Core.Network; | ||
|
||
namespace Leak.Core.Listener.Events | ||
{ | ||
public class ListenerAccepted | ||
{ | ||
public PeerHash Local; | ||
|
||
public PeerAddress Remote; | ||
|
||
public NetworkConnection Connection; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Leak.Core.Common; | ||
|
||
namespace Leak.Core.Listener.Events | ||
{ | ||
public class ListenerAccepting | ||
{ | ||
public PeerHash Local; | ||
|
||
public PeerAddress Remote; | ||
} | ||
} |
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
Oops, something went wrong.