QuickBusClientChanel diag logging for sub / unsub

This commit is contained in:
Jake Norbut committed 2019-03-14 15:53:12 -05:00
1 parent 16e8a6e26d
commit f6eb1e4745
1 file changed
+5 -3
@@ -67,8 +67,8 @@ namespace bts.api.core {
while (true) {
var response = await check_stream_access(method_id, qualifier);
if (response.success) {
if (response.value.Authorized) {
// success. Break loop and subscribe
if (response.value.Authorized) {
// success. Break loop and subscribe
break;
}
else {
@@ -94,7 +94,8 @@ namespace bts.api.core {
// Authorized. Stream events
unsubscribe_temp_sub();
return SubscribeNative(method, qualifier, parser, converter, observer);
});
});
Log.QBus.diag($"Subscribing for sub: '{method}/{qualifier}'");
return result;
}
private Task<Result<StreamAccessResponse>> check_stream_access(int method_id, string qualifier) {
@@ -143,6 +144,7 @@ namespace bts.api.core {
};
var subscription = ApiNativeMethods.api_client_subscribe(_client, method, qualifier, cb, IntPtr.Zero);
return FinalizeableAnonymousDisposable.Create((disposing) => {
Log.QBus.diag($"Unsubscribing for sub: '{method}/{qualifier}'");
ApiNativeMethods.api_client_unsubscribe(_client, subscription);
subscription = IntPtr.Zero;
GC.KeepAlive(cb);