示例#1
0
文件: CS_NMClient.cs 项目: metoer/wpf
        public static NMClientPrx uncheckedCast(Ice.ObjectPrx b)
        {
            if (b == null)
            {
                return(null);
            }
            NMClientPrx r = b as NMClientPrx;

            if (r == null)
            {
                NMClientPrxHelper h = new NMClientPrxHelper();
                h.copyFrom__(b);
                r = h;
            }
            return(r);
        }
示例#2
0
文件: CS_NMClient.cs 项目: metoer/wpf
        public static NMClientPrx checkedCast(Ice.ObjectPrx b)
        {
            if (b == null)
            {
                return(null);
            }
            NMClientPrx r = b as NMClientPrx;

            if ((r == null) && b.ice_isA(ice_staticId()))
            {
                NMClientPrxHelper h = new NMClientPrxHelper();
                h.copyFrom__(b);
                r = h;
            }
            return(r);
        }
示例#3
0
文件: CS_NMClient.cs 项目: metoer/wpf
        public static NMClientPrx checkedCast(Ice.ObjectPrx b, _System.Collections.Generic.Dictionary <string, string> ctx)
        {
            if (b == null)
            {
                return(null);
            }
            NMClientPrx r = b as NMClientPrx;

            if ((r == null) && b.ice_isA(ice_staticId(), ctx))
            {
                NMClientPrxHelper h = new NMClientPrxHelper();
                h.copyFrom__(b);
                r = h;
            }
            return(r);
        }
示例#4
0
文件: CS_NMClient.cs 项目: metoer/wpf
 public static void write__(IceInternal.BasicStream os__, NMClientPrx v__)
 {
     os__.writeProxy(v__);
 }
示例#5
0
        /// <summary>
        /// 初始化连接
        /// </summary>
        /// <returns></returns>
        public bool Init()
        {
            try
            {
                lock (lockData)
                {
                    Ice.InitializationData intiData = new Ice.InitializationData();

                    Ice.Properties properties = Ice.Util.createProperties();

                    properties.setProperty("Ice.MessageSizeMax", "104857600");

                    intiData.properties = properties;

                    ic = Ice.Util.initialize(intiData);

                    // 连接
                    Ice.ObjectPrx objectPrx = ic.stringToProxy(string.Format("{0}:tcp -h {1} -p {2} -t 5000", NMCommunicationRPCId.value,
                                                                             EEMSConfigHelper.GetValueByCommomConfig("config/CommonConfig/netagent_ip", "127.0.0.1"),
                                                                             EEMSConfigHelper.GetValueByCommomConfig("config/CommonConfig/netagent_port", "40050")));

                    client = NMServerPrxHelper.checkedCast(objectPrx);

                    // 代理
                    Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints(NMCommunicationRPCId.value, string.Format("tcp -h {0} -p {1} -t 5000",
                                                                                                                              EEMSConfigHelper.GetValueByCommomConfig("config/CollectClient/WarnInfoLocalIp", "127.0.0.1"),
                                                                                                                              EEMSConfigHelper.GetValueByCommomConfig("config/CollectClient/WarnInfoClentPort", "42050")));

                    NMClientI clientI = new NMClientI();

                    clientI.ReceiveDataHandler += clientI_ReceiveDataHandler;

                    Ice.Object obj = clientI;

                    adapter.add(obj, ic.stringToIdentity(NMCommunicationRPCId.value));

                    adapter.activate();

                    NMClientPrx call = NMClientPrxHelper.uncheckedCast(adapter.createProxy(ic.stringToIdentity(NMCommunicationRPCId.value)));

                    client.NMRegistClient(clientID, call);

                    IsConnect = true;
                }

                return(true);
            }
            catch (Exception e)
            {
                // 初始化失败
                client = null;
                LogHelper.Instance.WirteErrorMsg(e.Message);
                return(false);
            }
            finally
            {
                if (!isThreadStart)
                {
                    isThreadStart = true;
                    CheckConnectThread();
                }
            }
        }