DelphiWebsockets/IdServerIOHandlerWebsocket.pas

53 lines
1.4 KiB
ObjectPascal
Raw Normal View History

2013-11-11 21:14:42 +01:00
unit IdServerIOHandlerWebsocket;
interface
uses
Classes,
IdServerIOHandlerStack, IdIOHandlerStack, IdGlobal, IdIOHandler, IdYarn, IdThread, IdSocketHandle,
IdIOHandlerWebsocket;
type
TIdServerIOHandlerWebsocket = class(TIdServerIOHandlerStack)
protected
procedure InitComponent; override;
public
function Accept(ASocket: TIdSocketHandle; AListenerThread: TIdThread;
AYarn: TIdYarn): TIdIOHandler; override;
function MakeClientIOHandler(ATheThread:TIdYarn): TIdIOHandler; override;
end;
implementation
{ TIdServerIOHandlerStack_Websocket }
function TIdServerIOHandlerWebsocket.Accept(ASocket: TIdSocketHandle;
AListenerThread: TIdThread; AYarn: TIdYarn): TIdIOHandler;
begin
Result := inherited Accept(ASocket, AListenerThread, AYarn);
if Result <> nil then
2013-11-18 14:27:13 +01:00
begin
2013-11-11 21:14:42 +01:00
(Result as TIdIOHandlerWebsocket).IsServerSide := True; //server must not mask, only client
2013-11-18 14:27:13 +01:00
(Result as TIdIOHandlerWebsocket).UseNagle := False;
end;
2013-11-11 21:14:42 +01:00
end;
procedure TIdServerIOHandlerWebsocket.InitComponent;
begin
inherited InitComponent;
IOHandlerSocketClass := TIdIOHandlerWebsocket;
end;
function TIdServerIOHandlerWebsocket.MakeClientIOHandler(
ATheThread: TIdYarn): TIdIOHandler;
begin
Result := inherited MakeClientIOHandler(ATheThread);
if Result <> nil then
2013-11-18 14:27:13 +01:00
begin
2013-11-11 21:14:42 +01:00
(Result as TIdIOHandlerWebsocket).IsServerSide := True; //server must not mask, only client
2013-11-18 14:27:13 +01:00
(Result as TIdIOHandlerWebsocket).UseNagle := False;
end;
2013-11-11 21:14:42 +01:00
end;
end.