Merge branch 'master' of https://github.com/andremussche/DelphiWebsockets
This commit is contained in:
commit
e6d3ad515a
|
@ -594,6 +594,8 @@ begin
|
|||
// end
|
||||
// else
|
||||
// FSocketIOContext.Create(Self); //update with new iohandler etc
|
||||
|
||||
(FSocketIOContext as TSocketIOContext).ConnectSend := True; //connect already send via url? GET /socket.io/1/websocket/9elrbEFqiimV29QAM6T-
|
||||
FSocketIO.WriteConnect(FSocketIOContext as TSocketIOContext);
|
||||
end;
|
||||
|
||||
|
|
|
@ -259,7 +259,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
|
||||
|
@ -1265,8 +1267,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)
|
||||
|
@ -1281,8 +1281,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