@maccesar/titools 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -61
- package/lib/cleanup.js +29 -0
- package/lib/commands/agents.js +8 -7
- package/lib/commands/skills.js +118 -23
- package/lib/config.js +13 -15
- package/lib/installer.js +5 -3
- package/lib/utils.js +36 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +188 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +233 -0
- package/skills/alloy-guides/references/CONCEPTS.md +171 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +279 -0
- package/skills/alloy-guides/references/MODELS.md +742 -0
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +482 -0
- package/skills/alloy-guides/references/PURGETSS.md +57 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +235 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +375 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +102 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +581 -0
- package/skills/alloy-guides/references/WIDGETS.md +160 -0
- package/skills/alloy-howtos/SKILL.md +179 -0
- package/skills/alloy-howtos/references/best_practices.md +121 -0
- package/skills/alloy-howtos/references/cli_reference.md +230 -0
- package/skills/alloy-howtos/references/config_files.md +158 -0
- package/skills/alloy-howtos/references/custom_tags.md +148 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +78 -0
- package/skills/alloy-howtos/references/samples.md +156 -0
- package/skills/purgetss/SKILL.md +6 -3
- package/skills/purgetss/references/EXAMPLES.md +8 -6
- package/skills/purgetss/references/app-branding.md +5 -0
- package/skills/purgetss/references/apply-directive.md +1 -1
- package/skills/purgetss/references/class-categories.md +1 -1
- package/skills/purgetss/references/class-index-properties.md +618 -0
- package/skills/purgetss/references/class-index.md +4 -610
- package/skills/purgetss/references/cli-commands.md +15 -0
- package/skills/purgetss/references/custom-fonts.md +39 -36
- package/skills/purgetss/references/custom-rules.md +1 -1
- package/skills/purgetss/references/customization-deep-dive.md +64 -1
- package/skills/purgetss/references/icon-fonts.md +2 -0
- package/skills/purgetss/references/migration-guide.md +53 -1
- package/skills/purgetss/references/multi-density-images.md +53 -2
- package/skills/purgetss/references/svg-pipeline.md +249 -0
- package/skills/purgetss/references/tikit-components.md +2 -2
- package/skills/purgetss/references/titanium-resets.md +2 -2
- package/skills/purgetss/references/ui-ux-design.md +7 -5
- package/skills/purgetss/references/version-history.md +12 -0
- package/skills/ti-api/SKILL.md +128 -0
- package/skills/ti-api/references/api-android.md +675 -0
- package/skills/ti-api/references/api-app-platform.md +636 -0
- package/skills/ti-api/references/api-core.md +764 -0
- package/skills/ti-api/references/api-data-network.md +641 -0
- package/skills/ti-api/references/api-media.md +655 -0
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
- package/skills/ti-api/references/api-modules-map.md +632 -0
- package/skills/ti-api/references/api-modules-nfc.md +725 -0
- package/skills/ti-api/references/api-modules-social-misc.md +526 -0
- package/skills/ti-api/references/api-services.md +700 -0
- package/skills/ti-api/references/api-ui-android.md +499 -0
- package/skills/ti-api/references/api-ui-extras.md +702 -0
- package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
- package/skills/ti-api/references/api-ui-ios.md +756 -0
- package/skills/ti-api/references/api-ui-lists.md +581 -0
- package/skills/ti-api/references/api-ui-text-input.md +607 -0
- package/skills/ti-api/references/api-ui-views.md +572 -0
- package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
- package/skills/ti-api/references/api-xml-global.md +743 -0
- package/skills/ti-guides/SKILL.md +82 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +155 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +373 -0
- package/skills/ti-guides/references/application-frameworks.md +366 -0
- package/skills/ti-guides/references/cli-reference.md +700 -0
- package/skills/ti-guides/references/coding-best-practices.md +150 -0
- package/skills/ti-guides/references/commonjs-advanced.md +279 -0
- package/skills/ti-guides/references/hello-world.md +99 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +458 -0
- package/skills/ti-guides/references/javascript-primer.md +402 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +172 -0
- package/skills/ti-guides/references/style-and-conventions.md +104 -0
- package/skills/ti-guides/references/tiapp-config.md +655 -0
- package/skills/ti-howtos/SKILL.md +131 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +609 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +96 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +162 -0
- package/skills/ti-howtos/references/cross-platform-development.md +358 -0
- package/skills/ti-howtos/references/debugging-profiling.md +473 -0
- package/skills/ti-howtos/references/extending-titanium.md +684 -0
- package/skills/ti-howtos/references/google-maps-v2.md +172 -0
- package/skills/ti-howtos/references/ios-map-kit.md +149 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +595 -0
- package/skills/ti-howtos/references/local-data-sources.md +310 -0
- package/skills/ti-howtos/references/location-and-maps.md +267 -0
- package/skills/ti-howtos/references/media-apis.md +268 -0
- package/skills/ti-howtos/references/notification-services.md +539 -0
- package/skills/ti-howtos/references/remote-data-sources.md +339 -0
- package/skills/ti-howtos/references/tutorials.md +552 -0
- package/skills/ti-howtos/references/using-modules.md +182 -0
- package/skills/ti-howtos/references/web-content-integration.md +288 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +125 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
# Ti.Network, Ti.Database & Ti.Filesystem API Reference
|
|
2
|
+
|
|
3
|
+
## Ti.Database
|
|
4
|
+
> The top-level `Database` module, used for creating and accessing the in-application SQLite database.
|
|
5
|
+
> Extends Ti.Module
|
|
6
|
+
> Platforms: both
|
|
7
|
+
> Type: module
|
|
8
|
+
|
|
9
|
+
### Constants (4)
|
|
10
|
+
- **FIELD_TYPE_\***: FIELD_TYPE_DOUBLE, FIELD_TYPE_FLOAT, FIELD_TYPE_INT, FIELD_TYPE_STRING
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Methods (2)
|
|
14
|
+
| Method | Returns | Platform | Description |
|
|
15
|
+
|--------|---------|----------|-------------|
|
|
16
|
+
| install(path, dbName) | Ti.Database.DB | both | Installs an SQLite database to device's internal storage. |
|
|
17
|
+
| open(dbName) | Ti.Database.DB | both | Opens an SQLite database. |
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Ti.Database.DB
|
|
23
|
+
> The `Database` instance returned by <Titanium.Database.open> or <Titanium.Database.install>.
|
|
24
|
+
> Extends Ti.Proxy
|
|
25
|
+
> Platforms: both
|
|
26
|
+
|
|
27
|
+
### Properties (unique: 4/7)
|
|
28
|
+
| Property | Type | Default | Platform | Description |
|
|
29
|
+
|----------|------|---------|----------|-------------|
|
|
30
|
+
| file | Ti.Filesystem.File | — | both | A `File` object representing the file where this database is stored. Must only … |
|
|
31
|
+
| lastInsertRowId | Number | — | both | The identifier of the last populated row. |
|
|
32
|
+
| name | String | — | both | The name of the database. |
|
|
33
|
+
| rowsAffected | Number | — | both | The number of rows affected by the last query. |
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Methods (6)
|
|
37
|
+
| Method | Returns | Platform | Description |
|
|
38
|
+
|--------|---------|----------|-------------|
|
|
39
|
+
| close(—) | void | both | Closes the database and releases resources from memory. Once closed, this insta… |
|
|
40
|
+
| execute(sql, vararg) | Ti.Database.ResultSet | both | Executes an SQL statement against the database and returns a `ResultSet`. |
|
|
41
|
+
| executeAsync(query, vararg, callback) | Promise<Titanium.Database.ResultSet> | both | Asynchronously executes an SQL statement against the database and fires a callb… |
|
|
42
|
+
| executeAll(queries) | Array<Titanium.Database.ResultSet> | both | Synchronously executes an array of SQL statements against the database and retu… |
|
|
43
|
+
| executeAllAsync(queries, callback) | Promise<Array<Titanium.Database.ResultSet>> | both | Asynchronously executes an array of SQL statements against the database and fir… |
|
|
44
|
+
| remove(—) | void | both | Removes the database files for this instance from disk. WARNING: this is a dest… |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Ti.Database.ResultSet
|
|
50
|
+
> The ResultSet instance returned by <Titanium.Database.DB.execute>.
|
|
51
|
+
> Extends Ti.Proxy
|
|
52
|
+
> Platforms: both
|
|
53
|
+
|
|
54
|
+
A result set represents the results returned by a database query.
|
|
55
|
+
|
|
56
|
+
The [rowCount](Titanium.Database.ResultSet.rowCount) property identifies the number of
|
|
57
|
+
rows in the result set. The `ResultSet` object maintains an internal record of the
|
|
58
|
+
current row. As shown in the example, you can use the
|
|
59
|
+
[next](Titanium.Database.ResultSet.next) method to iterate through the rows in the set.
|
|
60
|
+
|
|
61
|
+
Use the [field](Titanium.Database.ResultSet.field) or
|
|
62
|
+
[fieldByName](Titanium.Database.ResultSet.fieldByName) methods to query the fields for
|
|
63
|
+
the current row.
|
|
64
|
+
|
|
65
|
+
On the iOS platform, closing the database also closes the result set, that is,
|
|
66
|
+
you can only access the result set if the database is currently open.
|
|
67
|
+
|
|
68
|
+
### Properties (unique: 3/6)
|
|
69
|
+
| Property | Type | Default | Platform | Description |
|
|
70
|
+
|----------|------|---------|----------|-------------|
|
|
71
|
+
| fieldCount | Number | — | both | The number of columns in this result set. |
|
|
72
|
+
| rowCount | Number | — | both | The number of rows in this result set. |
|
|
73
|
+
| validRow | Boolean | — | both | Indicates whether the current row is valid. |
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Methods (7)
|
|
77
|
+
| Method | Returns | Platform | Description |
|
|
78
|
+
|--------|---------|----------|-------------|
|
|
79
|
+
| close(—) | void | both | Closes this result set and release resources. Once closed, the result set must … |
|
|
80
|
+
| field(index, type) | String \| Number \| Ti.Blob | both | Retrieves the value for the specified field in the current row, and casts it to… |
|
|
81
|
+
| fieldByName(name, type) | String \| Number \| Ti.Blob | both | Retrieves the value for the specified field in the current row, and casts it to… |
|
|
82
|
+
| fieldName(index) | String | both | Returns the field name for the specified field index. |
|
|
83
|
+
| getFieldName(index) | String | android | Returns the field name for the specified field index. |
|
|
84
|
+
| isValidRow(—) | Boolean | both | Returns whether the current row is valid. |
|
|
85
|
+
| next(—) | Boolean | both | Advances to the next row in the result set and returns `true` if one exists, or… |
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Ti.Filesystem
|
|
91
|
+
> The top level filesystem module, used to access files and directories on the device.
|
|
92
|
+
> Extends Ti.Module
|
|
93
|
+
> Platforms: both
|
|
94
|
+
> Type: module
|
|
95
|
+
|
|
96
|
+
For examples of using the Filesystem APIs, refer to the
|
|
97
|
+
[Filesystem Access and Storage guide](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Working_with_Local_Data_Sources/Filesystem_Access_and_Storage.html)
|
|
98
|
+
as well as the other Filesystem submodule API documentation.
|
|
99
|
+
|
|
100
|
+
### Properties (unique: 11/21)
|
|
101
|
+
| Property | Type | Default | Platform | Description |
|
|
102
|
+
|----------|------|---------|----------|-------------|
|
|
103
|
+
| applicationCacheDirectory | String | — | both | Path to the application's internal cache directory. |
|
|
104
|
+
| applicationDataDirectory | String | — | both | Path to the application's data directory. |
|
|
105
|
+
| applicationDirectory | String | — | ios | Path to the iOS application directory. |
|
|
106
|
+
| applicationSupportDirectory | String | — | ios | Path to the application support directory. |
|
|
107
|
+
| externalCacheDirectory | String | — | android | Path to the app's sandboxed cache folder on removable storage, such as SD card. |
|
|
108
|
+
| externalStorageDirectory | String | — | android | Path to the app's sandboxed folder on removable storage, such as SD card. |
|
|
109
|
+
| lineEnding | String | — | both | Platform-specific line ending constant. |
|
|
110
|
+
| resourcesDirectory | String | — | both | Path to the application's resource directory. |
|
|
111
|
+
| resRawDirectory | String | — | android | Path to the application's raw resource directory. |
|
|
112
|
+
| separator | String | — | both | Platform-specific path separator constant. |
|
|
113
|
+
| tempDirectory | String | — | both | Path for the application's temporary directory. |
|
|
114
|
+
|
|
115
|
+
### Constants (7)
|
|
116
|
+
- **IOS_FILE_PROTECTION_\***: IOS_FILE_PROTECTION_NONE, IOS_FILE_PROTECTION_COMPLETE
|
|
117
|
+
- **IOS_FILE_PROTECTION_COMPLETE_UNLESS_\***: IOS_FILE_PROTECTION_COMPLETE_UNLESS_OPEN
|
|
118
|
+
- **IOS_FILE_PROTECTION_COMPLETE_UNTIL_FIRST_USER_\***: IOS_FILE_PROTECTION_COMPLETE_UNTIL_FIRST_USER_AUTHENTICATION
|
|
119
|
+
- **MODE_\***: MODE_APPEND, MODE_READ, MODE_WRITE
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### Methods (9)
|
|
123
|
+
| Method | Returns | Platform | Description |
|
|
124
|
+
|--------|---------|----------|-------------|
|
|
125
|
+
| createTempDirectory(—) | Ti.Filesystem.File | both | Creates a temporary directory and returns a [File](Titanium.Filesystem.File) ob… |
|
|
126
|
+
| createTempFile(—) | Ti.Filesystem.File | both | Creates a temporary file and returns a [File](Titanium.Filesystem.File) object … |
|
|
127
|
+
| getFile(path) | Ti.Filesystem.File | both | Returns a `File` object representing the file identified by the path arguments. |
|
|
128
|
+
| getAsset(path) | Ti.Blob | ios | Returns a `Blob` object representing the asset catalog image identified by the … |
|
|
129
|
+
| isExternalStoragePresent(—) | Boolean | both | Returns `true` if the device supports external storage *and* the external stora… |
|
|
130
|
+
| hasStoragePermissions(—) | Boolean | android | Returns `true` if the app has storage permissions. |
|
|
131
|
+
| requestStoragePermissions(callback) | Promise<RequestStorageAccessResult> | android | Requests for storage permissions |
|
|
132
|
+
| openStream(mode, path) | Ti.Filesystem.FileStream | both | Opens file using the <Titanium.IOStream> interface. |
|
|
133
|
+
| directoryForSuite(suiteName) | String | ios | Returns the path to the container directory associated with the specified secur… |
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Ti.Filesystem.File
|
|
139
|
+
> Object representing a path to a file or directory in the device's persistent storage.
|
|
140
|
+
> Extends Ti.Proxy
|
|
141
|
+
> Platforms: both
|
|
142
|
+
|
|
143
|
+
Use the <Titanium.Filesystem.getFile> method to get a handle to a `File` object,
|
|
144
|
+
which represents a given path. There does not need to be an existing file or directory
|
|
145
|
+
does not need to exist before `getFile` is called. If the file doesn't exist, and
|
|
146
|
+
the file path identifies a file in a writable directory, writing to the file
|
|
147
|
+
creates the file implicitly.
|
|
148
|
+
|
|
149
|
+
See <Titanium.Filesystem> for constants identifying commonly-used device directories.
|
|
150
|
+
|
|
151
|
+
Use the [exists](Titanium.Filesystem.File.exists) method to test whether the file exists.
|
|
152
|
+
|
|
153
|
+
A file object can point to an ordinary file, a directory or a symbolic link.
|
|
154
|
+
Use [createDirectory](Titanium.Filesystem.File.createDirectory) to create a directory.
|
|
155
|
+
Use the [getDirectoryListing](Titanium.Filesystem.File.getDirectoryListing) method to
|
|
156
|
+
retrieve a list of the directory's contents.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
*(See full overview in titanium-docs)*
|
|
160
|
+
|
|
161
|
+
### Properties (unique: 10/13)
|
|
162
|
+
| Property | Type | Default | Platform | Description |
|
|
163
|
+
|----------|------|---------|----------|-------------|
|
|
164
|
+
| executable | Boolean | — | both | `true` if the file is executable. |
|
|
165
|
+
| hidden | Boolean | — | both | Set to `true` if the file is hidden. |
|
|
166
|
+
| name | String | — | both | Name of the file. |
|
|
167
|
+
| nativePath | String | — | both | Native path associated with this file object, as a file URL. |
|
|
168
|
+
| parent | Ti.Filesystem.File | — | android | A `File` object representing the parent directory of the file identified by thi… |
|
|
169
|
+
| readonly | Boolean | — | android | `true` if the file identified by this object is read-only. |
|
|
170
|
+
| size | Number | — | both | Size, in bytes, of the file identified by this object. |
|
|
171
|
+
| remoteBackup | Boolean | true | ios | Value indicating whether or not to back up to a cloud service. |
|
|
172
|
+
| symbolicLink | Boolean | — | both | `true` if the file identified by this object is a symbolic link. |
|
|
173
|
+
| writable | Boolean | — | both | `true` if the file identified by this object is writable. |
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
### Methods (25)
|
|
177
|
+
| Method | Returns | Platform | Description |
|
|
178
|
+
|--------|---------|----------|-------------|
|
|
179
|
+
| append(data) | Boolean | both | Appends data to the file identified by this file object. |
|
|
180
|
+
| copy(destinationPath) | Boolean | both | Copies the file identified by this file object to a new path. |
|
|
181
|
+
| createDirectory(recursive) | Boolean | both | Creates a directory at the path identified by this file object. |
|
|
182
|
+
| createFile(—) | Boolean | both | Creates a file at the path identified by this file object. |
|
|
183
|
+
| createTimestamp(—) | Number | both | Returns the creation timestamp for the file identified by this file object. |
|
|
184
|
+
| createdAt(—) | Date | both | Returns the creation Date for the file identified by this file object. |
|
|
185
|
+
| deleteDirectory(recursive) | Boolean | both | Deletes the directory identified by this file object. |
|
|
186
|
+
| deleteFile(—) | Boolean | both | Deletes the file identified by this file object. |
|
|
187
|
+
| exists(—) | Boolean | both | Returns `true` if the file or directory identified by this file object exists o… |
|
|
188
|
+
| extension(—) | String | both | Returns the extension for the file identified by this file object. |
|
|
189
|
+
| getDirectoryListing(—) | Array<String> | both | Returns a listing of the directory identified by this file object, or `null` if… |
|
|
190
|
+
| getParent(—) | String \| Ti.Filesystem.File | both | Returns the path of the parent directory holding the file identified by this fi… |
|
|
191
|
+
| getProtectionKey(—) | String | ios | Returns the protection key value of this file object. Returns `null` if there's… |
|
|
192
|
+
| isDirectory(—) | Boolean | both | Returns `true` if this file object represents a directory. |
|
|
193
|
+
| isFile(—) | Boolean | both | Returns `true` if this file object represents an ordinary file. |
|
|
194
|
+
| modificationTimestamp(—) | Number | both | Returns the last modification time for this file. |
|
|
195
|
+
| modifiedAt(—) | Date | both | Returns the last modification Date for the file identified by this file object. |
|
|
196
|
+
| move(newpath) | Boolean | both | Moves the file identified by this file object to another path. |
|
|
197
|
+
| open(mode) | Ti.Filesystem.FileStream | both | Opens the file identified by this file object for random access. |
|
|
198
|
+
| read(—) | Ti.Blob | both | Returns the contents of the file identified by this file object as a `Blob`. |
|
|
199
|
+
| rename(newname) | Boolean | both | Renames the file identified by this file object. |
|
|
200
|
+
| resolve(—) | String | both | Returns the fully-resolved native path associated with this file object. |
|
|
201
|
+
| setProtectionKey(fileProtectionType) | Boolean | ios | Sets the protection key as an attribute to the file identified by this file obj… |
|
|
202
|
+
| spaceAvailable(—) | Number | both | Returns the amount of free space available on the device where the file identif… |
|
|
203
|
+
| write(data, append) | Boolean | both | Writes the specified data to the file identified by this file object. |
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Ti.Filesystem.FileStream
|
|
209
|
+
> Wrapper around `Titanium.Filesystem.File` that implements the `Titanium.IOStream` interface
|
|
210
|
+
> Extends Ti.IOStream
|
|
211
|
+
> Platforms: both
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
### Methods (1)
|
|
215
|
+
| Method | Returns | Platform | Description |
|
|
216
|
+
|--------|---------|----------|-------------|
|
|
217
|
+
| close(—) | void | both | closes file stream, exception is thrown on error |
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Ti.Network
|
|
223
|
+
> The top level network module.
|
|
224
|
+
> Extends Ti.Module
|
|
225
|
+
> Platforms: both
|
|
226
|
+
> Type: module
|
|
227
|
+
|
|
228
|
+
The `Network` module is used to access networking related functionality.
|
|
229
|
+
|
|
230
|
+
For TCP sockets, see <Titanium.Network.Socket.TCP>.
|
|
231
|
+
|
|
232
|
+
The legacy <Titanium.Network.TCPSocket> object is still required
|
|
233
|
+
by the [BonjourBrowser](Titanium.Network.BonjourBrowser) and
|
|
234
|
+
[BonjourService](Titanium.Network.BonjourService) objects.
|
|
235
|
+
|
|
236
|
+
For all other socket needs, use <Titanium.Network.Socket.TCP>.
|
|
237
|
+
|
|
238
|
+
### App Transport Security
|
|
239
|
+
|
|
240
|
+
Starting with iOS 9, Apple introduced new security and compatibility guidelines for networking
|
|
241
|
+
and connectivity, which include:
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
*(See full overview in titanium-docs)*
|
|
245
|
+
|
|
246
|
+
### Properties (unique: 7/24)
|
|
247
|
+
| Property | Type | Default | Platform | Description |
|
|
248
|
+
|----------|------|---------|----------|-------------|
|
|
249
|
+
| allHTTPCookies | Array<Titanium.Network.Cookie> | — | ios | A list of all cookies in the cookie storage. |
|
|
250
|
+
| networkType | Number | — | both | Network type value as a constant. |
|
|
251
|
+
| networkTypeName | String | — | both | Network type as a String. Returns one of `NONE`, `WIFI`, `LAN`, `MOBILE`, or `U… |
|
|
252
|
+
| online | Boolean | — | both | Boolean value indicating if the device is connected to the network. |
|
|
253
|
+
| remoteDeviceUUID | String | — | ios | Remote device UUID if the device is registered with the Apple Push Notification… |
|
|
254
|
+
| remoteNotificationTypes | Array<Number> | — | ios | Array of push notification type constants enabled for the application. |
|
|
255
|
+
| remoteNotificationsEnabled | Boolean | — | both | Indicates whether push notifications have been enabled using [registerForPushNo… |
|
|
256
|
+
|
|
257
|
+
### Constants (14)
|
|
258
|
+
- **NETWORK_\***: NETWORK_LAN, NETWORK_MOBILE, NETWORK_NONE, NETWORK_UNKNOWN, NETWORK_WIFI
|
|
259
|
+
- **NOTIFICATION_TYPE_\***: NOTIFICATION_TYPE_ALERT, NOTIFICATION_TYPE_BADGE, NOTIFICATION_TYPE_SOUND, NOTIFICATION_TYPE_NEWSSTAND
|
|
260
|
+
- **PROGRESS_\***: PROGRESS_UNKNOWN
|
|
261
|
+
- **TLS_VERSION_1_\***: TLS_VERSION_1_0, TLS_VERSION_1_1, TLS_VERSION_1_2, TLS_VERSION_1_3
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
### Methods (19)
|
|
265
|
+
| Method | Returns | Platform | Description |
|
|
266
|
+
|--------|---------|----------|-------------|
|
|
267
|
+
| addHTTPCookie(cookie) | void | both | Adds a cookie to the HTTP client cookie store. |
|
|
268
|
+
| addSystemCookie(cookie) | void | android | Adds a cookie to the system cookie store. |
|
|
269
|
+
| createBonjourBrowser(serviceType, domain, parameters) | Ti.Network.BonjourBrowser | ios | Creates and returns a `BonjourBrowser` object. |
|
|
270
|
+
| createBonjourService(name, type, domain, parameters) | Ti.Network.BonjourService | ios | Creates and returns a `BonjourService` object. |
|
|
271
|
+
| decodeURIComponent(value) | String | both | Returns a decoded version of a URI encoded value. |
|
|
272
|
+
| encodeURIComponent(value) | String | both | Returns a URI encoded version of the specified URI component. |
|
|
273
|
+
| getHTTPCookies(domain, path, name) | Array<Titanium.Network.Cookie> | both | Gets all the cookies with the domain, path and name matched with the given valu… |
|
|
274
|
+
| getHTTPCookiesForDomain(domain) | Array<Titanium.Network.Cookie> | both | Gets all the cookies with the domain matched with the given values from the HTT… |
|
|
275
|
+
| getSystemCookies(domain, path, name) | Array<Titanium.Network.Cookie> | android | Gets all the cookies with the domain, path and name matched with the given valu… |
|
|
276
|
+
| removeAllHTTPCookies(—) | void | both | Removes all the cookies from the HTTP client cookie store. |
|
|
277
|
+
| removeAllSystemCookies(—) | void | android | Removes all the cookie from the system client cookie store. |
|
|
278
|
+
| removeHTTPCookie(domain, path, name) | void | both | Removes the cookie with the domain, path and name exactly the same as the given… |
|
|
279
|
+
| removeHTTPCookiesForDomain(domain) | void | both | Removes the cookies with the domain matched with the given values from the HTTP… |
|
|
280
|
+
| removeSystemCookie(domain, path, name) | void | android | Removes the cookie with the domain, path and name exactly the same as the given… |
|
|
281
|
+
| registerForPushNotifications(config) | void | both | Registers for push notifications with the Apple Push Notification Service. |
|
|
282
|
+
| unregisterForPushNotifications(—) | void | both | Unregisters the application for push notifications. |
|
|
283
|
+
| createCookie(parameters) | Ti.Network.Cookie | both | Creates and returns an instance of <Titanium.Network.Cookie>. |
|
|
284
|
+
| createHTTPClient(parameters) | Ti.Network.HTTPClient | both | Creates and returns an instance of <Titanium.Network.HTTPClient>. |
|
|
285
|
+
| createTCPSocket(parameters) | Ti.Network.TCPSocket | ios | Creates and returns an instance of <Titanium.Network.TCPSocket>. |
|
|
286
|
+
|
|
287
|
+
### Events (1)
|
|
288
|
+
| Event | Platform | Description |
|
|
289
|
+
|-------|----------|-------------|
|
|
290
|
+
| change | both | Fired when network connectivity changes. |
|
|
291
|
+
|
|
292
|
+
### Related Types
|
|
293
|
+
|
|
294
|
+
#### PushNotificationConfig
|
|
295
|
+
> Simple object for specifying push notification options to [registerForPushNotifications](Titanium.Network.registerForPushNotifications).
|
|
296
|
+
|
|
297
|
+
| Property | Type | Description |
|
|
298
|
+
|----------|------|-------------|
|
|
299
|
+
| types | Array<Number> | Array of `NOTIFICATION_TYPE` constants that the application would like to recei… |
|
|
300
|
+
| success | Callback<PushNotificationSuccessArg> | Callback function called when the push registration is successfully completed. |
|
|
301
|
+
| error | Callback<PushNotificationErrorArg> | Callback function called when an error occurs during registration. |
|
|
302
|
+
| callback | Callback<PushNotificationData> | Callback function invoked upon receiving a new push notification. |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Ti.Network.BonjourBrowser
|
|
307
|
+
> A browser for the discovery and retrieval of Bonjour services available on the network.
|
|
308
|
+
> Extends Ti.Proxy
|
|
309
|
+
> Platforms: ios
|
|
310
|
+
|
|
311
|
+
Use the <Titanium.Network.createBonjourBrowser> method to create a `BonjourBrowser` instance.
|
|
312
|
+
|
|
313
|
+
If your application publishes Bonjour services itself, that service will be discovered
|
|
314
|
+
by the browser if necessary; be prepared to perform a check if you do not want to list
|
|
315
|
+
local services as available. Bonjour service browsing is an asynchronous operation,
|
|
316
|
+
meaning that you should be extremely careful when caching values from the `services`
|
|
317
|
+
property returned by the `updatedservices` event. In particular, if you maintain a
|
|
318
|
+
local copy of available services and a user tries to connect to one, you should be prepared
|
|
319
|
+
to handle failures gracefully; the next `updatedservices` event should provide the new
|
|
320
|
+
services list, but you should not rely on it being delivered before user input. When
|
|
321
|
+
a window which uses Bonjour browsing is closed, if you do not want to continue searching,
|
|
322
|
+
you must call the stop() method.
|
|
323
|
+
|
|
324
|
+
In iOS 14.0+, to browse services add key `NSLocalNetworkUsageDescription` and `NSBonjourServices` to the `ios plist` section of the tiapp.xml file.
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
*(See full overview in titanium-docs)*
|
|
328
|
+
|
|
329
|
+
### Properties (unique: 3/5)
|
|
330
|
+
| Property | Type | Default | Platform | Description |
|
|
331
|
+
|----------|------|---------|----------|-------------|
|
|
332
|
+
| domain | String | local. | ios | The domain the browser is searching in |
|
|
333
|
+
| isSearching | Boolean | false | ios | Whether or not the browser is currently searching |
|
|
334
|
+
| serviceType | String | — | ios | The type of the service the browser searches for |
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
### Methods (2)
|
|
338
|
+
| Method | Returns | Platform | Description |
|
|
339
|
+
|--------|---------|----------|-------------|
|
|
340
|
+
| search(—) | void | ios | Conduct a search for Bonjour services matching the type and domain specified du… |
|
|
341
|
+
| stopSearch(—) | void | ios | Halt an ongoing search |
|
|
342
|
+
|
|
343
|
+
### Events (1)
|
|
344
|
+
| Event | Platform | Description |
|
|
345
|
+
|-------|----------|-------------|
|
|
346
|
+
| updatedservices | ios | Fired when the discovered services list is updated |
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Ti.Network.BonjourService
|
|
351
|
+
> Describes a service on the network which is published by Bonjour.
|
|
352
|
+
> Extends Ti.Proxy
|
|
353
|
+
> Platforms: ios
|
|
354
|
+
|
|
355
|
+
You can obtain a `BonjourService` instance by calling <Titanium.Network.createBonjourService>
|
|
356
|
+
or from the `service` list from a [BonjourBrowser](Titanium.Network.BonjourBrowser)
|
|
357
|
+
`updatedservices` event.
|
|
358
|
+
|
|
359
|
+
You can only publish Bonjour services attached to a socket which is currently listening;
|
|
360
|
+
you cannot publish a service for a remotely connected socket. If you stop the Bonjour
|
|
361
|
+
service and wish to close the socket it uses, it is strongly recommended that you stop
|
|
362
|
+
the service first. When a window which publishes a Bonjour service is closed, you must
|
|
363
|
+
stop the service if the associated socket is also to be closed, or if it is no longer
|
|
364
|
+
necessary to publish. Bonjour service resolution and publishing is asynchronous.
|
|
365
|
+
|
|
366
|
+
In iOS 14.0+, to publish service add key `NSLocalNetworkUsageDescription` and `NSBonjourServices` in tiapp.xml file.
|
|
367
|
+
|
|
368
|
+
Example:
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
*(See full overview in titanium-docs)*
|
|
372
|
+
|
|
373
|
+
### Properties (unique: 5/7)
|
|
374
|
+
| Property | Type | Default | Platform | Description |
|
|
375
|
+
|----------|------|---------|----------|-------------|
|
|
376
|
+
| domain | String | — | ios | the domain of the service |
|
|
377
|
+
| isLocal | Boolean | true | ios | whether or not the service is local to the device |
|
|
378
|
+
| name | String | — | ios | the name of the service |
|
|
379
|
+
| socket | Ti.Network.Socket.TCP | — | ios | the TCPSocket object that is used to connect to the service |
|
|
380
|
+
| type | String | — | ios | the type of the service |
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
### Methods (3)
|
|
384
|
+
| Method | Returns | Platform | Description |
|
|
385
|
+
|--------|---------|----------|-------------|
|
|
386
|
+
| publish(socket, callback) | void | ios | Asynchronously publish a Bonjour service to the network. Only works if isLocal … |
|
|
387
|
+
| resolve(timeout, callback) | void | ios | Asynchronously resolve a Bonjour service from the network. Must be done before … |
|
|
388
|
+
| stop(callback) | void | ios | Asynchronously halts a currently running attempt to publish or resolve a servic… |
|
|
389
|
+
|
|
390
|
+
### Events (3)
|
|
391
|
+
| Event | Platform | Description |
|
|
392
|
+
|-------|----------|-------------|
|
|
393
|
+
| publish | ios | Fired when the service has been published (or errored). |
|
|
394
|
+
| resolve | ios | Fired when the service has been resolved (or errored). If successful, the [sock… |
|
|
395
|
+
| stop | ios | Fired when a service's publish or resolution was stopped via <Titanium.Network.… |
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Ti.Network.Cookie
|
|
400
|
+
> Cookie object used to manage the system cookie store and HTTP client cookie store.
|
|
401
|
+
> Extends Ti.Proxy
|
|
402
|
+
> Platforms: both
|
|
403
|
+
|
|
404
|
+
Use <Titanium.Network.createCookie> to create a new `Cookie` object.
|
|
405
|
+
The following is an example of how to setup and read a cookie on a web view:
|
|
406
|
+
|
|
407
|
+
``` js
|
|
408
|
+
if (!Date.prototype.toISOString) {
|
|
409
|
+
(function() {
|
|
410
|
+
function pad(number) {
|
|
411
|
+
const r = String(number);
|
|
412
|
+
if (r.length === 1) {
|
|
413
|
+
r = '0' + r;
|
|
414
|
+
}
|
|
415
|
+
return r;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
Date.prototype.toISOString = function() {
|
|
419
|
+
|
|
420
|
+
*(See full overview in titanium-docs)*
|
|
421
|
+
|
|
422
|
+
### Properties (unique: 11/14)
|
|
423
|
+
| Property | Type | Default | Platform | Description |
|
|
424
|
+
|----------|------|---------|----------|-------------|
|
|
425
|
+
| comment | String | — | both | The comment describing the purpose of this cookie |
|
|
426
|
+
| domain | String | — | both | The domain attribute of the cookie. |
|
|
427
|
+
| expiryDate | String | — | ios | The expiration Date of the cookie. |
|
|
428
|
+
| maxAge | Number | — | android | Sets the Max-Age attribute of a Cookie, in delta-seconds. |
|
|
429
|
+
| httponly | Boolean | false | both | The httponly attribute of the cookie. |
|
|
430
|
+
| name | String | — | both | The name of the cookie. |
|
|
431
|
+
| originalUrl | String | — | ios | The original URL attribute of the cookie. |
|
|
432
|
+
| path | String | — | both | The path attribute of the cookie. |
|
|
433
|
+
| secure | Boolean | false | both | The secure attribute of the cookie. |
|
|
434
|
+
| value | String | — | both | The value of the cookie. |
|
|
435
|
+
| version | Number | — | both | The version of the cookie specification to which this cookie conforms. |
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
### Methods (1)
|
|
439
|
+
| Method | Returns | Platform | Description |
|
|
440
|
+
|--------|---------|----------|-------------|
|
|
441
|
+
| isValid(—) | Boolean | both | Returns true if the cookie is valid. |
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Ti.Network.HTTPClient
|
|
447
|
+
> HTTP client object that (mostly) implements the XMLHttpRequest specification.
|
|
448
|
+
> Extends Ti.Proxy
|
|
449
|
+
> Platforms: both
|
|
450
|
+
|
|
451
|
+
Use <Titanium.Network.createHTTPClient> to create a new `HTTPClient` object.
|
|
452
|
+
|
|
453
|
+
An `HTTPClient` object is intended to be used for a single request. It may be
|
|
454
|
+
possible to re-use an `HTTPClient` object, but this use case is not tested.
|
|
455
|
+
|
|
456
|
+
There are three steps in making a typical HTTP request:
|
|
457
|
+
|
|
458
|
+
* Creating an `HTTPClient` object.
|
|
459
|
+
* Opening the `HTTPClient` object.
|
|
460
|
+
* Sending the request.
|
|
461
|
+
|
|
462
|
+
Before opening the request, you must define one or more callbacks to handle
|
|
463
|
+
the HTTP response, as well as errors, progress updates, and other conditions.
|
|
464
|
+
|
|
465
|
+
The `HTTPClient` callbacks operate somewhat differently from other
|
|
466
|
+
|
|
467
|
+
*(See full overview in titanium-docs)*
|
|
468
|
+
|
|
469
|
+
### Properties (unique: 31/39)
|
|
470
|
+
| Property | Type | Default | Platform | Description |
|
|
471
|
+
|----------|------|---------|----------|-------------|
|
|
472
|
+
| allResponseHeaders | String | — | android | All of the response headers. |
|
|
473
|
+
| responseHeaders | Dictionary | — | ios | Returns all the response headers returned with the request. |
|
|
474
|
+
| autoEncodeUrl | Boolean | true | android | Determines whether automatic encoding is enabled for the specified URL. |
|
|
475
|
+
| autoRedirect | Boolean | true | both | Determines whether automatic automatic handling of HTTP redirects is enabled. |
|
|
476
|
+
| connected | Boolean | — | both | Indicates whether the response was successful. |
|
|
477
|
+
| connectionType | String | — | both | Connection type, normally either `GET`, `POST` or `PATCH`. |
|
|
478
|
+
| domain | String | Undefined | both | Sets the domain parameter for authentication credentials. |
|
|
479
|
+
| enableKeepAlive | Boolean | false | ios | Determines whether the client should attempt to keep a persistent connection. |
|
|
480
|
+
| file | String \| Ti.Filesystem.File | — | both | Target local file or file path to receive data. |
|
|
481
|
+
| location | String | — | both | Absolute URL of the request. |
|
|
482
|
+
| ondatastream | Callback<Object> | — | both | Function to be called at regular intervals as the request data is being receive… |
|
|
483
|
+
| onerror | Callback<FailureResponse> | — | both | Function to be called upon a error response. |
|
|
484
|
+
| onload | Callback<SuccessResponse> | — | both | Function to be called upon a successful response. |
|
|
485
|
+
| onreadystatechange | Callback<Object> | — | both | Function to be called for each [readyState](Titanium.Network.HTTPClient.readySt… |
|
|
486
|
+
| onsendstream | Callback<Object> | — | both | Function to be called at regular intervals as the request data is being transmi… |
|
|
487
|
+
| password | String | Undefined | both | Sets the password parameter for authentication credentials. |
|
|
488
|
+
| readyState | Number | — | both | The current ready state of this HTTP request. |
|
|
489
|
+
| responseData | Ti.Blob | — | both | Response data as a `Blob` object. |
|
|
490
|
+
| responseText | String | — | both | Response as text. |
|
|
491
|
+
| responseDictionary | String | — | both | Response as JSON object. |
|
|
492
|
+
| responseXML | Ti.XML.Document | — | both | Response object as an XML DOM Document object. |
|
|
493
|
+
| securityManager | SecurityManagerProtocol | — | both | The Security Manager for this client. |
|
|
494
|
+
| status | Number | — | both | Response HTTP status code. |
|
|
495
|
+
| statusText | String | — | both | Human-readable status message associated with the status code. |
|
|
496
|
+
| timeout | Number | On iOS, the default is 15000 (15 seconds). | both | Timeout in milliseconds when the connection should be aborted. |
|
|
497
|
+
| timeoutForResource | Number | The default is `7*24*60*60*1000` milliseconds (7 days). | ios | The maximum amount of time (in milliseconds) that a resource request should be … |
|
|
498
|
+
| waitsForConnectivity | Boolean | false | ios | A Boolean value that indicates whether the session should wait for connectivity… |
|
|
499
|
+
| username | String | Undefined | both | Sets the username parameter for authentication credentials. |
|
|
500
|
+
| validatesSecureCertificate | Boolean | False when running in the simulator or on device in testing mode, and true if built for release in distribution mode. | both | Determines how SSL certification validation is performed on connection. |
|
|
501
|
+
| tlsVersion | Number | undefined, behaves as `Ti.Network.TLS_VERSION_1_2`. | android | Sets the TLS version to use for handshakes. |
|
|
502
|
+
| cache | Boolean | false | ios | Determines whether HTTP responses are cached. |
|
|
503
|
+
|
|
504
|
+
### Constants (5)
|
|
505
|
+
- **HEADERS_\***: HEADERS_RECEIVED
|
|
506
|
+
- **OTHER_\***: DONE, LOADING, OPENED, UNSENT
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
### Methods (8)
|
|
510
|
+
| Method | Returns | Platform | Description |
|
|
511
|
+
|--------|---------|----------|-------------|
|
|
512
|
+
| abort(—) | void | both | Cancels a pending request. |
|
|
513
|
+
| clearCookies(host) | void | both | Clears any cookies stored for the host. |
|
|
514
|
+
| getAllResponseHeaders(—) | String | both | All of the response headers. |
|
|
515
|
+
| getResponseHeader(name) | String | both | Returns the value of the specified response header. |
|
|
516
|
+
| open(method, url, async) | void | both | Opens the request and prepares the connection. |
|
|
517
|
+
| send(data) | void | both | Sends the request. |
|
|
518
|
+
| setRequestHeader(name, value) | void | both | Sets the value for the specified request header. Must be called after `open` bu… |
|
|
519
|
+
| setTimeout(timeout) | void | both | Sets the request timeout. |
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
### Related Types
|
|
523
|
+
|
|
524
|
+
#### Dictionary
|
|
525
|
+
> Plain JavaScript object.
|
|
526
|
+
|
|
527
|
+
#### SecurityManagerProtocol
|
|
528
|
+
> The protocol that the <Titanium.Network.HTTPClient.securityManager> must implement.
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
## Ti.Network.Socket
|
|
533
|
+
> Socket module, used for creating sockets.
|
|
534
|
+
> Extends Ti.Module
|
|
535
|
+
> Platforms: both
|
|
536
|
+
> Type: module
|
|
537
|
+
|
|
538
|
+
### Constants (5)
|
|
539
|
+
- **OTHER_\***: INITIALIZED, CONNECTED, LISTENING, CLOSED, ERROR
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
### Methods (1)
|
|
543
|
+
| Method | Returns | Platform | Description |
|
|
544
|
+
|--------|---------|----------|-------------|
|
|
545
|
+
| createTCP(params) | Ti.Network.Socket.TCP | both | Returns a new TCP socket object. |
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
550
|
+
## Ti.Network.Socket.TCP
|
|
551
|
+
> TCP socket that implements the `Titanium.IOStream` interface.
|
|
552
|
+
> Extends Ti.IOStream
|
|
553
|
+
> Platforms: both
|
|
554
|
+
|
|
555
|
+
Most socket operations are asynchronous. When you create a socket, you can define
|
|
556
|
+
callback functions to receive the results of API calls, as well as to handle incoming
|
|
557
|
+
data.
|
|
558
|
+
|
|
559
|
+
For example, for a client-side socket, you define
|
|
560
|
+
[connected](Titanium.Network.Socket.TCP.connected) and
|
|
561
|
+
[error](Titanium.Network.Socket.TCP.error) callback functions.
|
|
562
|
+
|
|
563
|
+
To connect to a remote host, call the socket's
|
|
564
|
+
[connect](Titanium.Network.Socket.TCP.connect) method. If the socket connects
|
|
565
|
+
successfully, your `connected` callback is invoked, and you can send and receive data
|
|
566
|
+
on the socket. If the socket connection fails, your `error` callback is invoked.
|
|
567
|
+
|
|
568
|
+
After a socket is connected, you can access it like any other <Titanium.IOStream>.
|
|
569
|
+
Note that the socket's `read` and `write` methods may block, so in most cases
|
|
570
|
+
|
|
571
|
+
*(See full overview in titanium-docs)*
|
|
572
|
+
|
|
573
|
+
### Properties (unique: 9/12)
|
|
574
|
+
| Property | Type | Default | Platform | Description |
|
|
575
|
+
|----------|------|---------|----------|-------------|
|
|
576
|
+
| host | String | — | both | The host to connect to or listen on. |
|
|
577
|
+
| port | Number | — | both | The port to connect to or listen on. |
|
|
578
|
+
| secure | Boolean | false | android | Creates a secure socket. |
|
|
579
|
+
| listenQueueSize | Number | — | both | Max number of pending incoming connections to be allowed when the socket is in … |
|
|
580
|
+
| timeout | Number | — | both | Timeout, in milliseconds, for `connect` and all `write` operations. |
|
|
581
|
+
| connected | Callback<ConnectedCallbackArgs> | — | both | Callback to be fired when the socket enters the "connected" state. |
|
|
582
|
+
| error | Callback<ErrorCallbackArgs> | — | both | Callback to be fired when the socket enters the [ERROR](Titanium.Network.Socket… |
|
|
583
|
+
| accepted | Callback<AcceptedCallbackArgs> | — | both | Callback to be fired when a listener accepts a connection. |
|
|
584
|
+
| state | Number | — | both | Current state of the socket. |
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
### Methods (4)
|
|
588
|
+
| Method | Returns | Platform | Description |
|
|
589
|
+
|--------|---------|----------|-------------|
|
|
590
|
+
| close(—) | void | both | Closes a socket. |
|
|
591
|
+
| connect(—) | void | both | Attempts to connect the socket to its host/port. |
|
|
592
|
+
| listen(—) | void | both | Attempts to start listening on the socket's host/port. |
|
|
593
|
+
| accept(options) | void | both | Tells a [LISTENING](Titanium.Network.Socket.LISTENING) socket to accept a conne… |
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
### Related Types
|
|
597
|
+
|
|
598
|
+
#### AcceptDict
|
|
599
|
+
> Options object for the [accept](Titanium.Network.Socket.TCP.accept) method.
|
|
600
|
+
|
|
601
|
+
| Property | Type | Description |
|
|
602
|
+
|----------|------|-------------|
|
|
603
|
+
| timeout | Number | Timeout, in milliseconds, for all `write` operations. |
|
|
604
|
+
| error | Callback<ErrorCallbackArgs> | Callback to be fired when the socket enters the [ERROR](Titanium.Network.Socket… |
|
|
605
|
+
|
|
606
|
+
---
|
|
607
|
+
|
|
608
|
+
## Ti.Network.TCPSocket
|
|
609
|
+
> The TCPSocket instance returned from <Titanium.Network.createTCPSocket>. This object represents a socket which either listens locally on the device for connections, or connects to a remote machine.
|
|
610
|
+
> Extends Ti.Proxy
|
|
611
|
+
> Platforms: ios
|
|
612
|
+
|
|
613
|
+
Sockets are nontrivial; it is recommended that anyone using them be familiar with the basics of BSD sockets. All sockets use TCP connections, and are asynchronous for read operations, so your program should be ready to receive 'read' events at any point. Socket references cannot be transferred to socket objects, and vice-versa - socket references are an internal mechanism which is used only to determine which sockets to send data to and read data from. For listening sockets, it is highly recommended that you use the <Titanium.Network.INADDR_ANY> constant as the host name. If a window containing a socket is closed, the socket MUST be closed also unless you intend to continue to receive data, otherwise the socket will consume resources (and potentially cause conflicts with opening the window again, if a listener) until the program is restarted. Be aware of the differences between the listen() and connect() functions; attempting to use one when you mean the other may result in errors, unpredictable behavior, or both.
|
|
614
|
+
|
|
615
|
+
### Properties (unique: 5/7)
|
|
616
|
+
| Property | Type | Default | Platform | Description |
|
|
617
|
+
|----------|------|---------|----------|-------------|
|
|
618
|
+
| hostName | String | — | ios | the host name to connect to. Must be <Titanium.Network.INADDR_ANY> or an identi… |
|
|
619
|
+
| isValid | Boolean | — | ios | whether or not the socket is valid |
|
|
620
|
+
| mode | Number | — | ios | the socket's mode |
|
|
621
|
+
| port | Number | — | ios | the port to connect/listen on |
|
|
622
|
+
| stripTerminator | Boolean | — | ios | strip terminating null character when sending string data; default is false |
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
### Methods (4)
|
|
626
|
+
| Method | Returns | Platform | Description |
|
|
627
|
+
|--------|---------|----------|-------------|
|
|
628
|
+
| close(—) | void | ios | close the socket |
|
|
629
|
+
| connect(—) | void | ios | connect the socket to a TCP server |
|
|
630
|
+
| listen(—) | void | ios | set up the socket to receive connections |
|
|
631
|
+
| write(data, sendTo) | void | ios | write data to the socket, if the mode is WRITE_MODE or READ_WRITE_MODE |
|
|
632
|
+
|
|
633
|
+
### Events (3)
|
|
634
|
+
| Event | Platform | Description |
|
|
635
|
+
|-------|----------|-------------|
|
|
636
|
+
| read | ios | new data was read off the socket |
|
|
637
|
+
| readError | ios | an error occurred when reading |
|
|
638
|
+
| writeError | ios | an error occurred when writing |
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|