public FSharpAsync <ConnectionAction> OnConnectionBeforeHandler(
            IDiResolveReleaseOnlyContainer di, string url, object serviceInstanceOrNull,
            MethodInfo methodOrNull, object[] parms, ResourceType res)
        {
            var ci   = di.Resolve <ClientConnectionInfo>();
            var guid = Guid.NewGuid().ToString();

            LogAsReply($"OnConnectionBeforeHandler() ip={ci.ClientIpAddress} guid={guid} url={url} resourceType={res.ToString()} serviceImpl={serviceInstanceOrNull} method={methodOrNull} parms={parms}");

            var ctx = new FilterInvocation {
                Url     = url,
                ResType = res,
                InvType = FilterInvocationType.BeforeConnection,
                FullInterfaceNameOrNull = serviceInstanceOrNull == null ?
                                          null
                    :
                                          FindServiceInterfaceType(serviceInstanceOrNull).FullName,
                MethodNameOrNull = methodOrNull?.Name,
                Guid             = guid
            };

            SendFilterInvocation(ctx);

            return(FSharpAsyncUtil.FromResult(ConnectionAction.CreateNonFiltered(ctx)));
        }
Exemple #2
0
        public FSharpAsync <ConnectionAction> OnConnectionBeforeHandler(
            IDiResolveReleaseOnlyContainer di, string url, object serviceInstance,
            MethodInfo method, object[] prms, ResourceType res)
        {
            var ci   = di.Resolve <ClientConnectionInfo>();
            var guid = Guid.NewGuid().ToString();

            Logger.Debug(typeof(LifeTimeFilter), $"OnConnectionBeforeHandler() ip={ci.ClientIpAddress} guid={guid} url={url} resourceType={res.ToString()} serviceImpl={serviceInstance} method={method} prms={prms}");
            return(FSharpAsyncUtil.FromResult(ConnectionAction.CreateNonFiltered(guid)));
        }
        public FSharpAsync <Microsoft.FSharp.Core.Unit> OnConnectionAfterHandler(
            object rawConnCtx, IDiResolveReleaseOnlyContainer di, Exception exOrNull)
        {
            var connCtx = (FilterInvocation)rawConnCtx;

            LogAsReply($"OnConnectionAfterServiceHandler() guid={connCtx.Guid} success?={exOrNull == null} errorDetails={exOrNull}");

            connCtx.InvType = FilterInvocationType.AfterConnection;

            SendFilterInvocation(connCtx);

            return(FSharpAsyncUtil.FromUnitResult());
        }
        public Task OnServerStarted(IDiResolveReleaseOnlyContainer di)
        {
            _consoleBasedListener = new Thread(() => {
                Thread.CurrentThread.IsBackground = true;

                LogAsReply("listening started");

                while (!_shouldQuit)
                {
                    var rawCmd = _receiveCommand();
                    LogAsReply("received raw command");

                    try {
                        var decoded = _codec.Decode <CommandRequest>(rawCmd);

                        LogAsReply($"successfully decoded command requestId={decoded.Id} type={decoded.Type}");

                        switch (decoded.Type)
                        {
                        case RequestType.StopServer:
                            _shouldQuit = true;
                            break;

                        default: throw new Exception("unsupported RequestType");
                        }
                    } catch (Exception ex) {
                        LogAsReply($"could not decode command because of {ex}");
                    }
                }
            });
            _consoleBasedListener.Start();

            Send(CommandReplyUtil.CreateServerStarted());
            SendFilterInvocation(new FilterInvocation {
                InvType = FilterInvocationType.ServerStarted
            });

            return(Task.CompletedTask);
        }
Exemple #5
0
 public FSharpAsync <Microsoft.FSharp.Core.Unit> OnConnectionAfterHandler(object connCtx, IDiResolveReleaseOnlyContainer obj0, Exception exOrNull)
 {
     Logger.Debug(typeof(LifeTimeFilter), $"OnConnectionAfterServiceHandler() guid={connCtx} success?={exOrNull == null} errorDetails={exOrNull}");
     return(FSharpAsyncUtil.FromUnitResult());
 }
Exemple #6
0
 public Task OnServerStarted(IDiResolveReleaseOnlyContainer di)
 {
     Logger.Debug(typeof(LifeTimeFilter), "OnServerStarted()");
     return(Task.CompletedTask);
 }