Пример #1
0
 public bool SendFileToAll(string filePath, string destPath = "")
 {
     byte[] data = AddHead(filePath, destPath);
     if (data == null)
     {
         return(false);
     }
     _tcpServer.SendToAllClient(data, 0, data.Length);
     OnSendFile?.Invoke($"client:allClient,filepath:{filePath}");
     return(true);
 }
Пример #2
0
 public bool SendFile(string ip, string filePath, string destPath = "")
 {
     byte[] data = AddHead(filePath, destPath);
     if (data == null)
     {
         return(false);
     }
     _tcpServer.Send(ip, data, 0, data.Length);
     OnSendFile?.Invoke($"ip:{ip},filepath:{filePath}");
     return(true);
 }
Пример #3
0
 public bool SendFile(int connectId, string filePath, string destPath = "")
 {
     byte[] data = AddHead(filePath, destPath);
     if (data == null)
     {
         return(false);
     }
     _tcpServer.Send(connectId, data, 0, data.Length);
     OnSendFile?.Invoke($"connectid:{connectId.ToString()},filepath:{filePath}");
     return(true);
 }
Пример #4
0
 public int SendFileSyn(string fileName, string destFolder = "")
 {
     _synSendLength = SendFile(fileName, destFolder);
     if (Wait())
     {
         OnSendFile?.Invoke(fileName);
         return(_synSendLength);
     }
     else
     {
         OnError?.Invoke($"SendFileSyn error {fileName}");
     }
     return(0);
 }
Пример #5
0
 public int SendFile(string fileName, string destFolder = "")
 {
     if (Connected)
     {
         byte[] data = AddHead(fileName, destFolder);
         if (data != null)
         {
             _tcpClients.Send(data, 0, data.Length);
             OnSendFile?.Invoke(fileName);
             return(data.Length);
         }
         else
         {
             OnError?.Invoke($"Read file error {fileName}");
         }
     }
     return(0);
 }