/// <summary> /// /// </summary> /// <param name="applicationId"></param> /// <param name="configFileName"></param> public BaseClientManager(string applicationId, string configFileName) { this.applicationId = applicationId; this.configFileName = configFileName; if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.configFileName))) { throw (new FileNotFoundException("没有找的客户端默认的配置文件!")); } try { ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = this.configFileName; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); AppSettingsSection appSection = (AppSettingsSection)config.Sections["appSettings"]; ip = appSection.Settings["ip"].Value; port = Convert.ToInt32(appSection.Settings["port"].Value); tcpCli = new TcpCli(); tcpCli.Resovlver = new Neusoft.FrameWork.Server.DatagramResolver(DefaultEndTag); tcpCli.DisConnectedServer += new NetEvent(DisConnectedServer); tcpCli.ConnectingServer += new NetEvent(ConnectingServer); tcpCli.ConnectedServer += new NetEvent(ConnectedServer); tcpCli.ReceivedDatagram += new NetEvent(RecvdServerData); tcpCli.CannotConnectedServer += new NetEvent(CannotConnectedServer); } catch (Exception ex) { throw (ex); } }
/// <summary> /// /// </summary> /// <param name="applicationId"></param> /// <param name="ip"></param> /// <param name="port"></param> public BaseClientManager(string applicationId, string ip, int port) { try { this.applicationId = applicationId; this.ip = ip; this.port = port; tcpCli = new TcpCli(); tcpCli.Resovlver = new Neusoft.FrameWork.Server.DatagramResolver(DefaultEndTag); tcpCli.DisConnectedServer += new NetEvent(DisConnectedServer); tcpCli.ConnectingServer += new NetEvent(ConnectingServer); tcpCli.ConnectedServer += new NetEvent(ConnectedServer); tcpCli.ReceivedDatagram += new NetEvent(RecvdServerData); tcpCli.CannotConnectedServer += new NetEvent(CannotConnectedServer); } catch (Exception ex) { throw (ex); } }