Esempio n. 1
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="to">topic则是组名,</param>
        /// <param name="t"></param>
        ///  /// <param name="Validityperiod">时效(毫秒)</param>
        /// <returns></returns>
        public bool Send <T>(String to, T t, int Validityperiod)
        {
            String  str = Newtonsoft.Json.JsonConvert.SerializeObject(t);
            WMQData wmd = new WMQData();

            byte command = 0x01;

            if (Type == WMQType.topic)
            {
                command            = 0x02;
                wmd.to             = to;
                wmd.message        = str;
                wmd.Validityperiod = Validityperiod;
            }
            else
            {
                command            = 0x01;
                wmd.to             = to;
                wmd.form           = Token;
                wmd.message        = str;
                wmd.Validityperiod = Validityperiod;
            }
            str = Newtonsoft.Json.JsonConvert.SerializeObject(wmd);
            System.Threading.Thread.Sleep(10);
            return(client.send(command, str));
        }
Esempio n. 2
0
 private void Client_receiveServerEvent(byte command, string text)
 {
     if (command == 0x01)
     {
         WMQData wd = Newtonsoft.Json.JsonConvert.DeserializeObject <WMQData>(text);
         receiveQueueEvent(wd);
     }
     else if (command == 0x02)
     {
         WMQData wd = Newtonsoft.Json.JsonConvert.DeserializeObject <WMQData>(text);
         receivetopicEvent(wd);
     }
 }