Skip to main content

LensStudio:Network

Module

Before using anything in this namespace, make sure to import LensStudio:Network and add network in your plugin's module.json.

Example

// module.json
{
"main": "main.js",
"permissions": ["network"]
}
// main.js
import * as network from 'LensStudio:Network';

Namespaces

NamespaceDescription
HttpRequest-

Classes

ClassDescription
AddressA TCP Server address. Use with "LensStudio:Network".TcpServer.
BaseServerBase class for network servers, providing common listen and connection management functionality.
BaseSocketBase class for network sockets, providing common send and event handling functionality.
FormDataHolds key-value pairs and file attachments for encoding multipart HTTP request bodies.
HttpReplyHandle to an in-progress HTTP request returned by performHttpRequestWithReply; must be retained to keep the connection alive.
HttpRequestA HTTP Request configuration. Use with "LensStudio:Network".performHttpRequestWithReply.
HttpResponseAn HTTP response, received from the callback to performing a request, such as through: "LensStudio:Network".performHttpRequestWithReply, or "LensStudio:RemoteServiceModule".performApiRequest.
TcpServerA class to accept TCP connetions. Useful for receiving streaming data. It's also able to send back responses.
TcpSocketTCP socket for use with "LensStudio:Network".TcpSocket.

Functions

FunctionDescription
performAuthorizedHttpRequestCalls a HTTPS endpoint with authorization to Snapchat. See Editor.IAuthorization. Requires snap_auth_token in module.json of your plugin.
performHttpRequestCalls a HTTP endpoint.
performHttpRequestWithReplyRequest an HTTP call with reply. You should store the reply object (e.g. in the this of the plugin) in order for the network connection to be maintained.