winddriver/Delphi-Cross-Socket

为什么会报 '不能在IO线程中执行StopLoop!'

Closed this issue · 0 comments

代码片段如下
FHttpServer.OnMessage(procedure(const AConnection: ICrossWebSocketConnection; const ARequestType: TWsMessageType; const ARequestData: TBytes) begin OnMessage(AConnection,ARequestType,ARequestData); end );
`
procedure TNetServerCore.OnMessage(const AConnection: ICrossWebSocketConnection;
const AType: TWsMessageType; const AData: TBytes);
var
Service:IService;
begin
Service := nil;
//查找服务
if GlobalContainer.Registry.FindOne(AConnection.Request.Path) <> nil then
begin
Service := GlobalContainer.Resolve(AConnection.Request.Path);
end;

if Service <> nil then
Service.OnMessage(Self,AConnection,AType,AData);
end; <--------- Exception class ECrossSocket with message '不能在IO线程中执行StopLoop!'. Process WebSocketServer.exe (19904)
`

IService声明如下
IService = interface procedure OnMessage(ACore:INetServerCore;const AConnection: ICrossWebSocketConnection;const AType: TWsMessageType; const AData: TBytes); end;
实现如下
procedure TServiceAuthLogin.OnMessage(ACore: INetServerCore; const AConnection: ICrossWebSocketConnection; const AType: TWsMessageType; const AData: TBytes); begin { TODO : 在此实现服务代码 } // Writeln(AConnection.PeerAddr); Writeln('11'); end;

调用栈

:778e1722 KERNELBASE.RaiseException + 0x62 Net.CrossSocket.Iocp.TIocpCrossSocket.StopLoop Net.CrossSocket.Base.TCrossSocketBase.BeforeDestruction :0040992c @BeforeDestruction + $C :00410e7c TInterfacedObject._Release + $3C :0040fa3b @IntfClear + $13 :00410e7c TInterfacedObject._Release + $3C :0040fa3b @IntfClear + $13 Rat.Net.Server.CoreClass.TNetServerCore.OnMessage(TCrossWebSocketConnection($253B734) as ICrossWebSocketConnection,wtText,(72, 69, 76, 76, 79, 32, 83, 69, 82, 86, 73, 67, 69)) Rat.Net.Server.CoreClass.TNetServerCore.Create[1]$ActRec.$5$Body(TCrossWebSocketConnection($253B734) as ICrossWebSocketConnection,wtText,(72, 69, 76, 76, 79, 32, 83, 69, 82, 86, 73, 67, 69)) Net.CrossWebSocketServer.TCrossWebSocketServer._OnMessage(TCrossWebSocketConnection($253B734) as ICrossWebSocketConnection,wtText,(72, 69, 76, 76, 79, 32, 83, 69, 82, 86, 73, 67, 69))
实在是搞不清楚为啥了,请指点。