harmony 鸿蒙VpnExtensionContext
VpnExtensionContext
VpnExtensionContext represents the context of VpnExtensionAbility and is inherited from ExtensionContext.
This module provides the context required for APIs to access the resources of a VpnExtensionAbility object.
NOTE
The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version. The APIs of this module can be used only in the stage model.
Modules to Import
import { VpnExtensionAbility } from '@kit.NetworkKit';
How to Use
You can obtain a VpnExtensionContext object through a VpnExtensionAbility child class instance.
import { VpnExtensionAbility, vpnExtension } from '@kit.NetworkKit';
import { Want } from '@kit.AbilityKit';
export default class MyVpnExtAbility extends VpnExtensionAbility {
private vpnServerIp: string = 'xxx.xxx.x.x';
private tunIp: string = 'x.x.x.x';
private blockedAppName: string = 'xxxx';
onCreate(want: Want) {
let VpnConnection: vpnExtension.VpnConnection = vpnExtension.createVpnConnection(this.context);
console.info("vpn createVpnConnection: " + JSON.stringify(VpnConnection));
}
}
VpnExtensionAbility
Represents the VPN extension capability.
System capability: SystemCapability.Ability.AbilityRuntime.Core.
Model restriction: This API can be used only in the stage model.
Name | Type | Mandatory | Description |
---|---|---|---|
context | VpnExtensionContext | Yes | Specified context. |
onCreate
onCreate(want: Want): void
Represents the callback triggered when the extended VPN is initialized.
System capability: SystemCapability.Ability.AbilityRuntime.Core.
Model restriction: This API can be used only in the stage model.
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
want | Want | Yes | Want information. |
onDestroy
onDestroy(): void
Represents the callback triggered when the extended VPN is destroyed.
System capability: SystemCapability.Ability.AbilityRuntime.Core.
Model restriction: This API can be used only in the stage model.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙NetConn_ConnectionProperties
harmony 鸿蒙NetConn_NetCapabilities
harmony 鸿蒙NetConn_NetConnCallback
harmony 鸿蒙NetConn_NetHandleList
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦