Пример #1
0
 public static extern void DecodeIpcMessageNative(
     string encodedReq,
     IntPtr self,
     DecodeAuthCb cb1,
     DecodeUnregCb cb2,
     DecodeContCb cb3,
     DecodeShareMDataCb cb4,
     DecodeRevokedCb cb5,
     DecodeErrorCb cb6);
Пример #2
0
 public static extern void DecodeIpcMessageNative(
     string encodedReq,
     IntPtr self,
     DecodeAuthCb authCb,
     DecodeUnregCb unregCb,
     DecodeContCb contCb,
     DecodeShareMDataCb shareMDataCb,
     DecodeRevokedCb revokedCb,
     ListBasedResultCb errorCb);
Пример #3
0
        public void DecodeIpcMessage(
            string encodedReq,
            DecodeAuthCb authCb,
            DecodeUnregCb unregCb,
            DecodeContCb contCb,
            DecodeShareMDataCb shareMDataCb,
            DecodeRevokedCb revokedCb,
            ListBasedResultCb errorCb)
        {
            var cbs = new List <object> {
                authCb, unregCb, contCb, shareMDataCb, revokedCb, errorCb
            };

            DecodeIpcMessageNative(
                encodedReq,
                cbs.ToHandlePtr(),
                OnDecodeAuthCb,
                OnDecodeUnregCb,
                OnDecodeContCb,
                OnDecodeShareMDataCb,
                OnDecodeRevokedCb,
                OnListBasedResultCb);
        }
Пример #4
0
        public static Task <DecodeIpcResult> DecodeIpcMessageAsync(string encodedReq)
        {
            return(Task.Run(
                       () => {
                var tcs = new TaskCompletionSource <DecodeIpcResult>();
                DecodeAuthCb authCb = null;
                DecodeUnregCb unregCb = null;
                DecodeContCb contCb = null;
                DecodeShareMDataCb shareMDataCb = null;
                DecodeRevokedCb revokedCb = null;
                DecodeErrorCb errorCb = null;
                var callbacks = new List <object>();

                authCb = (self, id, authGrantedFfiPtr) => {
                    var authGrantedFfi = (AuthGrantedFfi)Marshal.PtrToStructure(authGrantedFfiPtr, typeof(AuthGrantedFfi));
                    var authGranted = new AuthGranted {
                        AppKeys = authGrantedFfi.AppKeys,
                        AccessContainer = authGrantedFfi.AccessContainer,
                        BootStrapConfig = authGrantedFfi.BootStrapConfigPtr.ToList <byte>(authGrantedFfi.BootStrapConfigLen)
                    };

                    tcs.SetResult(new DecodeIpcResult {
                        AuthGranted = authGranted
                    });
                    CallbackManager.Unregister(callbacks);
                };
                unregCb = (self, id, config, size) => {
                    tcs.SetResult(new DecodeIpcResult {
                        UnRegAppInfo = Tuple.Create(config, size)
                    });
                    CallbackManager.Unregister(callbacks);
                };
                contCb = (self, id) => {
                    tcs.SetResult(new DecodeIpcResult {
                        ContReqId = id
                    });
                    CallbackManager.Unregister(callbacks);
                };
                shareMDataCb = (self, id) => {
                    tcs.SetResult(new DecodeIpcResult {
                        ShareMData = id
                    });
                    CallbackManager.Unregister(callbacks);
                };
                revokedCb = self => {
                    tcs.SetResult(new DecodeIpcResult {
                        Revoked = true
                    });
                    CallbackManager.Unregister(callbacks);
                };
                errorCb = (self, result) => {
                    tcs.SetException(result.ToException());
                    CallbackManager.Unregister(callbacks);
                };

                callbacks.AddRange(new List <object> {
                    authCb, unregCb, contCb, shareMDataCb, revokedCb, errorCb
                });
                CallbackManager.Register(callbacks);
                NativeBindings.DecodeIpcMessage(encodedReq, UserData, authCb, unregCb, contCb, shareMDataCb, revokedCb, errorCb);

                return tcs.Task;
            }));
        }