sgcWebSockets 4.1.0
iii
Table of Contents
IDE Editions ............................................................................................................................... 3
Delphi supported IDE ......................................................................................................... 3
CBuilder supported IDE ...................................................................................................... 3
AppMethod supported IDE ................................................................................................. 3
FreePascal supported IDE ................................................................................................. 3
HTML supported IDE .......................................................................................................... 3
Free Version ....................................................................................................................... 4
Library .................................................................................................................................... 4
Installation .................................................................................................................................. 5
Delphi / CBuilder / Lazarus .................................................................................................... 5
HTML5 Builder ....................................................................................................................... 7
QuickStart .................................................................................................................................. 9
VCL Server ......................................................................................................................... 9
VCL Client .......................................................................................................................... 9
WebBrowser Client ............................................................................................................. 9
How To Use ...................................................................................................................... 10
Linux Compiler .................................................................................................................. 10
Linux (Lazarus) ................................................................................................................. 11
WebBrowser Test .................................................................................................................... 12
Features ................................................................................................................................... 13
Authentication ...................................................................................................................... 13
Custom Objects .................................................................................................................... 15
Secure Connections ............................................................................................................. 16
Compression ........................................................................................................................ 18
Flash ..................................................................................................................................... 19
Bindings ................................................................................................................................ 20
Quality Of Service ................................................................................................................ 21
Queues ................................................................................................................................. 23
Transactions ......................................................................................................................... 25
HTTP .................................................................................................................................... 27
Throttle ................................................................................................................................. 28
Server-sent Events (Push Notifications) .............................................................................. 29
LoadBalancing ..................................................................................................................... 32
HeartBeat ............................................................................................................................. 33
WatchDog ............................................................................................................................. 34
Files ...................................................................................................................................... 35
Proxy .................................................................................................................................... 36
Logs ...................................................................................................................................... 37
General .................................................................................................................................... 38
WebSocket Events ............................................................................................................... 38
WebSocket Parameters Connection .................................................................................... 39
Using inside a DLL ............................................................................................................... 40
TsgcWebSocketServer ............................................................................................................ 41
Methods ............................................................................................................................ 41
Properties ......................................................................................................................... 42
TsgcWebSocketHTTPServer ................................................................................................... 45
Methods ............................................................................................................................ 46
Properties ......................................................................................................................... 46
TsgcWebSocketClient ............................................................................................................. 48
Methods ............................................................................................................................ 48
Properties ......................................................................................................................... 49
TsgcWebSocketClient_SocketIO ............................................................................................ 51
Methods ............................................................................................................................ 51
Properties ......................................................................................................................... 52
Properties ......................................................................................................................... 52
TsgcWebSocketClient_WinHTTP ............................................................................................ 54
Methods ............................................................................................................................ 54
sgcWebSockets 4.1.0
iv
Properties ......................................................................................................................... 54
TsgcWebSocketLoadBalancerServer ...................................................................................... 56
TsgcWebSocketProxyServer ................................................................................................... 57
TsgcIWWebSocketClient ......................................................................................................... 58
Methods ............................................................................................................................ 58
Properties ......................................................................................................................... 58
Connections ............................................................................................................................. 60
TsgcWSConnection ............................................................................................................. 60
Protocols .................................................................................................................................. 62
Protocols .............................................................................................................................. 62
Protocols Javascript ............................................................................................................. 63
Subprotocols ........................................................................................................................ 66
Default .............................................................................................................................. 67
Dataset ............................................................................................................................. 76
Files .................................................................................................................................. 85
WebRTC ........................................................................................................................... 90
WAMP ............................................................................................................................... 93
MQTT .............................................................................................................................. 100
Extensions ............................................................................................................................. 103
Extensions .......................................................................................................................... 103
Extensions | PerMessage-Deflate ...................................................................................... 104
Extensions | Deflate-Frame ................................................................................................ 105
Library .................................................................................................................................... 107
Library | Build ......................................................................................................................... 108
QuickStart .............................................................................................................................. 109
QuickStart | Library | Delphi ............................................................................................... 109
QuickStart | Library | C# ..................................................................................................... 110
Client ...................................................................................................................................... 111
Library | Client .................................................................................................................... 111
Library Client | SocketIO .................................................................................................... 113
Library | Client Protocol SGC ............................................................................................. 117
Server .................................................................................................................................... 120
Library | Server ................................................................................................................... 120
Library | Server Protocol SGC ............................................................................................ 122
WebSockets ........................................................................................................................... 125
JSON ..................................................................................................................................... 126
JSON-RPC 2.0 ...................................................................................................................... 127
Parsers ........................................................................................................................... 127
WAMP .................................................................................................................................... 128
WebRTC ................................................................................................................................ 129
MQTT ..................................................................................................................................... 130
Server-Sent Events ................................................................................................................ 131
License ................................................................................................................................... 133
1
Introduction
sgcWebSockets is a complete package providing access to WebSockets protocol, allowing to
create WebSockets Servers, Intraweb Clients or WebSocket Clients in VCL, Firemonkey, Linux
and FreePascal applications.
Fully functional multithreaded WebSocket server according to RFC 6455.
Supports Firemonkey (Windows and MacOS).
Supports NEXTGEN Compiler (IOS and Android Support).
Supports LINUX Compiler.
Supports Lazarus / FreePascal.
Supports CBuilder.
Supports Chrome, Firefox, Safari, Opera and Internet Explorer (including
iPhone, iPad and iPod)
Supports C#.NET using compiled library (for Windows 32 and 64 bits).
Multiple Threads Support
Supports Message Compression using PerMessage_Deflate extension RFC
7692.
Supports Text and Binary Messages.
Supports Server and Client Authentication.
Server component providing WebSocket and HTTP connections through the
same port.
Proxy Server component allowing to Web Browsers to connect to any TCP
server.
Load Balancing Server.
Client WebSocket based on WinHTTP API.
Client WebSocket supports connections through Socket.IO Servers.
FallBack support through Adobe Flash for old Web Browsers like Internet
Explorer from 6 to 9.
Supports Server-Sent Events (Push Notifications) over HTTP Protocol.
WatchDog and HeartBeat built-in support.
Client WebSocket supports connections through HTTP Proxy Servers and
SOCKS Proxy Servers.
Events Available: OnConnect, OnDisconnect, OnMessage, OnError,
OnHandshake
Built-in sub-protocols: JSON-RPC 2.0, Dataset, WebRTC, MQTT and WAMP
Support for JSON parsers: Delphi JSON and XSuperObject.
Built-in Javascript libraries to support browser clients.
Easy to setup
Javascript Events for a full control
Async Events using Ajax
SSL/TLS Support for Server / Client Components (OpenSSL libraries
required).
Main components available are:
TsgcWebSocketServer: Non-visual component, it's used to manage client
threaded connections. Supports RFCC 6455. Based on Indy library.
TsgcWebSocketHTTPServer: Non-visual component, it's used to manage
client threaded connections. Supports RFCC 6455. Supports HTTP Requests using an
unique port for WebSocket and HTTP Connections. Based on Indy library.
TsgcWebSocketLoadBalancerServer: Non-visual component, it's used to
distribute messages across several back-up servers. Based on Indy library.
TsgcWebSocketClient: Non-visual component, used to establish a WebSocket
connection with a WebSocket server, based on Indy LIbrary.