schulz3000 / deepstreamNet

dotnet Client for deepstream.io
MIT License
38 stars 9 forks source link

Subscribe to record property change not triggered on same connection #26

Closed grendo closed 7 years ago

grendo commented 7 years ago

Here is a quick test that creates a record, sets it with an ack, then subscribes to changes, then sets with an ack again. Finally it waits for the property change event to trigger which never happens.

Note this is all on the one connection.

        [Test]
        public async Task SubscribeToChangesOnSameConnection()
        {
            var key = @"test/helloworld";
            using (var writerClient = await GetConnection("john", "test"))
            {
                var obj = new JObject();
                obj["name"] = "test me";
                var record = await writerClient.Records.GetRecordAsync(key);
                var set = await writerClient.Records.SetWithAckAsync(record, obj);
                Assert.IsTrue(set);
                var events = new List<PropertyChangedEventArgs>();
                record.PropertyChanged += (sender, args) =>
                {
                    events.Add(args);
                };
                obj["name"] = "bob";
                set = await writerClient.Records.SetWithAckAsync(record, obj);
                Assert.IsTrue(set);

               // hangs here and never gets the event
                while (events.Count == 0)
                {
                    System.Threading.Thread.Sleep(200);
                }
            }
        }