|
|
|
@ -43,13 +43,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
ws.OnMessage += (s, e) => |
|
|
|
|
{ |
|
|
|
|
string content = Encoding.UTF8.GetString(e.Content); |
|
|
|
|
Log.Error("收到请求:" + s.ToString() + " 请求参数:" + content); |
|
|
|
|
//读取参数 |
|
|
|
|
if (content != "ping" && !string.IsNullOrEmpty(content)) |
|
|
|
|
{ |
|
|
|
|
//返回内容 |
|
|
|
|
string result = string.Empty; |
|
|
|
|
content = Base64str2(content); |
|
|
|
|
Log.Error("收到请求:" + s.ToString() + " 请求参数:" + content); |
|
|
|
|
if (!string.IsNullOrEmpty(content)) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
@ -151,10 +151,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; |
|
|
|
|
} |
|
|
|
|
Log.Error("答复请求者:" + s.ToString() + " 返回数据:" + result); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
//答复请求者(处理完请求后在些答复) |
|
|
|
|
byte[] bytes = SerializeContent(result); |
|
|
|
|
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); |
|
|
|
|
} |
|
|
|
|
catch { result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"400\",\"status\":true,\"data\":\"返回参数失败\"}"; } |
|
|
|
|
finally { } |
|
|
|
|
} |
|
|
|
|
//监听心跳并且回复客户端“已ping作为关键字” |
|
|
|
|
else if (content == "ping") |
|
|
|
|
{ |
|
|
|
@ -351,7 +356,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
{ |
|
|
|
|
//Log.Error("停止失败: " + ex.Message + ""); |
|
|
|
|
} |
|
|
|
|
//AutoAudio(false, ""); |
|
|
|
|
// AutoAudio(false, ""); |
|
|
|
|
}); |
|
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; |
|
|
|
|
SubmitLogs(result, "payleText"); |
|
|
|
@ -363,7 +368,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
{ |
|
|
|
|
//形成语音 |
|
|
|
|
tempWav = GenerateWavFromText(text); |
|
|
|
|
////开始播放 |
|
|
|
|
//////开始播放 |
|
|
|
|
string command = $"sox {tempWav} -d"; |
|
|
|
|
ShllCommad(command); |
|
|
|
|
//AutoAudio(true, tempWav); |
|
|
|
@ -462,7 +467,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); event2.WaitOne(); }); |
|
|
|
|
Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); }); |
|
|
|
|
event2.WaitOne(); |
|
|
|
|
string result = sginStr; |
|
|
|
|
SubmitLogs(result, "OpenSign"); |
|
|
|
|
return result; |
|
|
|
@ -581,6 +587,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
Regex re = new Regex(@"(((?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)"); |
|
|
|
|
MatchCollection mc = re.Matches(url);//获取的是一个数组 |
|
|
|
|
string reurl = mc[0].ToString() + "://" + mc[1].ToString() + urlpath; |
|
|
|
|
|
|
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + reurl + "\"}"; |
|
|
|
|
SubmitLogs(result, "SoundRecording"); |
|
|
|
|
return result; |
|
|
|
@ -783,18 +790,18 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
{ |
|
|
|
|
Task.Run(() => |
|
|
|
|
{ |
|
|
|
|
//if (Typrocess != null) |
|
|
|
|
//{ |
|
|
|
|
// // 如果进程还在运行 |
|
|
|
|
// if (!Typrocess.HasExited) |
|
|
|
|
// { |
|
|
|
|
// // 发送SIGTERM信号来停止进程 |
|
|
|
|
// Typrocess.Kill(); |
|
|
|
|
// // 等待进程真正停止 |
|
|
|
|
// Typrocess.WaitForExit(); |
|
|
|
|
// } |
|
|
|
|
//} |
|
|
|
|
AutoAudio(ispaly, ""); |
|
|
|
|
if (Typrocess != null) |
|
|
|
|
{ |
|
|
|
|
// 如果进程还在运行 |
|
|
|
|
if (!Typrocess.HasExited) |
|
|
|
|
{ |
|
|
|
|
// 发送SIGTERM信号来停止进程 |
|
|
|
|
Typrocess.Kill(); |
|
|
|
|
// 等待进程真正停止 |
|
|
|
|
Typrocess.WaitForExit(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//AutoAudio(ispaly, ""); |
|
|
|
|
}); |
|
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "停止播放成功" + "}"; |
|
|
|
|
SubmitLogs(result, "PalyFile"); |
|
|
|
@ -830,9 +837,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
response.Close(); |
|
|
|
|
|
|
|
|
|
//开始播放 |
|
|
|
|
//string command = $"sox {path} -d"; |
|
|
|
|
//ShllCommad(command); |
|
|
|
|
AutoAudio(ispaly, path); |
|
|
|
|
string command = $"sox {path} -d"; |
|
|
|
|
ShllCommad(command); |
|
|
|
|
//AutoAudio(ispaly, path); |
|
|
|
|
}); |
|
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "开始播放" + "}"; |
|
|
|
|
SubmitLogs(result, "PalyFile"); |
|
|
|
@ -1295,6 +1302,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
public static bool StopRecording() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (recordingProcess != null) |
|
|
|
|
{ |
|
|
|
|
// 如果进程还在运行 |
|
|
|
|
if (!recordingProcess.HasExited) |
|
|
|
@ -1303,6 +1312,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
|
|
|
|
|
recordingProcess.Kill(); |
|
|
|
|
recordingProcess.WaitForExit(); // 等待进程真正停止 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|