コード例 #1
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 = "连接成功!";
                }
            });
        }
コード例 #2
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.*");
                }
            });
        }
コード例 #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);
                    }
                }
            });
        }
コード例 #4
0
ファイル: ZedgraphDemo.cs プロジェクト: 15831944/tool
        public void connect()
        {
            ClientInfo clientInfo = new ClientInfo();

            clientInfo.setAddress(Ip, Port);
            clientInfo.setUser("zedgraph", "zedgraph");
            clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;

            ThreadPool.QueueUserWorkItem(o =>
            {
                cedaClient.Connect(clientInfo);
                if (cedaClient == null)
                {
                    return;
                }
                if (cedaClient.IsConnected)
                {
                    while (cedaClient != null)
                    {
                        if (cedaClient.IsConnected)
                        {
                            Message reply = cedaClient.Request(getMessage());
                            CedaObject co = CedaObject.ToCedaObject(reply);
                            if (co != null)
                            {
                                LogHelper.Debug(co.Topic + ":" + co.MessageBody);

                                ServerTopicRef result = MsgHelper.Deserialize <ServerTopicRef>(co.MessageBody,
                                                                                               MsgSerializerType.Json);

                                setLinesData(result.TSvrTopicRefs);
                                createLines();

                                LogHelper.Debug("init end.");

                                break;
                            }
                            else
                            {
                                LogHelper.Error("reply is null.");
                            }
                        }
                        Thread.Sleep(repeatRequestTime);
                    }
                }
            });
        }
コード例 #5
0
ファイル: Form3.cs プロジェクト: 15831944/tool
        public void connect()
        {
            logHelper = new TextLogHelper(label5,this, IP, PORT);
            _cedaSubscribe = new CedaManager(logHelper);

            
            ClientInfo clientInfo = new ClientInfo();
            clientInfo.setAddress(IP, PORT);
            clientInfo.setUser("monitor", "monitor");
            clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;

            ThreadPool.QueueUserWorkItem(o =>
            {


                _cedaSubscribe.Connect(clientInfo);
            });

               
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: 15831944/tool
        //连接服务器,并订阅目标消息
        private void ConnectionServer()
        {
            //MessageBox.Show("kaishilianjie");
            _cedaSubscribe = new CedaManager(logHelper);
            _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;
            //MessageBox.Show("启动线程,并订阅消息");
            try
            {
                ThreadPool.QueueUserWorkItem(o =>
                {
                    _cedaSubscribe.Connect(_clientInfo);
                    if (_cedaSubscribe == null)
                    {
                        return;
                    }
                    if (_cedaSubscribe.IsConnected)
                    {
                        string msgbody = MsgHelper.Serializer <Dictionary <string, object> >(dic);

                        request.MessageBody.addString((short)3, msgbody);

                        request.MessageBody.addString((short)4, "JSON");
                        request.MessageBody.addInt((short)5, 0);
                        request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));

                        sentMsg();
                        _cedaSubscribe.Subscribe("monitor.event.*");
                    }
                });
            }
            catch { txtMsg.Text = "连接失败,请检查链接。SerID:" + serId + "   IP:" + ip + "   PORT:" + port; }
        }
コード例 #7
0
        private void ConnectionServer()
        {
            _cedaSubscribe = new CedaManager(logHelper);
            _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)
                {
                    _cedaSubscribe.Subscribe("YM.MONITOR");
                }
            });
        }