Exemplo n.º 1
0
        /// <summary>
        ///     上传资源
        /// </summary>
        /// <param name="localFile">本地文件的完整路径</param>
        /// <param name="resHandler">上传的结果回调</param>
        /// <param name="prgHandler">上传进度的回调</param>
        public static void Upload(string localFile, UploadResultHandler2 resHandler, ProgressResultHandler prgHandler, object userData = null)
        {
            ProgressData data = new ProgressData();

            data.FilePath = localFile;
            data.UserData = userData;
            ProgressPair pair = new ProgressPair(data, prgHandler);
            var          ptr1 = DelegateConverter.ConvertToIntPtr(resHandler);
            var          ptr2 = DelegateConverter.ConvertToIntPtr(pair);

            NosNativeMethods.nim_nos_upload(localFile, UploadCb2, ptr1, UploadPrgCb, ptr2);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     下载资源
        /// </summary>
        /// <param name="nosUrl">下载资源的URL</param>
        /// <param name="resHandler">下载的结果回调</param>
        /// <param name="prgHandler">下载进度的回调</param>
        public static void Download(string nosUrl, DownloadResultHandler resHandler, ProgressResultHandler prgHandler, object userData = null)
        {
            ProgressData data = new ProgressData();

            data.Url      = nosUrl;
            data.UserData = userData;
            ProgressPair pair = new ProgressPair(data, prgHandler);
            var          ptr1 = DelegateConverter.ConvertToIntPtr(resHandler);
            var          ptr2 = DelegateConverter.ConvertToIntPtr(pair);

            NosNativeMethods.nim_nos_download(nosUrl, DownloadCb, ptr1, DownloadPrgCb, ptr2);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     获取资源
        /// </summary>
        /// <param name="msg">消息体,NIMVideoMessage NIMAudioMessage NIMFileMessage等带msg_attach属性的有下载信息的消息</param>
        /// <param name="resHandler">下载的结果回调</param>
        /// <param name="prgHandler">下载进度的回调</param>
        public static void DownloadMedia(NIMIMMessage msg, DownloadResultHandler resHandler, ProgressResultHandler prgHandler, object userData = null)
        {
            ProgressData data = new ProgressData();

            data.Message  = msg;
            data.UserData = userData;
            ProgressPair pair    = new ProgressPair(data, prgHandler);
            var          ptr1    = DelegateConverter.ConvertToIntPtr(resHandler);
            var          ptr2    = DelegateConverter.ConvertToIntPtr(pair);
            var          msgJson = msg.Serialize();

            NosNativeMethods.nim_nos_download_media(msgJson, DownloadCb, ptr1, DownloadPrgCb, ptr2);
        }
Exemplo n.º 4
0
 public ProgressPair(ProgressData data, ProgressResultHandler action)
 {
     Data   = data;
     Action = action;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 获取资源
        /// </summary>
        /// <param name="msg">消息体,NIMVedioMessage NIMAudioMessage NIMFileMessage等带msg_attach属性的有下载信息的消息</param>
        /// <param name="resHandler">下载的结果回调</param>
        /// <param name="prgHandler">下载进度的回调</param>
        public static void DownloadMedia(NIMIMMessage msg, DownloadResultHandler resHandler, ProgressResultHandler prgHandler)
        {
            var ptr1    = NimUtility.DelegateConverter.ConvertToIntPtr(resHandler);
            var ptr2    = NimUtility.DelegateConverter.ConvertToIntPtr(prgHandler);
            var msgJson = msg.Serialize();

            NosNativeMethods.nim_nos_download_media(msgJson, DownloadCb, ptr1, DownloadPrgCb, ptr2);
        }