constructor TfrmMain.Create(AOwner: TComponent);
begin
inherited;
__defaultFile := ChangeFileExt(ParamStr(0), '.history.json'); //改变文件的后缀
FASyncInvoker := TASyncInvoker.Create; //创建异步调用请求
FASyncInvoker.Start(OnASyncWork); //启动弄步调用请求
FFileLogger := TSafeLogger.Create; //创建日志记录类
FFileLogger.setAppender(TLogFileAppender.Create(False), true);
FSendDataOnRecv := chkRecvEcho.Checked; //是否启用接收到数据后直接返回数据
FRecvOnLog := chkRecvOnLog.Checked; //是否启用收到数据显示
FRecvOnSaveToFile := chkSaveData.Checked; //是否保存数据
FConvertHex := chkHex.Checked; // 是否启用16进制
sfLogger.setAppender(TStringsAppender.Create(mmoRecvMessage.Lines)); //safeLogger记录到Memo中的方法
sfLogger.AppendInMainThread := true; //追加记录
FIocpClientSocket := TDiocpTcpClient.Create(Self); //创建Tdiocptpclient类
FIocpClientSocket.createDataMonitor;
FIocpClientSocket.OnContextConnected := OnContextConnected; //连接后调用事件
FIocpClientSocket.OnReceivedBuffer := OnRecvdBuffer; //收到数据后调用
FIocpClientSocket.RegisterContextClass(TEchoContext); //注册TEchocontext类记录
FIocpClientSocket.DisableAutoConnect := True; //是否自动重连
TFMMonitor.createAsChild(tsMonitor, FIocpClientSocket); //系统信息统计
ReadHistory(__defaultFile);
end;