Beispiel #1
0
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="message">文本内容,最大约2000汉字</param>
        public void SendData(string message)
        {
            if (message.Length > 2000)
            {
                //默认传输都是汉字
                throw new Exception("传入字数过长,不得超过2000汉字!");
            }
            try
            {
                JObject frame    = new JObject();
                JObject business = new JObject();
                JObject common   = new JObject();
                JObject data     = new JObject();
                // 填充common
                common.Add("app_id", appId);
                //填充business
                business.Add("aue", configSetting.aue);
                business.Add("tte", configSetting.tte);
                business.Add("ent", configSetting.ent);
                business.Add("vcn", configSetting.vcn);
                business.Add("pitch", configSetting.pitch);
                business.Add("speed", configSetting.speed);
                business.Add("volume", configSetting.volume);
                business.Add("auf", configSetting.auf);
                business.Add("ram", configSetting.ram);
                business.Add("rdn", configSetting.rdn);
                business.Add("reg", configSetting.reg);
                business.Add("sfl", configSetting.sfl);
                data.Add("status", 2);//数据状态,固定位2
                data.Add("text", Base64Helper.EncodeBase64("utf-8", message));

                frame.Add("common", common);
                frame.Add("business", business);
                frame.Add("data", data);

                byte[] value = Encoding.Default.GetBytes(frame.ToString());

                sendMessage(value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }