WebSocket Server. To understand the Wakanda Server side WebSocket support, it is important to identify the different parts and how they interact:



Similar documents
Wakanda Studio Features

Repeater. BrowserStack Local. browserstack.com 1. BrowserStack Local makes a REST call using the user s access key to browserstack.

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

latest Release 0.2.6

Using the VMRC Plug-In: Startup, Invoking Methods, and Shutdown on page 4

Step into the Future: HTML5 and its Impact on SSL VPNs

Research of Web Real-Time Communication Based on Web Socket

HTML5 Websockets with ruby and rails. Saurabh Bhatia, CEO, Safew Labs

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

Apache JMeter HTTP(S) Test Script Recorder

Developing ASP.NET MVC 4 Web Applications MOC 20486

Instant Chime for IBM Sametime Installation Guide for Apache Tomcat and Microsoft SQL

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Spring Design ScreenShare Service SDK Instructions

Development Techniques for Native/Hybrid Tizen Apps. Presented by Kirill Kruchinkin

Developing ASP.NET MVC 4 Web Applications

Customer Tips. Xerox Network Scanning HTTP/HTTPS Configuration using Microsoft IIS. for the user. Purpose. Background

Spectrum Technology Platform

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

DiskPulse DISK CHANGE MONITOR

A Tool for Evaluation and Optimization of Web Application Performance

Real Time Data in Web Applications

Sitecore Dashboard User Guide

HTTP 1.1 Web Server and Client

Table of Contents Introduction and System Requirements 9 Installing VMware Server 35

SmartTV User Interface Development for SmartTV using Web technology and CEA2014. George Sarosi

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Smart Connect. Deployment Guide

DocuSign for SharePoint

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

Customer Tips. Configuring Color Access on the WorkCentre 7328/7335/7345 using Windows Active Directory. for the user. Overview

Multicast File and Screen Sharing using Wi-Fi Connectivity

Cybozu Garoon 3 Server Distributed System Installation Guide Edition 3.1 Cybozu, Inc.

Drupal CMS for marketing sites

Building Java Servlets with Oracle JDeveloper

Computer Networks/DV2 Lab

Week 13. Uploading Files to Web Hosting

Blue Coat Security First Steps Solution for Deploying an Explicit Proxy

Qualtrics Question API

How To Write A File Station In Android.Com (For Free) On A Microsoft Macbook Or Ipad (For A Limited Time) On An Ubuntu 8.1 (For Ubuntu) On Your Computer Or Ipa (For

CA Performance Center

OutDisk 4.0 FTP FTP for Users using Microsoft Windows and/or Microsoft Outlook. 5/1/ Encryptomatic LLC

WebIOPi. Installation Walk-through Macros

Active Directory Adapter with 64-bit Support Installation and Configuration Guide

Handshake & endpoints

Quick Start Guide. Installation and Setup

Dell Recovery Manager for Active Directory 8.6. Quick Start Guide

socketio Documentation

Installation and Deployment

How to use FTP Commander

B6: GET /started/with/ HTTP Analysis

isupplier PORTAL ACCESS SYSTEM REQUIREMENTS

JW Player for Flash and HTML5

Process Integrator Deployment on IBM Webspher Application Server Cluster

INTRODUCTION TO ATRIUM... 2 SYSTEM REQUIREMENTS... 2 TECHNICAL DETAILS... 2 LOGGING INTO ATRIUM... 3 SETTINGS... 4 NAVIGATION PANEL...

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

IceWarp to IceWarp Server Migration

How To Write A Web Server In Javascript

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

Web Tracking for You. Gregory Fleischer

JobScheduler Web Services Executing JobScheduler commands

How to start with 3DHOP

ISL Online Integration Manual

GUI and Web Programming

Automatic updates for Websense data endpoints

Login with Amazon. Getting Started Guide for Websites. Version 1.0

Installation Guide. Qlik Sense 1.1 Copyright QlikTech International AB. All rights reserved.

Sophos Computer Security Scan startup guide

Using Internet or Windows Explorer to Upload Your Site

Grandstream XML Application Guide Three XML Applications

Oracle Communications WebRTC Session Controller: Basic Admin. Student Guide

WIRIS quizzes web services Getting started with PHP and Java

Bringing M2M to the web with Paho

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

3DHOP Local Setup. Lezione 14 Maggio 2015

Performance Testing for Ajax Applications

NovaBACKUP Remote Workforce Version 12.5 Cloud Restore

StreamServe Persuasion SP4 StreamServe Connect for SAP - Business Processes

How To Install An Aneka Cloud On A Windows 7 Computer (For Free)

Client-side Web Engineering From HTML to AJAX

SysPatrol - Server Security Monitor

Reference and Troubleshooting: FTP, IIS, and Firewall Information

Proxy Sniffer V4.3 Release Notes

Monitoring Infrastructure (MIS) Software Architecture Document. Version 1.1

Chapter 6 Virtual Private Networking Using SSL Connections

Remote Console Installation & Setup Guide. November 2009

Features of The Grinder 3

Sage 100 ERP. ebusiness Manager Installation Guide

Specify the location of an HTML control stored in the application repository. See Using the XPath search method, page 2.

Table of Contents. Pointshop Betting. Installation

Administration Quick Start

MarkLogic Server. Installation Guide for All Platforms. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Chapter 3: Web Paradigms and Interactivity

Real Time Data Communication over Full Duplex Network Using Websocket

Research on Server Push Methods in Web Browser based Instant Messaging Applications

FTP, IIS, and Firewall Reference and Troubleshooting

Transcription:

WebSocket Server Wakanda Server provides a WebSocket Server API, allowing you to handle client WebSocket connections on the server. WebSockets enable Web applications (clients) to use the WebSocket protocol for two way communication with a remote host (server). For more information on the WebSocket protocol, please refer to the WebSocket W3C specification. Note: WebSockets are part of HTML5. Please keep in mind that the WebSocket specification is still under discussion and should neither be considered as frozen nor as finished. WebSockets protocol implementation relies on different parts, implying both client and server sides: Client side, WebSockets are supported through HTML5 implementation. On Wakanda Server, WebSocket handlers are registered using a specific API and WebSocket server instances rely on the Web Workers API. To understand the Wakanda Server side WebSocket support, it is important to identify the different parts and how they interact:

Managing server side WebSockets Understanding Server side Client WebSocket Representation On Wakanda Server, WebSockets registered by addwebsockethandler( ) are handled through Web Workers. When the server communicates with a client, the server has access to a WebSocket "proxy" object describing the client WebSocket. This proxy object is actually a Web worker, that you can handle through the regular Web Workers API. To handle a websocket, you can use: either a shared worker, or a dedicated worker. Usually, shared workers are more appropriate for handling WebSockets. However, you can select the type of worker depending on your needs while registering the WebSocket using addwebsockethandler( ). APIs for shared and dedicated workers are slightly different. Using a Shared Worker for the WebSocket When you have defined a server side WebSocket based on a shared worker, you can use the regular SharedWorker Instances APIs in the server script. SharedWorker properties are documented in the SharedWorker Instances API reference, Communication tools available through the event.ports[0] objects (onconnect and ports) are detailed in the Worker Instances API reference. Note that two specific APIs have been added to the Worker Instances class to handle WebSockets: binarytype allows you to define the type of data exchanged through the WebSocket. onclose function is called each time the WebSocket is closed. The following code structure can be used: onconnect = function (event) { //Called each time a new client is connected var websocket = event.ports[0]; //Access to the WebSocket client object. // Undefined if shared worker is called from SSJS server. websocket.binarytype = 'string'; // Defines the exchanged data type // this worker property is only available in the context of a WebSocket websocket.postmessage("helloworld"); websocket.onmessage = function(message) { //Called each time a client sends a message var data = JSON.parse(message.data); //Application protocol websocket.postmessage('message received'); websocket.onclose = function() { // when the socket is closed Server side communication with the Shared Worker If you use a shared worker to handle the WebSocket, a server side script can communicate with it like with any other web worker: var worker = new SharedWorker("chat-server.js", "chat"); worker.port.postmessage(''); // The message will be received in the onmessage callback of the web worker Using a Dedicated Worker for the WebSocket When you have defined a server side WebSocket based on a dedicated worker, you can use the regular Worker Instances APIs in the server script. In accordance with dedicated workers mechanism, the server side worker is automatically executed each time a message is sent by the client. Here is the list of available APIs for a server side WebSocket based on a dedicated worker: Worker APIs onmessage Only for WebSocket objects

postmessage( ) binarytype onclose X X You can use the following code structure: onmessage = function(message) { //Called each time a client sends a message var data = JSON.parse(message.data) //Get the message postmessage("helloworld"); //Send a message onclose = function(); // when the socket is closed

Downloadable Example A typical example of server side WebSocket implementation is a "chat" server providing the ability for several client users to chat together in real time in rooms located on the server: Download the chat example application This application contains client side WebSocket HTML5 as well as server side WebSocket implementation using shared workers. The JavaScript code is commented to explain the main techniques in use.

WebSocket Handlers On Wakanda Server, WebSockets are managed through a specific HTTP handler. You need to install this handler and register the WebSocket using the addwebsockethandler( ) method from the HTTP Server class. WebSocket handlers can be removed using the removewebsockethandler( ) method. addwebsockethandler( ) void addwebsockethandler( String pattern, String filepath, String socketid, Boolean shared ) Parameter Type Description pattern String Pattern or path to handle filepath String Path to the JavaScript file in which the handler function is defined socketid String Local name of the WebSocket shared Boolean Use a shared worker (true) or a dedicated worker (false) Description The addwebsockethandler( ) method installs a WebSocket handler script on the server. Once installed, this script will be called to handle any incoming request matching the predefined pattern. This method should usually be called in the Bootstrap file of the application. Example In the pattern parameter, pass a string describing the path or the pattern of the client WebSocket requests that you want to intercept. This pattern corresponds to the url property of the WebSocket instance on the client side. The pattern can be defined through a Regex (Regular expression). For more information, please refer to the addhttprequesthandler( ) method description. In the filepath parameter, pass a string containing the path to the file that has the code to call for this handler. You can pass either an absolute path or a path relative to the project folder (POSIX syntax). In the socketid parameter, pass a local name for the WebSocket. This name is only used with the removewebsockethandler( ) method. In the shared parameter, pass a Boolean value indicating if you want the local WebSocket to be handled through a SharedWorker( ) or a dedicated Worker( ): pass true to use a shared worker (recommended) pass false to use a dedicated worker Using a shared worker is usually recommended because a single thread will be created for all WebSocket connections. It is also more appropriate if you want to share information between the clients. If you use a dedicated worker, each new client WebSocket connection will open a new thread on the server. In this case, you have to pay attention to the server memory depending on the number of concurrent connections. You want to install a WebSocket handler that will manage a chat service in your application. In the bootstrap file of your application, you write: httpserver.addwebsockethandler("/chat", "chat-server.js", "mychat", true); //"/chat" is the incoming WebSocket URL // "chat-server.js" is the script file located at the root of your project folder // "mychat" is the local name of the WebSocket // true means you want to use a shared worker removewebsockethandler( ) void removewebsockethandler( String socketid ) Parameter Type Description socketid String Local name of the WebSocket to remove Description The removewebsockethandler( ) method removes the WebSocket handler socketid from the server. WebSocket handlers are installed with the addwebsockethandler( ) method. Example

You want to uninstall the "mychat" WebSocket: httpserver.removewebsockethandler("mychat");