Esempio n. 1
0
        public async Task <IApiResult <string> > Hello(string name, int count, Guid guid, byte[] file, long id = -1, Em em = Em.Test)
        {
            var test3 = DependencyHelper.GetService <TestObject>();
            var test2 = DependencyHelper.GetService <ITest>(nameof(TestObject));

            var ctx = context = GlobalContext.Current;

            await  Debug(1, context, context);

            ScopeRuner.RunScope("Hello2", Hello2);
            await Debug(1, ctx, GlobalContext.Current);

            if (DateTime.Now.Ticks % 13 == 11)
            {
                Logger.Exception(new Exception("故意的"));
            }
            if (DateTime.Now.Ticks % 23 == 19)
            {
                Logger.Error("故意的");
            }
            if (DateTime.Now.Ticks % 67 == 57)
            {
                Logger.Log(LogLevel.Critical, "故意的");
            }
            return(ApiResultHelper.Helper.Succees($"name:{name} count:{count} guid:{guid} file:{file} id:{id} em:{em}"));
        }
Esempio n. 2
0
        private void OnReceive(SessionReceiveEventArgs e)
        {
            TcpOption.Instance.ConcurrencySemaphore.Wait();
            var pipeStream = e.Stream.ToPipeStream();

            if (!pipeStream.TryReadLine(out var message) || message == null)
            {
                return;
            }
            message = message.Trim('\0').Trim();
            if (message.IsBlank())
            {
                return;
            }
            ScopeRuner.RunScope("TcpHandler", OnMessage, (message, e.Session));
        }
Esempio n. 3
0
        /// <summary>
        /// 消息处理(异步)
        /// </summary>
        /// <param name="service">服务</param>
        /// <param name="message">消息</param>
        /// <param name="offline">是否离线消息</param>
        /// <param name="original">原始透传对象</param>
        public static Task OnMessagePush(IService service, IInlineMessage message, bool offline, object original)
        {
            ZeroAppOption.Instance.BeginRequest();
            message.RealState = MessageState.Recive;
            var process = new MessageProcessor
            {
                Service   = service,
                Message   = message,
                Original  = original,
                IsOffline = offline,
                WaitTask  = new TaskCompletionSource <bool>()
            };

            ScopeRuner.RunScope($"{message.Service}/{message.Method}", process.Process, ContextInheritType.Clone);
            return(process.WaitTask.Task);
        }
Esempio n. 4
0
        /// <summary>
        /// 消息处理(异步)
        /// </summary>
        /// <param name="service">服务</param>
        /// <param name="message">消息</param>
        /// <param name="offline">是否离线消息</param>
        /// <param name="original">原始透传对象</param>
        public static void RunOnMessagePush(IService service, IInlineMessage message, bool offline, object original)
        {
            if (!ZeroAppOption.Instance.BeginRequest())
            {
                message.RealState = MessageState.Cancel;
                return;
            }
            message.RealState = MessageState.Recive;
            var process = new MessageProcessor
            {
                Service   = service,
                Message   = message,
                Original  = original,
                IsOffline = offline
            };

            ScopeRuner.RunScope($"{message.Service}/{message.Method}", process.Process, ContextInheritType.Clone);
        }