private static bool MethodProxyReceiver(string methodProxyJson, bool socketSuccess)
        {
            MethodProxy resultProxy = null;

            try
            {
                resultProxy = BridgeSerializer.Deserialize <MethodProxy>(ref methodProxyJson);
            }
            catch (Exception ex)
            {
                //Actually if we have an exception here that can mean that the user data has seem class not deserializable
                //between native and Blazor side. As we are probably in a waiting Task scenario, we must try to forward
                //the exception to the waiting task by fetching it's TaskId.

                //It will be easier to debug then
                if (TryGetDefaultFallbackMethodProxy(methodProxyJson, ex, out MethodProxy defaultProxy))
                {
                    return(BlazorCommonDispatcher.Receive(defaultProxy, socketSuccess));
                }

                //Otherwise returning false. The task may be blocked in a waiting state forever
                //TODO: We should implement some kind of CancellationToken in the future on interop method signatures
                //forcing the business code to continue
                return(false);
            }

            return(BlazorCommonDispatcher.Receive(resultProxy, socketSuccess));
        }
        public static bool Receive(string methodProxyJson, bool socketSuccess)
        {
            if (string.IsNullOrEmpty(methodProxyJson))
            {
                return(false);
            }

            try
            {
                MethodProxy resultProxy = BridgeSerializer.Deserialize <MethodProxy>(ref methodProxyJson);
                return(BlazorCommonDispatcher.Receive(resultProxy, socketSuccess));
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteException(ex);
                return(false);
            }
        }
Exemple #3
0
        public static async Task Send(MethodProxy methodProxy)
        {
            MethodProxy result = methodProxy;

            try
            {
                result = await ContextHelper.CallNativeReceive(methodProxy);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //Something gone wrong. Writting error and cancelling parent task
                result.TaskSuccess = false;
            }

            BlazorCommonDispatcher.Receive(result);

            return;
        }