Serwer WebSocket dla Delphi
TsgcWebSocketHTTPServer: wielowątkowy komponent serwera WebSocket i HTTP z obsługą IOCP/EPOLL, SSL/TLS, uwierzytelnianiem i serwowaniem plików statycznych.
TsgcWebSocketHTTPServer: wielowątkowy komponent serwera WebSocket i HTTP z obsługą IOCP/EPOLL, SSL/TLS, uwierzytelnianiem i serwowaniem plików statycznych.
Serwer HTTP + WebSocket obsługuje handshake wss://, rozgłasza wiadomości i zawiera wbudowane TLS, uwierzytelnianie, rejestrację w load balancerze oraz HTTP/2.
TsgcWebSocketHTTPServer
WebSocket — RFC 6455
Windows, macOS, Linux, iOS, Android
Professional / Enterprise
Upuść TsgcWebSocketHTTPServer, ustaw Port i SSL, podłącz OnMessage i serwer działa.
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;
Opublikowane właściwości: 27, metody: 7, zdarzenia: 22, pobrane z dokumentacji komponentu.
Opublikowane właściwości: Active, Port, Bindings.
Metody: Broadcast, WriteData, Ping.
Opublikowane właściwości: HeartBeat, WatchDog, LoadBalancer.
Opublikowane właściwości: Authentication, SSL, SSLOptions.
Zdarzenia: OnStartup, OnShutdown, OnTCPConnect.
Zdarzenia: OnMessage, OnBinary, OnFragmented.
Bezpośredni link do dokumentacji komponentu, gotowy do uruchomienia projekt demo i pobieranie wersji próbnej.
| Pomoc online — TsgcWebSocketServer Pełna dokumentacja właściwości, metod i zdarzeń tego komponentu. | Otwórz | |
| Projekt demonstracyjny — 01.WebSocket\02.Server Gotowy do uruchomienia projekt przykładowy. Dostarczany w pakiecie sgcWebSockets — pobierz wersję próbną poniżej. | Otwórz | |
| Dokument techniczny (PDF) Funkcje, szybki start, przykłady kodu dla Delphi, C++ Builder i .NET oraz źródła pierwotne, wyłącznie dla tego komponentu. | Otwórz | |
| Podręcznik użytkownika (PDF) Kompleksowy podręcznik obejmujący każdy komponent biblioteki. | Otwórz |