Esempio n. 1
0
        public static bool ConnectionServer(ChannelModel model)
        {
            //获取远程对象
            var channelGroup = model.ChannelGroupType == "1" ? ChannelGroup.TCP : ChannelGroup.HTTP;
            string protocol = "tcp";
            if (channelGroup == ChannelGroup.HTTP) protocol = "http";
            string uri = GetServerUrl(protocol, model);
            try
            {
                ChannelClass.StartChannel(channelGroup, model.ChannelName);
                _iHiCoordinator = Activator.GetObject(typeof(IHiCoordinator), uri) as IHiCoordinator;

                _wrapper = new EventWrapper();
                _wrapper.Server2ClientEvent += GetServerMessage;
                if (_iHiCoordinator != null)
                    _iHiCoordinator.Server2ClientEvent += _wrapper.OnServer2ClientEvent;
                ChannelDetail = model;
                string clientName = ChannelClass.GetMyHostName();
                if (_iHiCoordinator != null)
                    _iHiCoordinator.IClient2Server(clientName + "成功连接服务");
                return true;
            }
            catch (Exception ex)
            {
                MsgBox.ShowInformation("启动服务失败:" + ex.Message + "\n\n" + uri);
                return false;
            }
        }
Esempio n. 2
0
        public static bool ConnectionServer(ChannelModel model)
        {
            //获取远程对象
            var    channelGroup = model.ChannelGroupType == "1" ? ChannelGroup.TCP : ChannelGroup.HTTP;
            string protocol     = "tcp";

            if (channelGroup == ChannelGroup.HTTP)
            {
                protocol = "http";
            }
            string uri = GetServerUrl(protocol, model);

            try
            {
                ChannelClass.StartChannel(channelGroup, model.ChannelName);
                _iHiCoordinator = Activator.GetObject(typeof(IHiCoordinator), uri) as IHiCoordinator;

                _wrapper = new EventWrapper();
                _wrapper.Server2ClientEvent += GetServerMessage;
                if (_iHiCoordinator != null)
                {
                    _iHiCoordinator.Server2ClientEvent += _wrapper.OnServer2ClientEvent;
                }
                ChannelDetail = model;
                string clientName = ChannelClass.GetMyHostName();
                if (_iHiCoordinator != null)
                {
                    _iHiCoordinator.IClient2Server(clientName + "成功连接服务");
                }
                return(true);
            }
            catch (Exception ex)
            {
                MsgBox.ShowInformation("启动服务失败:" + ex.Message + "\n\n" + uri);
                return(false);
            }
        }
Esempio n. 3
0
 public static void SetDisConnection()
 {
     _iHiCoordinator = null;
 }
Esempio n. 4
0
 public static void SetDisConnection()
 {
     _iHiCoordinator = null;
 }