未验证 提交 066d124c 编写于 作者: O openharmony_ci 提交者: Gitee

!5098 【英文】翻译已完成4515&4331&4343

Merge pull request !5098 from shawn_he/OpenHarmony-3.1-Release
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import contact from '@ohos.contact';
```
......@@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result.
**Example**
```
```js
contact.addContact({
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result.
**Example**
```
```js
let promise = contact.addContact({
name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron
**Example**
```
```js
contact.deleteContact('xxx', (err) => {
if (err) {
console.log(`deleteContact callback: err->${JSON.stringify(err)}`);
......@@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to
**Example**
```
```js
let promise = contact.deleteContact('xxx');
promise.then(() => {
console.log(`deleteContact success`);
......@@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a
**Example**
```
```js
contact.updateContact({
name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example**
```
```js
contact.updateContact({
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example**
```
```js
let promise = contact.updateContact({
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example**
```
```js
contact.isLocalContact(/*id*/1, (err, data) => {
if (err) {
console.log(`isLocalContact callback: err->${JSON.stringify(err)}`);
......@@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example**
```
```js
let promise = contact.isLocalContact(/*id*/1);
promise.then((data) => {
console.log(`isLocalContact success: data->${JSON.stringify(data)}`);
......@@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c
**Example**
```
```js
contact.isMyCard(/*id*/1, (err, data) => {
if (err) {
console.log(`isMyCard callback: err->${JSON.stringify(err)}`);
......@@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu
**Example**
```
```js
let promise = contact.isMyCard(/*id*/1);
promise.then((data) => {
console.log(`isMyCard success: data->${JSON.stringify(data)}`);
......@@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result.
**Example**
```
```js
contact.queryMyCard((err, data) => {
if (err) {
console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
......@@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn
**Example**
```
```js
contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME']
}, (err, data) => {
......@@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
**Example**
```
```js
let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME']
});
......@@ -465,8 +465,6 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void
Selects a contact. This API uses an asynchronous callback to return the result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
**Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData
......@@ -478,7 +476,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example**
```
```js
contact.selectContact((err, data) => {
if (err) {
console.log(`selectContact callback: err->${JSON.stringify(err)}`);
......@@ -495,8 +493,6 @@ selectContact(): Promise<Array<Contact>>
Selects a contact. This API uses a promise to return the result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
**Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData
......@@ -508,7 +504,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example**
```
```js
let promise = contact.selectContact();
promise.then((data) => {
console.log(`selectContact success: data->${JSON.stringify(data)}`);
......@@ -536,7 +532,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call
**Example**
```
```js
contact.queryContact('xxx', (err, data) => {
if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`);
......@@ -566,7 +562,7 @@ Queries contacts based on the specified key and application. This API uses an as
**Example**
```
```js
contact.queryContact('xxx', {
holderId: 0
}, (err, data) => {
......@@ -598,7 +594,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy
**Example**
```
```js
contact.queryContact('xxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -631,7 +627,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example**
```
```js
contact.queryContact('xxx', {
holderId: 0
}, {
......@@ -670,7 +666,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example**
```
```js
let promise = contact.queryContact('xxx', {
holderId: 0
}, {
......@@ -701,7 +697,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul
**Example**
```
```js
contact.queryContacts((err, data) => {
if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
......@@ -730,7 +726,7 @@ Queries all contacts based on the specified application. This API uses an asynch
**Example**
```
```js
contact.queryContacts({
holderId: 0
}, (err, data) => {
......@@ -761,7 +757,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr
**Example**
```
```js
contact.queryContacts({
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -793,7 +789,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example**
```
```js
contact.queryContacts({
holderId: 0
}, {
......@@ -831,7 +827,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example**
```
```js
let promise = contact.queryContacts({
holderId: 0
}, {
......@@ -863,7 +859,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => {
if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
......@@ -893,7 +889,7 @@ Queries contacts based on the specified phone number and application. This API u
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0
}, (err, data) => {
......@@ -925,7 +921,7 @@ Queries contacts based on the specified phone number and attributes. This API us
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -958,7 +954,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0
}, {
......@@ -997,7 +993,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example**
```
```js
let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0
}, {
......@@ -1029,7 +1025,7 @@ Queries contacts based on the specified email address. This API uses an asynchro
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', (err, data) => {
if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
......@@ -1059,7 +1055,7 @@ Queries contacts based on the specified email address and application. This API
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', {
holderId: 0
}, (err, data) => {
......@@ -1091,7 +1087,7 @@ Queries contacts based on the specified email address and attributes. This API u
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -1124,7 +1120,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', {
holderId: 0
}, {
......@@ -1163,7 +1159,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example**
```
```js
let promise = contact.queryContactsByEmail('xxx@email.com', {
holderId: 0
}, {
......@@ -1194,7 +1190,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re
**Example**
```
```js
contact.queryGroups((err, data) => {
if (err) {
console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
......@@ -1223,7 +1219,7 @@ Queries all groups of this contact based on the specified application. This API
**Example**
```
```js
contact.queryGroups({
holderId: 0
}, (err, data) => {
......@@ -1258,7 +1254,7 @@ Queries all groups of this contact based on the specified application. This API
**Example**
```
```js
let promise = contact.queryGroups({
holderId: 0
});
......@@ -1287,7 +1283,7 @@ Queries all applications that have created contacts. This API uses an asynchrono
**Example**
```
```js
contact.queryHolders((err, data) => {
if (err) {
console.log(`queryHolders callback: err->${JSON.stringify(err)}`);
......@@ -1315,7 +1311,7 @@ Queries all applications that have created contacts. This API uses a promise to
**Example**
```
```js
let promise = contact.queryHolders();
promise.then((data) => {
console.log(`queryHolders success: data->${JSON.stringify(data)}`);
......@@ -1343,7 +1339,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an
**Example**
```
```js
contact.queryKey(/*id*/1, (err, data) => {
if (err) {
console.log(`queryKey callback: err->${JSON.stringify(err)}`);
......@@ -1373,7 +1369,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example**
```
```js
contact.queryKey(id, {
holderId:1
}, (err, data) => {
......@@ -1409,7 +1405,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example**
```
```js
let promise = contact.queryKey(id, {
holderId: 0
});
......@@ -1462,7 +1458,7 @@ Defines a contact.
Create contact data in JSON format:
```
```js
let myContact = {
phoneNumbers: [{
phoneNumber: "138xxxxxxxx"
......@@ -1480,7 +1476,7 @@ let myContact = {
Or, create data by configuring a new Contact object.
```
```js
let myContact = new contact.Contact();
let name = new contact.Name();
name.fullName = "fullName";
......@@ -1508,7 +1504,7 @@ If **null** is passed, all attributes are queried by default.
Create contact data in JSON format:
```
```js
let contactAttributes = {
attributes: [
contact.Attribute.ATTR_EMAIL,
......@@ -1521,7 +1517,7 @@ let contactAttributes = {
Or, create data by configuring a **ContactAttributes** object.
```
```js
let contactAttributes = new contact.ContactAttributes();
contactAttributes.attributes = ["ATTR_EMAIL"];
```
......@@ -1555,7 +1551,7 @@ Enumerates contact attributes.
Create contact data in JSON format:
```
```js
let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE];
```
......@@ -1591,7 +1587,7 @@ Defines a contact's email.
Create contact data in JSON format:
```
```js
let email = {
email: "xxx@email.com",
displayName: "displayName"
......@@ -1601,7 +1597,7 @@ let email = {
Or, create data by configuring an **Email** object.
```
```js
let email = new contact.Email();
email.email = "xxx@email.com";
```
......@@ -1624,7 +1620,7 @@ Defines an application that creates the contact.
Create contact data in JSON format:
```
```js
let holder = {
holderId: 0
};
......@@ -1632,7 +1628,7 @@ let holder = {
Or, create data by configuring a **Holder** object.
```
```js
let holder = new contact.Holder();
holder.holderId = 0;
```
......@@ -1668,7 +1664,7 @@ Defines a contact's event.
Create contact data in JSON format:
```
```js
let event = {
eventDate: "xxxxxx"
};
......@@ -1676,7 +1672,7 @@ let event = {
Or, create data by configuring an **Event** object.
```
```js
let event = new contact.Event();
event.eventDate = "xxxxxx";
```
......@@ -1698,7 +1694,7 @@ Defines a contact group.
Create contact data in JSON format:
```
```js
let group = {
groupId: 1,
title: "title"
......@@ -1707,7 +1703,7 @@ let group = {
Or, create data by configuring a **Group** object.
```
```js
let group = new contact.Group();
group.title = "title";
```
......@@ -1747,7 +1743,7 @@ Enumerates IM addresses.
Create contact data in JSON format:
```
```js
let imAddress = {
imAddress: "imAddress",
labelName: "labelName"
......@@ -1757,7 +1753,7 @@ let imAddress = {
Or, create data by configuring an **ImAddress** object.
```
```js
let imAddress = new contact.ImAddress();
imAddress.imAddress = "imAddress";
```
......@@ -1786,7 +1782,7 @@ Defines a contact's name.
Create contact data in JSON format:
```
```js
let name = {
familyName: "familyName",
fullName: "fullName"
......@@ -1795,7 +1791,7 @@ let name = {
Or, create data by configuring a **Name** object.
```
```js
let name = new contact.Name();
name.familyName = "familyName";
name.fullName = "fullName";
......@@ -1817,7 +1813,7 @@ Defines a contact's nickname.
Create contact data in JSON format:
```
```js
let nickName = {
nickName: "nickName"
};
......@@ -1825,7 +1821,7 @@ let nickName = {
Or, create data by configuring a **NickName** object.
```
```js
let nickName = new contact.NickName();
nickName.nickName = "nickName";
```
......@@ -1846,7 +1842,7 @@ Defines a contact's note.
Create contact data in JSON format:
```
```js
let note = {
noteContent: "noteContent"
};
......@@ -1854,7 +1850,7 @@ let note = {
Or, create data by configuring a **Note** object.
```
```js
let note = new contact.Note();
note.noteContent = "noteContent";
```
......@@ -1876,7 +1872,7 @@ Defines a contact's organization.
Create contact data in JSON format:
```
```js
let organization = {
name: "name",
title: "title"
......@@ -1885,7 +1881,7 @@ let organization = {
Or, create data by configuring an **Organization** object.
```
```js
let organization = new contact.Organization();
organization.name = "name";
organization.title = "title";
......@@ -1939,7 +1935,7 @@ Defines a contact's phone number.
Create contact data in JSON format:
```
```js
let phoneNumber = {
phoneNumber: "138xxxxxxxx",
labelId: contact.PhoneNumber.NUM_HOME
......@@ -1948,7 +1944,7 @@ let phoneNumber = {
Or, create data by configuring a new **PhoneNumber** object.
```
```js
let phoneNumber = new contact.PhoneNumber();
phoneNumber.phoneNumber = "138xxxxxxxx";
```
......@@ -1969,7 +1965,7 @@ Defines a contact's portrait.
Create contact data in JSON format:
```
```js
let portrait = {
uri: "uri"
};
......@@ -1977,7 +1973,7 @@ let portrait = {
Or, create data by configuring a new **Portrait** object.
```
```js
let portrait = new contact.Portrait();
portrait.uri = "uri";
```
......@@ -2020,7 +2016,7 @@ Defines a contact's postal address.
Create contact data in JSON format:
```
```js
let postalAddress = {
city: "city"
};
......@@ -2028,7 +2024,7 @@ let postalAddress = {
Or, create data by configuring a new **PostalAddress** object.
```
```js
let postalAddress = new contact.PostalAddress();
postalAddress.city = "city";
```
......@@ -2075,7 +2071,7 @@ Defines a contact's relationship.
Create contact data in JSON format:
```
```js
let relation = {
relationName: "relationName",
labelId: contact.Relation.RELATION_ASSISTANT
......@@ -2084,7 +2080,7 @@ let relation = {
Or, create data by configuring a new **Relation** object.
```
```js
let relation = new contact.Relation();
relation.relationName = "relationName";
relation.labelId = contact.Relation.RELATION_ASSISTANT;
......@@ -2121,7 +2117,7 @@ Defines a contact's SIP address.
Create contact data in JSON format:
```
```js
var sipAddress = {
sipAddress: "sipAddress"
};
......@@ -2129,7 +2125,7 @@ var sipAddress = {
Or, create data by configuring a new **SipAddress** object.
```
```js
let sipAddress = new contact.SipAddress();
sipAddress.sipAddress = "sipAddress";
```
......@@ -2150,7 +2146,7 @@ Defines a contact's website.
Create contact data in JSON format:
```
```js
let website = {
website: "website"
};
......@@ -2158,7 +2154,7 @@ let website = {
Or, create data by configuring a new **Website** object.
```
```js
let website = new contact.Website();
website.website = "website";
```
......@@ -21,15 +21,15 @@ Provides the constants of all rule types.
| Name | Type| Description |
| ---------------------------------- | -------- | ------------------------------------------------------ |
| RULE_CAUTION_PRINT_LOG | bigInt | Alarm rule, which is programmed to print a log when an alarm is generated. |
| RULE_CAUTION_TRIGGER_CRASH | bigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated. |
| RULE_THREAD_CHECK_SLOW_PROCESS | bigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked. |
| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigInt | Caution rule, which is programmed to detect whether ability leakage has occurred. |
| RULE_CAUTION_PRINT_LOG | bigint | Alarm rule, which is programmed to print a log when an alarm is generated. |
| RULE_CAUTION_TRIGGER_CRASH | bigint | Alarm rule, which is programmed to force the application to exit when an alarm is generated. |
| RULE_THREAD_CHECK_SLOW_PROCESS | bigint | Caution rule, which is programmed to detect whether any time-consuming function is invoked. |
| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigint | Caution rule, which is programmed to detect whether ability leakage has occurred. |
## hichecker.addRule
addRule(rule: bigInt): void
addRule(rule: bigint): void
Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.
......@@ -39,7 +39,7 @@ Adds one or more rules. HiChecker detects unexpected operations or gives feedbac
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigInt | Yes | Rule to be added.|
| rule | bigint | Yes | Rule to be added.|
**Example**
......@@ -54,7 +54,7 @@ hichecker.addRule(
## hichecker.removeRule
removeRule(rule: bigInt): void
removeRule(rule: bigint): void
Removes one or more rules. The removed rules will become ineffective.
......@@ -64,7 +64,7 @@ Removes one or more rules. The removed rules will become ineffective.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigInt | Yes | Rule to be removed.|
| rule | bigint | Yes | Rule to be removed.|
**Example**
......@@ -79,7 +79,7 @@ hichecker.removeRule(
## hichecker.getRule
getRule(): bigInt
getRule(): bigint
Obtains a collection of thread, process, and alarm rules that have been added.
......@@ -89,7 +89,7 @@ Obtains a collection of thread, process, and alarm rules that have been added.
| Type | Description |
| ------ | ---------------------- |
| bigInt | Collection of added rules.|
| bigint | Collection of added rules.|
**Example**
......@@ -103,7 +103,7 @@ hichecker.getRule(); // return 1n;
## hichecker.contains
contains(rule: bigInt): boolean
contains(rule: bigint): boolean
Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread.
......@@ -113,7 +113,7 @@ Checks whether the specified rule exists in the collection of added rules. If th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigInt | Yes | Rule to be checked.|
| rule | bigint | Yes | Rule to be checked.|
**Return value**
......
......@@ -180,7 +180,7 @@ Defines the information about an input device.
## AxisType
Axis type. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
Defines the axis type of an input device, which is **NULL**.
## AxisRange
......
......@@ -319,7 +319,7 @@ Defines an SMS message instance.
| Name | Type | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ |
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.|
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the device can reply to the SMS message through the originating SMSC.|
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| messageClass | [ShortMessageClass](#shortmessageclass) | SMS message type. |
......
......@@ -3,7 +3,6 @@
>![](public_sys-resources/icon-note.gif) **NOTE:**
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>Newly added APIs are defined but not implemented in OpenHarmony 3.1 Release. They will be available for use in OpenHarmony 3.1 MR.
You can use WebSocket to establish a bidirectional connection between a server and a client. Before doing this, you need to use the [createWebSocket](#websocketcreatewebsocket) API to create a [WebSocket](#websocket) object and then use the [connect](#connect) API to connect to the server. If the connection is successful, the client will receive a callback of the [open](#onopen) event. Then, the client can communicate with the server using the [send](#send) API. When the server sends a message to the client, the client will receive a callback of the [message](#onmessage) event. If the client no longer needs this connection, it can call the [close](#close) API to disconnect from the server. Then, the client will receive a callback of the [close](#onclose) event.
......@@ -12,13 +11,13 @@ If an error occurs in any of the preceding processes, the client will receive a
## Modules to Import
```
```js
import webSocket from '@ohos.net.webSocket';
```
## Complete Example
```
```js
import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://";
......@@ -78,7 +77,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc
**Example**
```
```js
let ws = webSocket.createWebSocket();
```
......@@ -107,7 +106,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, (err, value) => {
......@@ -141,7 +140,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, {
......@@ -184,7 +183,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
let promise = ws.connect(url);
......@@ -215,7 +214,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, (err, value) => {
......@@ -254,7 +253,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, (err, value) => {
......@@ -286,7 +285,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.close((err, value) => {
......@@ -318,7 +317,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.close({
......@@ -358,7 +357,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
let promise = ws.close({
......@@ -391,7 +390,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
......@@ -419,7 +418,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u
**Example**
```
```js
let ws = webSocket.createWebSocket();
let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
......@@ -451,7 +450,7 @@ Enables listening for the **message** events of a WebSocket connection. This API
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('message', (err, value) => {
console.log("on message, message:" + value);
......@@ -480,7 +479,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.off('message');
```
......@@ -503,7 +502,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
......@@ -532,7 +531,7 @@ Disables listening for the **close** events of a WebSocket connection. This API
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.off('close');
```
......@@ -556,7 +555,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err))
......@@ -584,7 +583,7 @@ Disables listening for the **error** events of a WebSocket connection. This API
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.off('error');
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册