Impl sendFile

This commit is contained in:
Changhua 2023-03-21 21:56:16 +08:00
parent 0bc9b754a4
commit d73339e9e2
2 changed files with 16 additions and 0 deletions

View File

@ -154,6 +154,19 @@ public class Client {
return ret;
}
public int sendFile(String path, String receiver) {
Wcf.PathMsg pathMsg = Wcf.PathMsg.newBuilder().setPath(path).setReceiver(receiver).build();
Request req = new Request.Builder().setFuncValue(Functions.FUNC_SEND_FILE_VALUE).setFile(pathMsg).build();
logger.debug("sendFile: {}", bytesToHex(req.toByteArray()));
Response rsp = sendCmd(req);
int ret = -1;
if (rsp != null) {
ret = rsp.getStatus();
}
return ret;
}
public void waitMs(int ms) {
try {
Thread.sleep(ms);

View File

@ -35,5 +35,8 @@ public class Main {
// 发送图片消息图片必须要存在
client.sendImage("C:\\Projs\\WeChatFerry\\TEQuant.jpeg", "filehelper");
// 发送文件消息文件必须要存在
client.sendFile("C:\\Projs\\WeChatFerry\\README.MD", "filehelper");
}
}