public async Task Fire_Client_Unsubscribed_Event() { using (var testEnvironment = CreateTestEnvironment()) { var server = await testEnvironment.StartServer(); ClientUnsubscribedTopicEventArgs eventArgs = null; server.ClientUnsubscribedTopicAsync += e => { eventArgs = e; return(PlatformAbstractionLayer.CompletedTask); }; var client = await testEnvironment.ConnectClient(); await client.UnsubscribeAsync("The/Topic"); await LongTestDelay(); Assert.IsNotNull(eventArgs); Assert.IsTrue(eventArgs.ClientId.StartsWith(nameof(Fire_Client_Unsubscribed_Event))); Assert.AreEqual("The/Topic", eventArgs.TopicFilter); } }
internal Task Server_ClientUnsubscribedTopic(ClientUnsubscribedTopicEventArgs e) { _logger.LogInformation($"Client [{e.ClientId}] unsubscribed[{e.TopicFilter}]"); if (!e.TopicFilter.StartsWith("$SYS/")) { Subscribed--; } return(Task.CompletedTask); }