Esempio n. 1
0
        /// <summary>
        /// 上传资源
        /// </summary>
        /// <param name="localFile">本地文件的完整路径</param>
        /// <param name="resHandler">上传的结果回调</param>
        /// <param name="prgHandler">上传进度的回调</param>
        public static void Upload(string localFile, UploadResultHandler resHandler, ProgressResultHandler prgHandler)
        {
            var ptr1 = NimUtility.DelegateConverter.ConvertToIntPtr(resHandler);
            var ptr2 = NimUtility.DelegateConverter.ConvertToIntPtr(prgHandler);

            NosNativeMethods.nim_nos_upload(localFile, UploadCb, ptr1, UploadPrgCb, ptr2);
        }
Esempio 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)
        {
            var ptr1 = NimUtility.DelegateConverter.ConvertToIntPtr(resHandler);
            var ptr2 = NimUtility.DelegateConverter.ConvertToIntPtr(prgHandler);

            NosNativeMethods.nim_nos_download(nosUrl, DownloadCb, ptr1, DownloadPrgCb, ptr2);
        }
Esempio n. 3
0
        public static void InitNosTags(List <NIMNosTagInfo> tags, NIMNosInitResultCallback cb)
        {
            var json = NimUtility.Json.JsonParser.Serialize(tags);
            var ptr  = DelegateConverter.ConvertToIntPtr(cb);

            NosNativeMethods.nim_nos_init_config(json, NosInitCallback, null, ptr);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// Nos模块初始化接口,对上传资源时使用的各场景资源生命周期进行初始化,开发者最多可自定义10个场景,并指定场景资源的生命周期,并可以对缺省场景(kNIMNosDefaultTagResource、kNIMNosDefaultTagIM)进行覆盖(重新指定生命周期)
        /// </summary>
        /// <param name="json_tags">tags 标签(json形式)</param>
        /// <param name="handler">回调函数</param>
        /// <param name="json_extension">拓展参数</param>
        public static void InitConfig(List <InitConfigParams> tags, InitConfigHandler handler, string json_extension = null)
        {
            var    ptr       = DelegateConverter.ConvertToIntPtr(handler);
            string json_tags = "";

            if (tags != null)
            {
                json_tags = JsonConvert.SerializeObject(tags);
            }
            NosNativeMethods.nim_nos_init_config(json_tags, InitConfigCbFunc, json_extension, ptr);
        }
Esempio n. 6
0
        /// <summary>
        /// 上传资源
        /// </summary>
        /// <param name="localFile">本地文件的完整路径</param>
        /// <param name="tag">场景标签,主要用于确定文件的保存时间</param>
        /// <param name="resHandler">上传的结果回调</param>
        /// <param name="prgHandler">上传进度的回调</param>
        public static void Upload2(string localFile, string tag, 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_upload2(localFile, tag, UploadCb2, ptr1, UploadPrgCb, ptr2);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        /// <summary>
        ///下载资源(扩展)
        /// </summary>
        /// <param name="url">下载资源的URL</param>
        /// <param name="param">http 扩展参数</param>
        /// <param name="resCb">下载结果的回调函数</param>
        /// <param name="resData">下载结果回调自定义用户数据,</param>
        /// <param name="prgCb">下载进度的回调函数</param>
        /// <param name="prgData">进度回调自定义用户数据</param>
        /// <param name="speedCb">下载速度的回调函数</param>
        /// <param name="speedData">下载速度回调自定义用户数据</param>
        /// <param name="infoCb">返回最终下载信息的回调函数</param>
        /// <param name="infoData">下载信息回调的自定义用户数据</param>
        public static void DownloadEx(string url,
                                      HttpExtendedParameters param,
                                      DownloadCb resCb, IntPtr resData,
                                      DownloadPrgCb prgCb, IntPtr prgData,
                                      DownloadSpeedCb speedCb, IntPtr speedData,
                                      DownloadInfoCb infoCb, IntPtr infoData)
        {
            CallbackDataPair resPair   = new CallbackDataPair(resCb, resData);
            CallbackDataPair prgPair   = new CallbackDataPair(prgCb, prgData);
            CallbackDataPair speedPair = new CallbackDataPair(speedCb, speedData);
            CallbackDataPair infoPair  = new CallbackDataPair(infoCb, infoData);

            NosNativeMethods.nim_nos_download_ex(url,
                                                 param != null ? param.Serialize() : string.Empty,
                                                 DownloadResultCallbackEx, resPair.ToIntPtr(),
                                                 DownloadPrgCallbackEx, prgPair.ToIntPtr(),
                                                 DownloadSpeedCallbackEx, speedPair.ToIntPtr(),
                                                 DownloadInfoCallbackEx, infoPair.ToIntPtr());
        }
Esempio n. 10
0
        /// <summary>
        /// 上传资源(扩展)
        /// </summary>
        /// <param name="localFile">本地文件的完整路径</param>
        /// <param name="tag">场景标签,主要用于确定文件的保存时间</param>
        /// <param name="param">参数配置</param>
        /// <param name="resCb">上传的回调函数</param>
        /// <param name="resData">APP的自定义用户数据,SDK只负责传回给回调函数resCb,不做任何处理!</param>
        /// <param name="prgCb">上传进度的回调函数</param>
        /// <param name="prgData">APP的自定义用户数据,SDK只负责传回给回调函数prgCb,不做任何处理!</param>
        /// <param name="speedCb">上传速度的回调函数</param>
        /// <param name="speedData">peed_user_data APP的自定义用户数据,SDK只负责传回给回调函数speedCb,不做任何处理!</param>
        /// <param name="infoCb">info_cb 返回最终上传信息的回调函数</param>
        /// <param name="infoData"> APP的自定义用户数据,SDK只负责传回给回调函数infoCb,不做任何处理!</param>
        public static void UploadEx2(string localFile,
                                     string tag,
                                     HttpExtendedParameters param,
                                     UploadCb resCb, IntPtr resData,
                                     UploadPrgCb prgCb, IntPtr prgData,
                                     UploadSpeedCb speedCb, IntPtr speedData,
                                     UploadInfoCb infoCb, IntPtr infoData)
        {
            CallbackDataPair resPair   = new CallbackDataPair(resCb, resData);
            CallbackDataPair prgPair   = new CallbackDataPair(prgCb, prgData);
            CallbackDataPair speedPair = new CallbackDataPair(speedCb, speedData);
            CallbackDataPair infoPair  = new CallbackDataPair(infoCb, infoData);

            NosNativeMethods.nim_nos_upload_ex2(localFile, tag,
                                                param != null ? param.Serialize() : string.Empty,
                                                UploadCallbackEx, resPair.ToIntPtr(),
                                                UploadPrgCallbackEx, prgPair.ToIntPtr(),
                                                UploadSpeedCallbackEx, speedPair.ToIntPtr(),
                                                UploadInfoCallbackEx, infoPair.ToIntPtr());
        }
Esempio n. 11
0
        /// <summary>
        /// 获取资源(扩展)
        /// </summary>
        /// <param name="msg">包含附件的消息体</param>
        ///<param name="param">下载扩展信息</param>
        /// <param name="resCb"></param>
        /// <param name="resData"></param>
        /// <param name="prgCb"></param>
        /// <param name="prgData"></param>
        /// <param name="speedCb"></param>
        /// <param name="speedData"></param>
        /// <param name="infoCb"></param>
        /// <param name="infoData"></param>
        public static void DownloadMediaEx(NIMIMMessage msg,
                                           HttpExtendedParameters param,
                                           DownloadCb resCb, IntPtr resData,
                                           DownloadPrgCb prgCb, IntPtr prgData,
                                           DownloadSpeedCb speedCb, IntPtr speedData,
                                           DownloadInfoCb infoCb, IntPtr infoData)
        {
            var msgJson = msg.Serialize();
            CallbackDataPair resPair   = new CallbackDataPair(resCb, resData);
            CallbackDataPair prgPair   = new CallbackDataPair(prgCb, prgData);
            CallbackDataPair speedPair = new CallbackDataPair(speedCb, speedData);
            CallbackDataPair infoPair  = new CallbackDataPair(infoCb, infoData);

            NosNativeMethods.nim_nos_download_media_ex(msgJson,
                                                       param == null ? null : param.Serialize(),
                                                       DownloadResultCallbackEx, resPair.ToIntPtr(),
                                                       DownloadPrgCallbackEx, prgPair.ToIntPtr(),
                                                       DownloadSpeedCallbackEx, speedPair.ToIntPtr(),
                                                       DownloadInfoCallbackEx, infoPair.ToIntPtr());
        }
Esempio n. 12
0
 /// <summary>
 /// 停止下载资源(只能用于调用了nim_nos_download_ex接口的下载任务)
 /// </summary>
 /// <param name="taskId"></param>
 /// <param name="ext"></param>
 public static void StopDownloadEx(string taskId, string ext = null)
 {
     NosNativeMethods.nim_nos_stop_download_ex(taskId, ext);
 }
Esempio n. 13
0
        /// <summary>
        /// (全局回调)注册上传回调,通过注册回调获得HTTP上传结果通知(所有触发HTTP上传任务的接口的参数列表里无法设置通知回调处理函数的通知都走这个通知,比如发送文件图片语音消息等)
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="data"></param>
        public static void RegisterDefaultUploadCallback(UploadCb callback, IntPtr data)
        {
            CallbackDataPair pair = new CallbackDataPair(callback, data);

            NosNativeMethods.nim_nos_reg_upload_cb(UploadCallbackEx, pair.ToIntPtr());
        }
Esempio n. 14
0
        /// <summary>
        /// 安全链接(短链)换源链接
        /// </summary>
        /// <param name="safeUrl">安全链接(短链)</param>
        /// <param name="cb"></param>
        public static void ConvertSafeUrlToOrigin(string safeUrl, SafeUrlConverterCb cb)
        {
            var ptr = DelegateConverter.ConvertToIntPtr(cb);

            NosNativeMethods.nim_nos_safeurl_to_originurl(safeUrl, null, SafeUrlConverterCallback, ptr);
        }
Esempio n. 15
0
        /// <summary>
        ///     注册下载回调,通过注册回调获得http下载结果通知,刷新资源
        /// </summary>
        /// <param name="handler">下载的结果回调</param>
        ///

        public static void RegDownloadCb(DownloadResultHandler handler)
        {
            var ptr = DelegateConverter.ConvertToIntPtr(handler);

            NosNativeMethods.nim_nos_reg_download_cb(DownloadCb, ptr);
        }
Esempio n. 16
0
 /// <summary>
 /// 设置是否支持快速上传
 /// </summary>
 /// <param name="trans">0:不支持,1:支持</param>
 public static void SetQuickTrans(int trans)
 {
     NosNativeMethods.nim_nos_set_quick_trans(trans);
 }
Esempio n. 17
0
        public static void StopDownloadMedia(NIMIMMessage msg)
        {
            var msgJson = msg.Serialize();

            NosNativeMethods.nim_nos_stop_download_media(msgJson);
        }
Esempio n. 18
0
        /// <summary>
        /// 对上传资源时使用的各场景资源生命周期进行初始化,开发者最多可自定义10个场景,
        /// 并指定场景资源的生命周期,并可以对缺省场景("nim_default_im"、"nim_default_profile_icon")进行覆盖(重新指定生命周期)
        /// </summary>
        public static void InitNosTags(System.Collections.Generic.List <NosTagInfo> tags)
        {
            var json = NimUtility.Json.JsonParser.Serialize(tags);

            NosNativeMethods.nim_nos_init_config(json, null, null, IntPtr.Zero);
        }