private void sentMsg() { if (_cedaSubscribe.IsConnected) { com.adaptiveMQ2.message.Message reply = _cedaSubscribe.Request(request); if (reply != null) { CedaObject co = CedaObject.ToCedaObject(reply); TimeChange result = MsgHelper.Deserialize <TimeChange>(co.MessageBody, MsgSerializerType.Json); if (result.Code == "0000") { TmMsg.Text = "现在时间间隔是" + result.period + "秒,在这里输入时间:"; } else { MessageBox.Show("出错啦,没有设置成功哦"); TmMsg.Text = "出错了"; } } else { MessageBox.Show("响应信息异常"); } } else { MessageBox.Show("连接失败"); } }
private void sentMsg() { if (_cedaSubscribe.IsConnected) { com.adaptiveMQ2.message.Message reply = _cedaSubscribe.Request(request); if (reply != null) { CedaObject co = CedaObject.ToCedaObject(reply); HistoryMsg result = MsgHelper.Deserialize<HistoryMsg>(co.MessageBody, MsgSerializerType.Json); _cedaSubscribe_OnCedaMessage(result); } else { MessageBox.Show("响应信息异常"); } } else { MessageBox.Show("连接失败"); } }
//建立连接 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); } } }); }
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); } } }); }
private MSD getMSD() { MSD msd = new MSD(); msd.svrinfos.Add(new TSvrinfo() { ServiceName = "Asvr" }); msd.svrinfos.Add(new TSvrinfo() { ServiceName = "AMQ1" }); msd.svrinfos.Add(new TSvrinfo() { ServiceName = "AMQ2" }); msd.svrrefs.Add(new TSvrRef() { Servername_From = "AMQ1", Servername_To = "Asvr" }); msd.svrrefs.Add(new TSvrRef() { Servername_From = "AMQ2", Servername_To = "Asvr" }); Message request = new Message(); request.Destination = new Destination("YM.M.SD"); request.SvrID = svrId; request.MessageBody.addString((short)3, "{}"); request.MessageBody.addString((short)4, "JSON"); request.MessageBody.addInt((short)5, 0); request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss")); Message reply = _cedaSubscribe.Request(request); CedaObject co = CedaObject.ToCedaObject(reply); if (co.MessageBody != null) { msd = MsgHelper.Deserialize <MSDResult>(co.MessageBody).MSD; } return(msd); }