public bool OnConnect() { try { var code = ConfigSingleton.CreateInstance().GetAppConfig <string>("ValidCode"); Console.WriteLine("Collector Socket Connected Success!"); //发送登录信息 TakeServerLoginDto tslLoginDto = new TakeServerLoginDto() { TakeType = collectorType, ValidCode = code }; string data = ProtocalSerialize.SerializeObject(tslLoginDto); ProtocolLogger.WriteLog <TakeServerLoginDto>(tslLoginDto, MainCommand.TakeServer, (ushort)TakeServerCommand.Login, LogerType.Info); socket.Send((ushort)MainCommand.TakeServer, (ushort)TakeServerCommand.Login, data); return(true); } catch (Exception ex) { logger.Error(ex.ToString()); } return(true); }