Delphi Server WebSocket
TsgcWebSocketHTTPServer — un componente server WebSocket e HTTP multithread con supporto IOCP/EPOLL, SSL/TLS, autenticazione e file serving statico.
TsgcWebSocketHTTPServer — un componente server WebSocket e HTTP multithread con supporto IOCP/EPOLL, SSL/TLS, autenticazione e file serving statico.
Server HTTP + WebSocket — serve handshake wss://, fa broadcast dei messaggi e include TLS, autenticazione, registrazione al bilanciatore di carico e HTTP/2.
TsgcWebSocketHTTPServer
WebSocket — RFC 6455
Windows, macOS, Linux, iOS, Android
Professional / Enterprise
Trascina un TsgcWebSocketHTTPServer, imposta Port e SSL, collega OnMessage e il server è attivo.
uses
sgcWebSocket, sgcWebSocket_Server, sgcWebSocket_Classes;
var
WSServer: TsgcWebSocketHTTPServer;
begin
WSServer := TsgcWebSocketHTTPServer.Create(nil);
WSServer.Port := 80;
WSServer.OnConnect := WSServerConnect;
WSServer.OnMessage := WSServerMessage;
WSServer.OnDisconnect := WSServerDisconnect;
WSServer.OnError := WSServerError;
WSServer.OnAuthentication := WSServerAuthentication;
WSServer.Active := True;
end;
procedure TForm1.WSServerMessage(Connection: TsgcWSConnection;
const Text: string);
begin
// Broadcast to every connected client
WSServer.WriteData(Text);
end;
procedure TForm1.WSServerAuthentication(Connection: TsgcWSConnection;
aUser, aPassword: string; var Authenticated: Boolean);
begin
Authenticated := (aUser = 'admin') and (aPassword = 's3cret');
end;
// uses: sgcWebSocket, sgcWebSocket_Server
TsgcWebSocketHTTPServer *WSServer = new TsgcWebSocketHTTPServer(this);
WSServer->Port = 80;
WSServer->OnConnect = WSServerConnect;
WSServer->OnMessage = WSServerMessage;
WSServer->OnDisconnect = WSServerDisconnect;
WSServer->OnError = WSServerError;
WSServer->OnAuthentication = WSServerAuthentication;
WSServer->Active = true;
void __fastcall TForm1::WSServerMessage(TsgcWSConnection *Connection,
const UnicodeString Text)
{
WSServer->WriteData(Text);
}
using esegece.sgcWebSockets;
var server = new TsgcWebSocketHTTPServer();
server.Port = 80;
server.OnConnect += (conn) => Console.WriteLine("#connected: " + conn.IP);
server.OnMessage += (conn, text) => server.WriteData(text); // broadcast
server.OnDisconnect += (conn, code) => Console.WriteLine("#disconnected: " + code);
server.OnAuthentication += (conn, user, pass, ref ok) => { ok = (user == "admin" && pass == "s3cret"); };
server.Active = true;
27 proprietà published, 7 metodi, 22 eventi — presi dal riferimento del componente.
Proprietà published: Active, Port, Bindings.
Metodi: Broadcast, WriteData, Ping.
Proprietà published: HeartBeat, WatchDog, LoadBalancer.
Proprietà published: Authentication, SSL, SSLOptions.
Eventi: OnStartup, OnShutdown, OnTCPConnect.
Eventi: OnMessage, OnBinary, OnFragmented.
Vai direttamente al riferimento del componente, prendi il progetto demo pronto all'uso e scarica la versione di prova.
| Guida online — TsgcWebSocketServer Riferimento completo di proprietà, metodi ed eventi di questo componente. | Apri | |
| Progetto demo — 01.WebSocket\02.Server Progetto di esempio pronto all'uso. Incluso nel pacchetto sgcWebSockets — scarica la versione di prova qui sotto. | Apri | |
| Documento tecnico (PDF) Funzionalità, guida rapida, esempi di codice per Delphi, C++ Builder e .NET e riferimenti alle fonti primarie — solo per questo componente. | Apri | |
| Manuale utente (PDF) Manuale completo che copre ogni componente della libreria. | Apri |