Exemple #1
0
 /// <summary>
 /// 从远程客户端接收文件
 /// </summary>
 /// <param name="msg">Message</param>
 /// <param name="remtoe">IPEndPoint</param>
 private static async Task ReceiveClientFile(Message msg, IPEndPoint remtoe)
 {
     if (msg.Udp)
     {
         ProcessFileByUdp process = new ProcessFileByUdp();
         await process.ReceiveClientFile(msg, remtoe);
     }
     else
     {
         ProcessFileByTcp process = new ProcessFileByTcp();
         await process.ReceiveClientFile(msg, remtoe);
     }
 }
Exemple #2
0
 /// <summary>
 /// 发送文件到远程客户端
 /// </summary>
 /// <param name="ip">IP</param>
 /// <param name="port">Port</param>
 /// <param name="filePath">文件路径</param>
 /// <param name="msg">信息内容</param>
 public static async Task SendFileToClient(string ip, int port, string filePath, Message msg, bool udp = true)
 {
     if (udp)
     {
         msg.Udp = true;  // Udp 传输文件
         ProcessFileByUdp process = new ProcessFileByUdp();
         await process.SendToClientFileAsync(ip, port, filePath, msg).ConfigureAwait(false);
     }
     else
     {
         msg.Udp = false;  // Tcp 传输文件
         ProcessFileByTcp process = new ProcessFileByTcp();
         await process.SendToClientFileAsync(ip, port, filePath, msg).ConfigureAwait(false);
     }
 }