예제 #1
0
        private void ConnectionServer()
        {
            _cedaSubscribe.OnCedaMessage += new Action <com.adaptiveMQ2.message.Message>(_cedaSubscribe_OnCedaMessage);


            _clientInfo = new ClientInfo();
            _clientInfo.setAddress(ip, port);
            _clientInfo.setUser("monitor", "monitor");
            _clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;

            ThreadPool.QueueUserWorkItem(o =>
            {
                _cedaSubscribe.Connect(_clientInfo);
                if (_cedaSubscribe == null)
                {
                    return;
                }
                if (_cedaSubscribe.IsConnected)
                {
                    msd = getMSD();

                    craeteNodeLine();
                    _cedaSubscribe.SubscribeWithImage("YM.M.SI.*", svrId);
                    _cedaSubscribe.Subscribe("YM.M.W.*");
                }
            });
        }
예제 #2
0
        /// <summary>
        /// 通过此方法,获得与服务器的连接。
        /// </summary>
        public void connect()//建¨立ⅰ?连?接ó
        {
            logHelper      = new TextLogHelper(label1, this, ip, port);
            _cedaSubscribe = new CedaManager(logHelper);
            _cedaSubscribe.OnCedaMessage += new Action <com.adaptiveMQ2.message.Message>(_cedaSubscribe_OnCedaMessage);
            ClientInfo clientInfo = new ClientInfo();

            clientInfo.setAddress(ip, port);
            clientInfo.setUser("monitor", "monitor");
            clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;
            ThreadPool.QueueUserWorkItem(o =>
            {
                _cedaSubscribe.Connect(clientInfo);
                labelControl19.Text = "等待连接..";
                if (!_cedaSubscribe.IsConnected)
                {
                    return;
                }
                if (_cedaSubscribe.IsConnected)
                {
                    labelControl19.Text     = "连接成功!";
                    List <string> topicList = new List <string>();
                    topicList.Add("monitor.count.user.all");
                    topicList.Add("monitor.count.user.clienttype");
                    topicList.Add("monitor.count.user.endtype");
                    topicList.Add("monitor.count.user.svraddr");
                    _cedaSubscribe.SubscribeWithImage(topicList, svrId, "");
                    labelControl19.Text = "连接成功!";
                }
            });
        }
예제 #3
0
        //建立连接
        public void connect()
        {
            initialize_ip_port_svrID();
            ClientInfo clientInfo = new ClientInfo();

            clientInfo.setAddress(ip, port);
            clientInfo.setUser("monitor", "monitor");
            clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;
            ThreadPool.QueueUserWorkItem(o =>
            {
                cedaManager.Connect(clientInfo);
                if (cedaManager == null)
                {
                    return;
                }
                if (cedaManager.IsConnected)
                {
                    //string msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic);
                    cedaManager.SubscribeWithImage(topicStr, svrId);
                    List <String> topicList = new List <String>();
                    topicList.Add(topicStr);
                    cedaManager.Subscribe(topicStr);
                    while (cedaManager.IsConnected)
                    {
                        if (cedaManager.IsConnected)
                        {
                            Message reply = cedaManager.Request(getMessage());
                            CedaObject co = CedaObject.ToCedaObject(reply);
                            if (co != null)
                            {
                                LogHelper.Debug(co.Topic + ":" + co.MessageBody);

                                HisMonitorMessages result = MsgHelper.Deserialize <HisMonitorMessages>(co.MessageBody, MsgSerializerType.Json);
                                lock (pointData)
                                {
                                    setLinesData(result.Data);
                                    createLines();
                                }
                                LogHelper.Debug("init end.");
                                break;
                            }
                            else
                            {
                                LogHelper.Error("reply is null.");
                            }
                        }
                        Thread.Sleep(1000);
                    }
                }
            });
        }