Exemplo n.º 1
0
        ///// <summary>
        ///// 初始化长连接
        ///// </summary>
        ///// <param name="config"></param>
        //public static void Connect(string config)
        //{
        //    MConfiguration.Bind<Config.MConfig>(config);
        //    Connect(Config.MConfig.Host, Config.MConfig.Port);
        //}
        ///// <summary>
        ///// 初始化长连接
        ///// </summary>
        ///// <param name="Host"></param>
        ///// <param name="Port"></param>
        //public static void Connect(string Host, int Port)
        //{
        //    NettyContainer.Client.Connect(Host, Port);

        //}

        /// <summary>
        /// 初始化客户端
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Host"></param>
        /// <param name="Port"></param>
        /// <returns></returns>
        public static T Client <T>(string config) where T : class
        {
            MConfiguration.Bind <Config.MConfig>(config);
            T client = InterfaceProxy.Resolve <T>();

            return(client);
        }
Exemplo n.º 2
0
        /// <summary>
        ///server 启动端口连接
        /// </summary>
        /// <param name="port"></param>
        public static async void Start(string config)
        {
            MConfiguration.Bind <Config.MConfig>(config);
            RpcConatiner.Initialize();
            DotNettyServer server = new DotNettyServer();
            await server.Listen(Config.MConfig.Port);

            System.Console.WriteLine("开始监听{0}:{1}", Config.MConfig.Host, Config.MConfig.Port);
        }