local sync
This commit is contained in:
parent
86dc2bfc35
commit
7a59f2b272
|
@ -246,7 +246,7 @@ begin
|
|||
if ARaiseExceptionOnTimeout then
|
||||
EIdReadTimeout.Toss(RSIdNoDataToRead) //exit, no data can be received
|
||||
else
|
||||
Exit;
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
SetLength(VBuffer, RecvBufferSize);
|
||||
|
|
|
@ -584,6 +584,8 @@ var
|
|||
errorref: TSocketIOError;
|
||||
error: ISuperObject;
|
||||
begin
|
||||
if ASocket = nil then Exit;
|
||||
|
||||
if not FConnections.ContainsValue(ASocket) and
|
||||
not FConnectionsGUID.ContainsValue(ASocket) then
|
||||
begin
|
||||
|
@ -1258,8 +1260,6 @@ begin
|
|||
for context in FConnections.Values do
|
||||
begin
|
||||
if context.IsDisconnected then Continue;
|
||||
// if not context.IsSocketIO then
|
||||
// raise EIdSocketIoUnhandledMessage.Create('Not a socket.io connection!');
|
||||
|
||||
if not Assigned(aCallback) then
|
||||
WriteSocketIOMsg(context, ''{no room}, aMessage, nil)
|
||||
|
@ -1274,8 +1274,6 @@ begin
|
|||
for context in FConnectionsGUID.Values do
|
||||
begin
|
||||
if context.IsDisconnected then Continue;
|
||||
// if not context.IsSocketIO then
|
||||
// raise EIdSocketIoUnhandledMessage.Create('Not a socket.io connection!');
|
||||
|
||||
if not Assigned(aCallback) then
|
||||
WriteSocketIOMsg(context, ''{no room}, aMessage, nil)
|
||||
|
|
|
@ -18,7 +18,9 @@ type
|
|||
FSocketIO: TIdServerSocketIOHandling_Ext;
|
||||
function GetSocketIO: TIdServerSocketIOHandling;
|
||||
protected
|
||||
FROTransportContexts: TInterfaceList;
|
||||
procedure InternalServerConnect(AThread: TIdContext); override;
|
||||
procedure InternalServerDisConnect(AThread: TIdContext); virtual;
|
||||
procedure InternalServerCommandGet(AThread: TIdThreadClass;
|
||||
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); override;
|
||||
procedure ProcessRemObjectsRequest(const AThread: TIdContext; const strmRequest: TMemoryStream; const strmResponse: TMemoryStream);
|
||||
|
@ -87,16 +89,19 @@ begin
|
|||
inherited;
|
||||
|
||||
FSocketIO := TIdServerSocketIOHandling_Ext.Create;
|
||||
FROTransportContexts := TInterfaceList.Create;
|
||||
|
||||
IndyServer.ContextClass := TROIdServerWSContext;
|
||||
if Self.IndyServer.IOHandler = nil then
|
||||
IndyServer.IOHandler := TIdServerIOHandlerWebsocket.Create(Self);
|
||||
IndyServer.OnDisconnect := InternalServerDisConnect;
|
||||
end;
|
||||
|
||||
destructor TROIndyHTTPWebsocketServer.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
FSocketIO.Free;
|
||||
FROTransportContexts.Free;
|
||||
end;
|
||||
|
||||
function TROIndyHTTPWebsocketServer.GetDispatchersClass: TROMessageDispatchersClass;
|
||||
|
@ -120,13 +125,26 @@ begin
|
|||
inherited InternalServerCommandGet(AThread, ARequestInfo, AResponseInfo)
|
||||
end;
|
||||
|
||||
procedure TROIndyHTTPWebsocketServer.InternalServerConnect(AThread: TIdContext);
|
||||
|
||||
procedure TROIndyHTTPWebsocketServer.InternalServerConnect(AThread: TIdContext);
|
||||
begin
|
||||
inherited;
|
||||
(AThread as TIdServerWSContext).OnCustomChannelExecute := Self.OnCustomChannelExecute;
|
||||
(AThread as TROIdServerWSContext).OnRemObjectsRequest := Self.ProcessRemObjectsRequest;
|
||||
end;
|
||||
|
||||
procedure TROIndyHTTPWebsocketServer.InternalServerDisConnect(
|
||||
AThread: TIdContext);
|
||||
var
|
||||
transport: TROTransportContext;
|
||||
begin
|
||||
transport := AThread.Data as TROTransportContext;
|
||||
if transport <> nil then
|
||||
FROTransportContexts.Remove(transport);
|
||||
//transport._Release;
|
||||
AThread.Data := nil;
|
||||
end;
|
||||
|
||||
procedure TROIndyHTTPWebsocketServer.Loaded;
|
||||
begin
|
||||
//do before inherited in case of designtime connection
|
||||
|
@ -159,7 +177,8 @@ begin
|
|||
begin
|
||||
//create IROTransport object
|
||||
transport := TROTransportContext.Create(Self, AThread as TIdServerWSContext);
|
||||
(transport as IROTransport)._AddRef;
|
||||
//(transport as IROTransport)._AddRef;
|
||||
FROTransportContexts.Add(transport);
|
||||
//attach RO transport to indy context
|
||||
AThread.Data := transport;
|
||||
//todo: enveloppes
|
||||
|
|
Loading…
Reference in a new issue