1,317
社区成员
发帖
与我相关
我的任务
分享class TMyIOHandlerSocket :public TIdIOHandlerStack{
public:
void __fastcall CheckForDisconnect(bool ARaiseExceptionIfDisconnected,bool AIgnoreBuffer);
};
void __fastcall TIdIOHandlerStack.CheckForDisconnect(bool ARaiseExceptionIfDisconnected,bool AIgnoreBuffer);
{
bool LDisconnected;
// ClosedGracefully // Server disconnected
// IOHandler = nil // Client disconnected
if (ClosedGracefully ){
if (BindingAllocated())(
Close();
// Call event handlers to inform the user that we were disconnected
DoStatus(hsDisconnected);
//DoOnDisconnected;
}
LDisconnected = true;
} else {
LDisconnected = ! BindingAllocated;
}
// Do not raise unless all data has been read by the user
if (LDisconnected) {
if ((InputBufferIsEmpty() || AIgnoreBuffer) && ARaiseExceptionIfDisconnected ) {
RaiseConnClosedGracefully(); //如果不想弹出消息就在这里修改,你可以在关闭的时候设置一个标志从而判断是否需要发出错误.当然,这是不建议的.
}
}
}