Created
October 28, 2011 22:10
-
-
Save anaisbetts/1323712 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const string socketAddr = "tcp://localhost:30101"; | |
| public IObservable<bool> ConnectOrBecomeAnnounceServer() | |
| { | |
| if (_socket != null) | |
| { | |
| return Observable.Throw<bool>(new Exception("Already connected")); | |
| } | |
| return ConnectToAnnounceServer() | |
| .Catch(BecomeAnnounceServer()) | |
| .SelectMany(sockAndCtx => | |
| { | |
| if (sockAndCtx == null) | |
| { | |
| return Observable.Throw<bool>(new Exception("Can't connect nor become announce server")); | |
| } | |
| _socket = _host.RegisterSocket(sockAndCtx.Item1); | |
| _isAnnounceServer = sockAndCtx.Item2; | |
| return Observable.Return(_isAnnounceServer); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment