package com.dc.thread; import java.net.URLEncoder; import com.dc.common.utils.MicroUtil; /** * 发送语音 * @author luhj * */ public class SendVoice implements Runnable{ /** * 语音服务器IP */ private String ip; /** * 端口 */ private int port; /** * 短信内容 */ private String content; /** * 语音次数 */ private int times; public SendVoice(String ip,int port,String content,int times){ this.ip = ip; this.port = port; this.content = content; this.times = times; } @Override public void run() { // TODO Auto-generated method stub try { System.out.println(content); content = URLEncoder.encode(content, "UTF-8"); String url = "http://"+ip+":"+port+"/sound"+"?content="+content; for(int i = 0 ; i < times; i++){ MicroUtil.getInstance().singleVoice(url); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
//线程调用
//发送语音 new Thread(new SendVoice(desk.getVoiceIp(), desk.getVoicePort(), voiceContent , 2)).start();