Skip to content

Commit

Permalink
现在,支持音频和视频传输协议
Browse files Browse the repository at this point in the history
修复大量bug
  • Loading branch information
XFEstudio committed Nov 5, 2023
1 parent 5080f16 commit 0642bd4
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions XFE各类拓展/CyberComm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,11 @@ public enum XCCBinaryMessageType
/// <summary>
/// 音频消息
/// </summary>
Audio
Audio,
/// <summary>
/// 视频消息
/// </summary>
Video
}
/// <summary>
/// XFE网络通信明文返回消息类型
Expand All @@ -885,7 +889,15 @@ public enum XCCTextMessageType
/// <summary>
/// 图片消息
/// </summary>
Image
Image,
/// <summary>
/// 音频消息
/// </summary>
Audio,
/// <summary>
/// 视频消息
/// </summary>
Video
}
class XCCNetWorkBase
{
Expand Down Expand Up @@ -1120,11 +1132,15 @@ public async Task StartXCC(bool autoReconnect = true, int reconnectMaxTimes = -1
case "[XCCTextMessage]":
messageType = XCCTextMessageType.Text;
break;

case "[XCCImage]":
messageType = XCCTextMessageType.Image;
break;

case "[XCCAudio]":
messageType = XCCTextMessageType.Audio;
break;
case "[XCCVideo]":
messageType = XCCTextMessageType.Video;
break;
default:
break;
}
Expand Down Expand Up @@ -1156,6 +1172,9 @@ public async Task StartXCC(bool autoReconnect = true, int reconnectMaxTimes = -1
case "audio":
messageType = XCCBinaryMessageType.Audio;
break;
case "video":
messageType = XCCBinaryMessageType.Video;
break;
case "callback":
UpdateTaskTrigger?.Invoke(true, messageId);
continue;
Expand Down Expand Up @@ -1203,7 +1222,7 @@ public async Task StartXCC(bool autoReconnect = true, int reconnectMaxTimes = -1
/// <param name="message">待发送的文本</param>
/// <param name="timeout">最长超时时长</param>
/// <returns>服务器接收校验是否成功</returns>
public async Task<bool> SendTextMessage(string message, int timeout = 10000)
public async Task<bool> SendTextMessage(string message, int timeout = 30000)
{
var messageId = Guid.NewGuid().ToString();
return await SendTextMessage(message, messageId, timeout);
Expand Down Expand Up @@ -1337,14 +1356,31 @@ public async Task<bool> SendImage(string filePath)
{
try
{
return await SendSignedBinaryMessage(File.ReadAllBytes(filePath), "image", 30000);
return await SendSignedBinaryMessage(File.ReadAllBytes(filePath), "image", 60000);
}
catch (Exception ex)
{
throw new XFECyberCommException("客户端发送图片到服务器时出现异常", ex);
}
}
/// <summary>
/// 发送视频
/// </summary>
/// <param name="filePath">视频路径</param>
/// <returns>服务器接收校验是否成功</returns>
/// <exception cref="XFECyberCommException"></exception>
public async Task<bool> SendVideo(string filePath)
{
try
{
return await SendSignedBinaryMessage(File.ReadAllBytes(filePath), "video", 300000);
}
catch (Exception ex)
{
throw new XFECyberCommException("客户端发送视频到服务器时出现异常", ex);
}
}
/// <summary>
/// 发送音频
/// </summary>
/// <param name="buffer">二进制音频流</param>
Expand Down

0 comments on commit 0642bd4

Please sign in to comment.