1. Create a new Window Forms Application
2. Drop a TsgcWebSocketClient onto a Form and configure Host and Port Properties to connect to Server.
3. Drop a TButton in a Form, Double Click and type this code:
TsgcWebSocketClient1.Active = true;
4. Drop a Button onto the Form, Double Click and type this code:
TsgcWebSocketClient1.WriteData("Hello Server From VCL Client");
TsgcWebSocketClient can connect to WebSocket servers using secure and none-secure connections.
TLSOptions
In TLSOptions property there are the properties to customize a secure connection. The most important property is version, which specifies the version of TLS protocol. Usually setting TLS property to true and TLSOptions.Version to tls1_2 is enough for the wide majority of WebSocket Servers.
If you get an error trying to connect to a server about TLS protocol, most probably this server requires a TLS version newer than you set. Example: if you set TLSOptions.Version = tls1_0 and you get an error about TLS protocol, try to set to tls1_2 and most probably will work.
If TLSOptions.IOHandler is set to iohOpenSSL, you need to deploy OpenSSL libraries (which are the libraries that handle all TLS stuff), check the following article about OpenSSL.
If TLSOptions.IOHandler is set to iohSChannel, then there is no need to deploy any library.
TsgcWebSocket client supports 4 types of Authentications:
oClient = new TsgcWebSocketClient(); oClient.Authorization.Enabled = true; oClient.Authorization.Basic.Enabled = true; oClient.User = "your user"; oClient.Password = "your password"; oClient.Authorization.Token.Enabled = false; oClient.Authorization.URL.Enabled = false; oClient.Authorization.Session.Enabled = false; oClient.Active = true;
HeartBeat property allows to send a Ping every X seconds to maintain connection alive. Some servers, close TCP connections if there is no data exchanged between peers. HeartBeat solves this problem, sending a ping every a specific interval. Usually this is enough to maintain a connection active, but you can set a TimeOut interval if you want to close connection if a response from server is not received after X seconds.
Example: send a ping every 30 seconds
oClient = new TsgcWebSocketClient(); oClient.HeartBeat.Interval = 30; oClient.HeartBeat.Timeout = 0; oClient.HeartBeat.Enabled = true; oClient.Active = true;
If WatchDog is enabled, when client detects a disconnection, WatchDog try to reconnect again every X seconds until connection is active again.
Example: reconnect every 10 seconds after a disconnection with unlimited attempts.
oClient = new TsgcWebSocketClient(); oClient.WatchDog.Interval = 10; oClient.WatchDog.Attempts = 0; oClient.WatchDog.Enabled = true; oClient.Active = true;
TsgcWebSocketClient can connect to WebSocket servers but can connect to plain TCP Servers too.
URL Property
The most easy way to connect to a WebSocket server is use URL property and call Active = true.
Example: connect to 127.0.0.1 port 5555
oClient = new TsgcWebSocketClient(); oClient.URL = "tcp://127.0.0.1:5555"; oClient.Active = true;
Once client has connected to server, it can send Text Messages to server. To send a Text Message, just call WriteData() method and send your text message.
Send a Text Message
Call To WriteData() method and send a Text message. This method is executed on the same thread that is called.
TsgcWebSocketClient1.WriteData("My First sgcWebSockets Message!.");
When client receives a Text Message, OnMessage event is fired, just read Text parameter to know the string of message received.
void OnMessage(TsgcWSConnection Connection, string Text) { MessageBox.Show("Message Received from Server: " + Text); }
By default, client uses neAsynchronous method to dispatch OnMessage event, this means that this event is executed on the context of Main Thread, so it's thread-safe to update any control of a form for example.
If your client receives lots of messages or you need to control the synchronization with other threads, set NotifyEvents property to neNoSync, this means that OnMessage event will be executed on the context of connection thread, so if you require to update any control of a form or access shared objects, you must implement your own synchronization methods.
.NET Components. Share your code using our sgcWebSockets library for your .NET projects. Includes Server, Clients and several protocols for building and connecting to applications.
.NET
Real Time Monitor
Shows 3 gauges which are updated automatically every x seconds.
SGC Protocol (RPC, PubSub, Transactional Messages, Acknowledgement, QoS...)
Shows the use of subscriptions to a custom channel, transactions, Remote Procedure Calls, Acknowledgements...
Presence Protocol (PubSub, Publish Messages, Members subscribed...)
Allows to know who is subscribed to a channel, example: chat rooms, collaborators on a document, people viewing the same web page, competitors in a game...
DevExtreme Data Grid
This example shows how to use the DevExtreme Data Grid with a sgcWebSockets server and the Dataset protocol updating the stock quotes in real-time.
KendoUI Grid
Use KendoUI grid to create/edit/delete records and all changes will be broadcasted to all clients connected.
Real Time Quotes
Shows a grid where quotes are automatically updated in Real Time.
AppRTC (Audio And Video) using WebSockets
Broadcast audio and video between 2 clients using AppRTC code.
Multi-user Video Conference
Multi-user (many-to-many) video chat using mesh networking model.
Screen Sharing
Multi-user (one-to-many) screen sharing using star topology.
Video BroadCasting
Multi-user (one-to-many) video broadcasting using star topology.
Real Time Tickets
Create customer clients and all changes are broadcasted to all clients connected.
Chat
Simple chat to send/receive messages from others.
Binary Messages
Broadcast images to all clients connected.
WAMP Protocol (RPC and PubSub)
Show the use of WAMP protocol.
WebRTC (Audio and Video) via WebSockets
Broadcast audio and video between 2 clients.
Server-Sent Events
Shows the use of Server-Sent events.
sgcWebSockets Community for Windows, Linux64 and OSX64
sgcWebSockets .NET Community
sgcWebSockets .NET Community Nuget Package
Includes a set of compiled demos which shows the use of sgcWebSockets
Download
ASP.NET Core React Demo
Download
Buy now your License to get sgcWebSockets source code: .NET package includes full source code for assemblies in the PROFESSIONAL edition, but if you require to rebuild sgcWebSockets.dll, select the ENTERPRISE edition.
When you buy a license, you'll get access to source code and 1 Year of updates.
If you have any doubts or questions, please Contact us for details.
Which support is included?
After you register your license, you get 1 year of updates and support by our online HelpDesk, public forums or by email.
How much time I need to wait between I purchase and I get the product?
Once registered, you get a link to download your package, so you don't need to wait, you'll get the package automatically after you purchase.
Where can I download updates of the library?
After successful registration, you get an user and password to login our website and you can download latest source version. When we release a new version, you'll get notified by mail.
Is there a Trial version of the sgcWebsockets?
Yes, you can download a trial version with precompiled units. This Trial is fully functional by limited in time.
Is Source Code available?
Yes, full source code is included only in sgcWebSockets .NET Enterprise edition.
How is your license scheme?
Is per-developer, so each developer that uses our product must have their own license.
Does the license expire?
No, the licenses are perpetual (with 12 months of free updates) and are royalty-free. Perpetual means that after expiration, you can use our components without limits, but this doesn't mean that you will get updates forever.
There are discounts if I renew a license?
Yes, if your subscription includes renewal discounts, a mail is sent automatically, when your license expires, with a discount code.
More info about checkout?
Yes, you can check following page with more info about checkout process.