WaveMaker Docs

WaveMaker Docs

  • Get started
  • Widgets
  • Mobile
  • How-to
  • Enterprise
  • Releases
  • Blog
  • Sign-in

›Variables

Getting started

  • Introduction
  • Walkthrough

Pages

  • Pages Overview
  • Creating a Page
  • Layout and Styles

    • Page Layout
    • Templates
    • Themes
    • Accessibility

    Page Configure

    • Page Artefacts
    • Page Cache
    • Partial Page
    • Page Parameters
    • Examples

    Page Actions

    • Navigation
    • Events

    Custom Development

    • Theme Editor
    • Manual Theme
    • Create Template

SSPA

  • Micro Frontend App

Databases

  • Database Services Overview
  • Database Tools
  • Database Designing

    • Working with Databases
    • Data Modelling
    • DataBase Schema Modes
    • Working with DB Schema
    • Database Views
    • Temporal Support

    Accessing Database

    • Accessing Database

    Queries and Procedures

    • Working with Queries
    • Working with Stored Procedures
    • Version Queries & Procedures
    • Blob Queries and Procedures
    • Queries & Procedures - Java Services

    Database Variables & API

    • Database CRUD
    • CRUD Event Listeners
    • Database APIs
    • Database Service APIs

REST & SOAP

  • Web Services Overview
  • Restful

    • REST Services
    • Secure Server-side Properties
    • REST Request Timeouts
    • REST Services using OAuth 2.0

    SOAP

    • Working with SOAP Services
    • Imported SOAP APIs

    Websocket

    • Working with WebSockets

    APIs

    • API Designer
    • Mocking APIs
    • Mocking REST API
    • Swagger Import

    Variables

    • CRUD Variable
    • Service Variable
    • WebSocket Variable

Java Services

  • Java Service
  • Java Services

    • Java Integration Services
    • DB Service Integration
    • API Composition
    • Variables for Invocation
    • Generated REST APIs (API Designer)

    Java Services Variables & API

    • Variable for Java Service
    • Java Service APIs

    Source Files

    • Resources and Third-party Libraries
    • Using 3rd party JavaScript files
    • Using 3rd party jar files

Variables & Actions

    Variables

    • Variables Overview
    • Model Variable
    • Device Variables

    Binding

    • Variable Binding
    • Custom Formatter

    Actions

    • Actions
    • Navigation Action
    • Login Action
    • Logout Action
    • Timer Action
    • Notification Action

    Events

    • Events
    • JavaScript Access

Security

    App Security

    • Overview
    • Authentication
    • Authorization
    • Access Levels & Permissions
    • Login Configuration
    • Session Persistence
    • SSL Encryption
    • XSS antisamy policy configuration
    • OWASP
    • XSS Prevention
    • Central Authentication System
    • Token Based Authentication
    • SAML Integration
    • Secure Connection for Deployed Apps
    • Concurrent Sessions
    • HostHeader Injection

    Security Variable and API

    • Security Variables
    • Remember Me
    • Variable for Security Service
    • Security Service APIs

Developer options

  • Test and Run (Preview) Apps
  • Chrome Extension: Devtool
  • Debugging
  • Inspection Framework
  • Build Options
  • WaveMaker Mobile Apps Automation
  • Developer Integration

    • Project User Management
    • Developer Collaboration
    • Extending the Application using IDEs
    • Import, Export & Update Apps
    • Project Shells

    Add-ons

    • Localization
    • Artifacts Repository

Deployment

  • Overview
  • Deployment Profile
  • One-click Deployment
  • WaveMaker CI/CD Pipeline

    • Overview
    • Configuration Profiles
    • Configuration Management
    • Pipelines and Phases

    Pipeline Configuration

    • Default Pipelines in WMO
    • Configure Pipeline in WME

    Deploy to Cloud Providers

    • AWS
    • Azure
    • Google Cloud
    • DigitalOcean

    Pipeline Configuration cont.

    • Phase configurations
    • Webhooks Integration
    • Tests Integration

    Manage Deployed Apps

    • Manage Deployed Apps

    Integrate with your CI/CD Providers

    • Push Code to External repo
    • Custom VCS Integration
    • Export WaveMaker Application
    • Building Project with Maven
    • Build with Docker
    • Jenkins Integration
    • Deploy using Docker Compose
    • Deployment to Heroku

    WaveMaker apps Interation with CDN

    • App Integration with AWS CDN
    • App Integration with Azure CDN

    Deployment to external web servers

    • Application Server Overview
    • Deploy to Tomcat
    • WebSphere
    • JBoss - WildFly
    • WebLogic Server

Connectors

  • Introduction
  • Architecture
  • Import Connectors
  • List of Connectors
  • Build a New Connector

Teams

  • Overview
  • Team Setup
  • Dashboard
  • Manage Users
  • Manage Projects
  • Manage Prefabs
  • Project Branches
  • Manage Roles
  • Code Repository
  • Import VCS Project
  • Team Profile
  • Manage Subscription
  • FAQs
Edit

WebSocket Variable


WebSocket Variable is the interface for the app developer to interact with a WebSocket Service imported into a WaveMaker app. The Variable has methods to interact with the target service like opening and closing the connection, sending and receiving messages to and from the server. It also holds the data to be sent to the service and the data received from the service.

Variable Lifecycle

socket_lifecycle

Variable Creation

The data source for WebSocket Variables comes from a Web Service. We will see steps in creating a WebSocket variable here.

  1. Select Variable option from the Create Menu

  1. Click New Variable from the Variable Dialog.

  1. For creating a variable to access WebSocket Web service APIs, select Web Service as the target action.

  2. In the next dialog, enter details for the following properties.

    • Service - service (already imported) name,
    • Name - is set by default but can be modified
    • Owner - the scope of the Variable being created. By default it is set to Page, you can change it to Application if you want this variable to be available across the app.
  3. Click Done to complete the variable creation process

  4. You will be directed to the Variables page, with the new variable listed. As you can see:

    • a Web Service Variable is created,
    • with the default exposed method/selected method as target
    • the properties tab contains all the properties like behavior and dataset behavior. Know more about properties.
    • the data tab will contain the fields serving as input fields for the API
    • the events tab will contain the events that can be configured to trigger any action. Know more about events.

Properties

WebSocket Variables are special variables that interact with the imported Web Socket service.

PropertyDescription
Service
ServiceThe WebSocket service targeted for the Variable.
Behavior
Connect on page loadIf set to true, the variable will open the connection between the client and target WebSocket service on:
- page load, for a page variable
- app load, for an app variable.
Dataset
On New DataA client once connected to a WebSocket service, can receive messages at any point in time and can receive many messages sequentially. This property determines what to do with data received from the variable.
- Refresh dataSet: dataSet will be updated with the data received.
- Add as last record: data will be appended at the end of dataSet. The latest data will be the last record in dataSet.
- Add as first record: data will be prepended at the beginning of dataSet. The latest data will be the first record in dataSet.
In the latter two cases, dataSet will always be a list of messages.
Data LimitMaximum number of messages that dataSet will hold. This is applicable only if “On New Data” property is set to other than “Refresh”. E.g. if set to 10, dataSet will hold a maximum of 10 message received from the server. When a new message is received, the first message is removed from the dataSet and the new one is appended to the end. Set it to 0 if no such upper limit is required.

Events

Following events are triggered during the lifecycle of a WebSocket Variable. These events can be utilized by the end user application developer to customize the behavior of the app through more complex logic.

EventDescription
on Before OpenThe event is triggered just before the Variable attempts to establish a connection between the client and target WebSocket service. If returned false from here, the connection establishment will be aborted.
on OpenThe event is triggered right after a successful connection is established between the client and the WebSocket service through the Variable.
on Before Message SendThe event is triggered just before the Variable attempts to send a message to the target service through the existing connection. You have a chance at this point to validate and edit the data to be sent to the service. Returning false from this event will prevent the message to be sent to the service.
on Message ReceiveThe event is triggered on the Variable when a message is received from the WebSocket service in an existing connection made by the Variable.
on ErrorTriggered if an error is encountered in establishing a connection with the server in the open phase.
on Before CloseTriggered before an existing connection(opened by the Variable) is closed. Returning false from here will abort the closing of the connection.
onCloseTriggered after the connection is closed.
note

WaveMaker supports binding multiple actions to a given event, i.e. a given event can trigger multiple actions.

Methods

opensendclose

open()

This method is used to open up the connection between the client and the WebSocket service. This is the starting point of the Variable lifecycle.

Parameters: None Return Value: None Usage:

Page.Variables.webSocketVariable.open();

send()

This method is used to send a message to the WebSocket service through the currently established connection.

Parameters:

  • message(object): the message to be sent to the service. If not provided, whatever is assigned to Variable RequestBody will be sent

Return Value: None

Usage:

Page.Variables.webSocketVariable.send(message);

close()

This method is used to close an existing WebSocket connection connected through the Variable.

Parameters: None

Return Value: None

Usage:

Page.Variables.webSocketVariable.close();
Last updated on 7/13/2020 by Swetha Kundaram
← Service VariableJava Service →
  • Variable Lifecycle
  • Variable Creation
  • Properties
  • Events
  • Methods
    • open()
    • send()
    • close()
WaveMaker
  • PRICING
  • PARTNERS
  • CUSTOMERS
  • ABOUT US
  • CONTACT US
Terms of Use | Copyright © 2013-2023 WaveMaker, Inc. All rights reserved.