Esempio n. 1
0
        /// <summary>发送消息</summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public virtual Boolean SendMessage(Object message)
        {
            var ctx = Server.CreateContext(this);

            message = Pipeline.Write(ctx, message);

            return(ctx.FireWrite(message));
        }
Esempio n. 2
0
        /// <summary>发送消息并等待响应</summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public virtual Task <Object> SendMessageAsync(Object message)
        {
            var ctx    = Server.CreateContext(this);
            var source = new TaskCompletionSource <Object>();

            ctx["TaskSource"] = source;

            message = Pipeline.Write(ctx, message);

            if (!ctx.FireWrite(message))
            {
                return(TaskEx.FromResult((Object)null));
            }

            return(source.Task);
        }