Beispiel #1
0
        public async Task CanPublishEventUsingAPrefix()
        {
            using (var client1 = new WampClient("localhost", 16000))
            using (var client2 = new WampClient("localhost", 16000))
            {
                await client1.Connect();
                await client2.Connect();

                var client1Obs = client1.Subscribe("http://localhost/simple/event#myevent").Replay();
                await Task.Delay(200);

                using (client1Obs.Connect())
                {
                    await client2.Prefix("event", "http://localhost/simple/event#");
                    await client2.Publish("event:myevent", "selfpublishing");

                    var obsTask = client1Obs.Take(1).ToTask();
                    var delay = Task.Delay(5000);

                    var t = await Task.WhenAny(obsTask, delay);

                    Assert.That(delay.Id, Is.Not.EqualTo(t.Id), "Timed out!");
                }
            }
        }
Beispiel #2
0
        public async Task CanPerformRpcUsingAPrefix()
        {
            using (var csharpFacade = new WampClient("localhost", 16000))
            {
                await csharpFacade.Connect();
                await csharpFacade.Prefix("calc", "http://localhost/simple/calc#");
                var call = csharpFacade.Call("calc:add", "5", "6");
                var delay = Task.Delay(5000);
                var r = await Task.WhenAny(call, delay);

                Assert.That(r.Id, Is.Not.EqualTo(delay.Id), "Timed out!");
                Assert.That(call.Result, Is.EqualTo("11"), "Wrong result");
            }
        }