private void okButton_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex != 0 && !string.IsNullOrEmpty(hostTextBox.Text) && !string.IsNullOrEmpty(portTextBox.Text)) { NIMProxyType proxyType = (NIMProxyType)(comboBox1.SelectedIndex + 3); Proxy proxy = new Proxy(); proxy.Type = proxyType; proxy.Host = hostTextBox.Text; proxy.Port = ushort.Parse(portTextBox.Text); proxy.UserName = unameTextBox.Text; proxy.Password = pwdTextBox.Text; proxy.IsValid = true; SaveProxySetting(proxy); this.Close(); } else { MessageBox.Show("代理无效,请重新设置"); } }
/// <summary> /// 设置SDK统一的网络代理。不需要代理时,type设置为kNIMProxyNone,其余参数都传空字符串(端口设为0)。有些代理不需要用户名和密码,相应参数也传空字符串 /// </summary> /// <param name="type"></param> /// <param name="host"></param> /// <param name="port"></param> /// <param name="user"></param> /// <param name="password"></param> public static void SetProxy(NIMProxyType type, string host, int port, string user, string password) { nim_global_set_proxy(type, host, port, user, password); }
private static extern void nim_global_set_proxy(NIMProxyType type, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string host, int port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string user, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string password);
internal static extern bool nim_vchat_set_proxy(NIMProxyType type, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NimUtility.Utf8StringMarshaler))] string host, int port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NimUtility.Utf8StringMarshaler))] string user, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NimUtility.Utf8StringMarshaler))] string password);
/// <summary> /// 测试代理 /// </summary> /// <param name="type">代理类型</param> /// <param name="host">代理地址</param> /// <param name="port">代理端口</param> /// <param name="user">代理用户名</param> /// <param name="password">代理密码</param> /// <param name="cb"></param> public static void DetectProxy(NIMProxyType type, string host, int port, string user, string password, NimProxyDetectionDelegate cb) { var ptr = DelegateConverter.ConvertToIntPtr(cb); NIMGlobalNativeMethods.nim_global_detect_proxy(type, host, port, user, password, ProxyDetectionCallback, ptr); }
/// <summary> /// 设置SDK音视频的网络代理,暂时只支持socks5代理,全局代理接口也能设置音视频的代理,两接口没有优先级区别。 /// 不需要代理时,type设置为kNIMProxyNone,其余参数都传空字符串(端口设为0)。有些代理不需要用户名和密码,相应参数也传空字符串。 /// </summary> /// <param name="type">代理类型,见NIMProxyType定义,其中音视频和白板暂时只支持kNIMProxySocks5代理</param> /// <param name="host">代理地址</param> /// <param name="port">代理端口</param> /// <param name="user">代理用户名</param> /// <param name="password">代理密码</param> public static void NIMVChatSetProxy(NIMProxyType type, string host, int port, string user, string password) { VChatNativeMethods.nim_vchat_set_proxy(type, host, port, user, password); }
internal static extern void nim_global_detect_proxy(NIMProxyType type, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string host, int port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string user, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))] string password, nim_global_detect_proxy_cb_func cb, IntPtr user_data);
/// <summary> /// 设置SDK白板的网络代理,暂时只支持socks5代理,全局代理接口也能设置音视频的代理,两接口没有优先级区别。 /// 不需要代理时,type设置为kNIMProxyNone,其余参数都传空字符串(端口设为0)。有些代理不需要用户名和密码,相应参数也传空字符串。 /// </summary> /// <param name="type">代理类型,见NIMProxyType定义,其中音视频和白板暂时只支持kNIMProxySocks5代理</param> /// <param name="host">代理地址</param> /// <param name="port">代理端口</param> /// <param name="user">代理用户名</param> /// <param name="password">代理密码</param> public static void SetProxy(NIMProxyType type, string host, int port, string user, string password) { RtsNativeMethods.nim_rts_set_proxy(type, host, port, user, password); }