v7.3.2018.0614   重构高性能资源池,减少GC压力,增加线程池,让异步任务得到平等竞争CPU的机会
大石头 authored at 2018-06-14 17:56:44
867.00 B
X
using System;
using System.ComponentModel;
using NewLife.Log;
using NewLife.Remoting;

namespace NewLife.MessageQueue
{
    /// <summary>消息控制器</summary>
    public class MessageController : IApi
    {
        /// <summary>Api接口会话</summary>
        public IApiSession Session { get; set; }

        /// <summary>发布消息</summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [DisplayName("发布消息")]
        public Boolean Public(Message msg)
        {
            XTrace.WriteLine("发布消息 {0}", msg);

            var user = Session["user"] as String;

            var tp = Session["Topic"] as Topic;
            if (tp == null) throw new Exception("未订阅");

            msg.Sender = user;
            tp.Send(msg);

            return true;
        }
    }
}