|
关于调用BVCU.dll中File_Transfer的问题
目的是想在IM中发送图片,还有接收IM中的图片和文件
对BVCU中文件的传输函数进行了封装
int CBVCU::fileTransfer(int _bUpload,char* localFilePath, char* remoteFilePath,char* _szTargetID,BVCU_HSession* session,BVCU_FileTrans_OnEvent onEvent)
{
BVCU_File_HTransfer fileHTransfer=NULL;
BVCU_File_TransferParam transferParam;
memset(&transferParam, 0, sizeof(transferParam));
//初始化传递的参数
transferParam.iSize=sizeof(transferParam);
transferParam.pUserData=0;
transferParam.iTimeOut=10000;
transferParam.pLocalFilePathName=localFilePath;
transferParam.pRemoteFilePathName=remoteFilePath;
transferParam.bUpload=1;
transferParam.iFileStartOffset=-1;
transferParam.hSession=session;
strcpy_s(transferParam.szTargetID,sizeof(transferParam.szTargetID),_szTargetID);
transferParam.bUpload=_bUpload;//0下载,1上传
//定义一个回调函数
transferParam.OnEvent=fileTransfer_OnEvent;
//启动文件的传输程序
BVCU_Result result=BVCU_FileTransfer_Open(&fileHTransfer,&transferParam);//返回值
if (BVCU_Result_SUCCEEDED(result))
{
m_procFileTransferEvent = onEvent;
}
return result;
}//封装调用的函数
然后导出了接口
LIB_MANAGED_LAYER_API int ManagedLayer_FileTransfer(const int* handle, BVCU_HSession* session,int _bUpload,char* localFilePath, char* remoteFilePath,char* _szTargetID,BVCU_FileTrans_OnEvent onEvent)
{
CBVCU* bvcu = (CBVCU*)handle;
return bvcu->fileTransfer(_bUpload,localFilePath,remoteFilePath,_szTargetID,session,onEvent);
}
C#进行了调用
public void fileOperater(string localPath, string remotePath, int bupload)
{
//包装文件的操作
try
{
int ret = BVCU.ManagedLayer_FileTransfer(m_bvsdkHandle,ref m_server.sessionHandle,bupload,
Encoding.UTF8.GetBytes(localPath), Encoding.UTF8.GetBytes(remotePath), m_bvsdkEventHandler.fileTransfer_OnEvent);
// 返回了一个值
BVCU.FAILED(ret);
}
catch
{
MessageBox.Show("文件上传下载失败");
}
}
但是遇到的问题就是调用函数BVCU_FileTransfer_Open不成功,返回值是-65535
请哪位大神能指教一下用sencmds 发送图片或者文件的流程,和如何传递参数 |
|