当前位置: 首页>>代码示例>>C#>>正文


C# TasClient.Connect方法代码示例

本文整理汇总了C#中Springie.Client.TasClient.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# TasClient.Connect方法的具体用法?C# TasClient.Connect怎么用?C# TasClient.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Springie.Client.TasClient的用法示例。


在下文中一共展示了TasClient.Connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    public bool Start()
    {
      if (config.AttemptToRecconnect) {
        recon = new Timer(config.AttemptReconnectInterval*1000);
        recon.Elapsed += new ElapsedEventHandler(recon_Elapsed);
      }

      recon.Enabled = false;

      try {
        spring = new Spring(config.SpringPath);
      } catch {
        MessageBox.Show("Spring not found in " + config.SpringPath, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        OpenFileDialog od = new OpenFileDialog();
        od.FileName = Spring.ExecutableName;
        od.DefaultExt = Path.GetExtension(Spring.ExecutableName);
        od.InitialDirectory = config.SpringPath;
        od.Title = "Please select your spring installation";
        od.RestoreDirectory = true;
        od.CheckFileExists = true;
        od.CheckPathExists = true;
        od.AddExtension = true;
        od.Filter = "Executable (*.exe)|*.exe";
        DialogResult dr = od.ShowDialog();
        if (dr == DialogResult.OK) {
          config.SpringPath = Path.GetDirectoryName(od.FileName);
          SaveConfig();
          try {
            spring = new Spring(config.SpringPath);
          } catch (Exception e) {
            MessageBox.Show(e.ToString(), "Error while checking spring, exiting");
            Application.Exit();
            return false;
          }
        } else {
          MessageBox.Show("Spring not found, exiting");
          Application.Exit();
          return false;
        }
      }

      tas = new TasClient();
      tas.ConnectionLost += new EventHandler<TasEventArgs>(tas_ConnectionLost);
      tas.Connected += new EventHandler<TasEventArgs>(tas_Connected);
      tas.LoginDenied += new EventHandler<TasEventArgs>(tas_LoginDenied);
      tas.LoginAccepted += new EventHandler<TasEventArgs>(tas_LoginAccepted);
      tas.Said += new EventHandler<TasSayEventArgs>(tas_Said);
      tas.MyStatusChangedToInGame += new EventHandler<TasEventArgs>(tas_MyStatusChangedToInGame);
      spring.SpringExited += new EventHandler(spring_SpringExited);
      spring.SpringStarted += new EventHandler(spring_SpringStarted);
      spring.PlayerSaid += new EventHandler<SpringLogEventArgs>(spring_PlayerSaid);
      autoHost = new AutoHost(tas, spring, null);
      autoUpdater = new AutoUpdater(spring, tas);

      if (config.StatsEnabled) stats = new Stats(tas, spring);
      try {
        tas.Connect(config.ServerHost, config.ServerPort);
      } catch {
        recon.Start();
      }
      return true;
    }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:62,代码来源:Main.cs

示例2: Start

        public bool Start()
        {
            if (config.AttemptToRecconnect) {
                recon = new Timer(config.AttemptReconnectInterval*1000);
                recon.Elapsed += recon_Elapsed;
            }

            recon.Enabled = false;
            spring = new Spring();


            tas = new TasClient();
            tas.ConnectionLost += tas_ConnectionLost;
            tas.Connected += tas_Connected;
            tas.LoginDenied += tas_LoginDenied;
            tas.LoginAccepted += tas_LoginAccepted;
            tas.Said += tas_Said;
            tas.MyStatusChangedToInGame += tas_MyStatusChangedToInGame;
            tas.ChannelUserAdded += tas_ChannelUserAdded;
            spring.SpringExited += spring_SpringExited;
            spring.SpringStarted += spring_SpringStarted;
            spring.PlayerSaid += spring_PlayerSaid;
            autoHost = new AutoHost(tas, spring, null);
            if (config.PlanetWarsEnabled) InitializePlanetWarsServer();
            autoUpdater = new AutoUpdater(spring, tas);

            if (config.StatsEnabledReal) stats = new Stats(tas, spring);
            try {
                tas.Connect(config.ServerHost, config.ServerPort);
            } catch {
                recon.Start();
            }
            return true;
        }
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:34,代码来源:Main.cs


注:本文中的Springie.Client.TasClient.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。