Created
October 5, 2011 04:16
-
-
Save anaisbetts/1263618 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
| namespace GitHub.Tests.Helpers | |
| { | |
| public class ZeroMqRxFixture | |
| { | |
| [Test] | |
| public void ClientServerSmokeTest() | |
| { | |
| string socketAddr = "tcp://localhost:19999"; | |
| var server = ZeroMQHost<string>.Create(() => | |
| { | |
| var socket1 = new Socket(SocketType.REP); | |
| socket1.Bind(socketAddr); | |
| return new[] {socket1}; | |
| }); | |
| server.SubscribeToSocket(socketAddr) | |
| .Subscribe(x => x.Response.OnNext("***" + x.Value)); | |
| var client = ZeroMQHost<string>.Create(() => | |
| { | |
| var socket2 = new Socket(SocketType.REQ); | |
| socket2.Connect(socketAddr); | |
| return new[] {socket2}; | |
| }); | |
| string result = null; | |
| IObserver<string> sender = client.SenderForSocket(socketAddr); | |
| client.SubscribeToSocket(socketAddr) | |
| .Subscribe(x => result = x.Value); | |
| sender.OnNext("Hello"); | |
| int retries = 10; | |
| while(retries-- > 10 && result == null) | |
| { | |
| Thread.Sleep(1000); | |
| } | |
| Assert.AreEqual("***Hello", result); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just make sure you dispose of the ManualResetEvent, they leak handles.