Z
zhaojianzhu
Unregistered / Unconfirmed
GUEST, unregistred user!
每个TCP连接在用户登陆(login)后建立连接对象(TTcpConnect)负责处理该连接的数据,一般的方法是使用TCPServer的OnExecute事件,但我想在TTcpConnect建立Execute方法代替TCPServer.execute 处理该连接数据。那位有什么办法???我研究了若干天了。
下面是我发现的跟execute有调用关系统的代码到function TIdContext.Run时就找不到是谁调用了他。
function TIdContext.Run: Boolean;
begin
if Assigned(OnRun) then begin
Result := OnRun(Self);
end else begin
Result := True;
end;
end;
procedure TIdListenerThread.Run;
begin
……………………………………………
LContext := Server.FContextClass.Create(LPeer, LYarn, Server.Contexts);
// We set these instead of having the context call them directly
// because they are protected methods. Also its good to keep
// Context indepent of the server as well.
LContext.OnBeforeRun := Server.DoConnect;
LContext.OnRun := Server.DoExecute;
LContext.OnAfterRun := Server.DoDisconnect;
End;
function TIdTCPServer.DoExecute(AContext: TIdContext): Boolean;
begin
if Assigned(OnExecute) then begin
OnExecute(AContext);
end;
Result := False;
if AContext <> nil then begin
if AContext.Connection <> nil then begin
Result := AContext.Connection.Connected;
end;
end;
end;
下面是我发现的跟execute有调用关系统的代码到function TIdContext.Run时就找不到是谁调用了他。
function TIdContext.Run: Boolean;
begin
if Assigned(OnRun) then begin
Result := OnRun(Self);
end else begin
Result := True;
end;
end;
procedure TIdListenerThread.Run;
begin
……………………………………………
LContext := Server.FContextClass.Create(LPeer, LYarn, Server.Contexts);
// We set these instead of having the context call them directly
// because they are protected methods. Also its good to keep
// Context indepent of the server as well.
LContext.OnBeforeRun := Server.DoConnect;
LContext.OnRun := Server.DoExecute;
LContext.OnAfterRun := Server.DoDisconnect;
End;
function TIdTCPServer.DoExecute(AContext: TIdContext): Boolean;
begin
if Assigned(OnExecute) then begin
OnExecute(AContext);
end;
Result := False;
if AContext <> nil then begin
if AContext.Connection <> nil then begin
Result := AContext.Connection.Connected;
end;
end;
end;