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