예제 #1
0
        public static void Init(ClientInitializer initializer)
        {
            var user = new User(initializer.Nick, initializer.NickColor);

            if (Interlocked.CompareExchange(ref model, new ClientModel(user), null) != null)
            {
                throw new InvalidOperationException("model already inited");
            }

            Api    = new ClientApi();
            Client = new AsyncClient(initializer.Nick);
            Peer   = new AsyncPeer();

            Plugins = new ClientPluginManager(initializer.PluginsPath);
            Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
예제 #2
0
        public static void Init(ClientInitializer initializer)
        {
            if (Interlocked.CompareExchange(ref model, new ClientModel(), null) != null)
            {
                throw new InvalidOperationException("model already inited");
            }

            using (var client = Get())
                model.User = new User(initializer.Nick, initializer.NickColor);

            // API установится автоматически при подключении к серверу (согласно версии на сервере)
            Client  = new AsyncClient(initializer.Nick);
            Peer    = new AsyncPeer();
            Plugins = new ClientPluginManager(initializer.PluginsPath);
            Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
예제 #3
0
        public static void Init(ClientInitializer initializer)
        {
            if (!initializer.Certificate.HasPrivateKey)
            {
                throw new ArgumentException("Initializer should have certificate with private key.");
            }

            var userId = new UserId(initializer.Nick, initializer.Certificate.Thumbprint);
            var user   = new ClientUser(userId, initializer.NickColor, initializer.Certificate);

            if (Interlocked.CompareExchange(ref _chat, new ClientChat(user), null) != null)
            {
                throw new InvalidOperationException("model already inited");
            }

            TrustedCertificates = new ClientCertificatesStorage(initializer.TrustedCertificatesPath, _notifier, _logger);

            Api    = new ClientApi();
            Client = new AsyncClient(userId, TrustedCertificates, initializer.Certificate, Api, _notifier, _logger);
            Peer   = new AsyncPeer(userId, initializer.Certificate, Api, _notifier, _logger);

            Plugins = new ClientPluginManager(initializer.PluginsPath);
            Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
예제 #4
0
    public static void Init(ClientInitializer initializer)
    {
      var user = new User(initializer.Nick, initializer.NickColor);

      if (Interlocked.CompareExchange(ref model, new ClientModel(user), null) != null)
        throw new InvalidOperationException("model already inited");

      Api = new ClientApi();
      Client = new AsyncClient(initializer.Nick);
      Peer = new AsyncPeer();

      Plugins = new ClientPluginManager(initializer.PluginsPath);
      Plugins.LoadPlugins(initializer.ExcludedPlugins);
    }
예제 #5
0
        private void InitializeClient(bool loopback)
        {
            var excludedPlugins = Settings.Current.Plugins
            .Where(s => !s.Enabled)
            .Select(s => s.Name)
            .ToArray();

              var initializer = new ClientInitializer
              {
            Nick = Settings.Current.Nick,
            NickColor = Settings.Current.NickColor,

            PluginsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"),
            ExcludedPlugins = excludedPlugins
              };

              ClientModel.Init(initializer);

              try
              {
            ClientModel.Player.SetOptions(Settings.Current.OutputAudioDevice);
            ClientModel.Recorder.SetOptions(Settings.Current.InputAudioDevice, new AudioQuality(1, Settings.Current.Bits, Settings.Current.Frequency));
              }
              catch (ModelException me)
              {
            ClientModel.Player.Dispose();
            ClientModel.Recorder.Dispose();

            if (me.Code != ErrorCode.AudioNotEnabled)
              throw;
            else
            {
              var msg = Localizer.Instance.Localize(AudioInitializationFailedKey);
              MessageBox.Show(msg, ProgramName, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
              }

              var address = loopback
            ? Settings.Current.StateOfIPv6Protocol ? IPAddress.IPv6Loopback : IPAddress.Loopback
            : IPAddress.Parse(Settings.Current.Address);

              ClientModel.Client.Connect(new IPEndPoint(address, Settings.Current.Port));
        }
예제 #6
0
        public static void Init(ClientInitializer initializer)
        {
            var user = new User(initializer.Nick, initializer.NickColor);

              if (Interlocked.CompareExchange(ref model, new ClientModel(user), null) != null)
            throw new InvalidOperationException("model already inited");

              // API установится автоматически при подключении к серверу (согласно версии на сервере)
              Client = new AsyncClient(initializer.Nick);
              Peer = new AsyncPeer();
              Plugins = new ClientPluginManager(initializer.PluginsPath);
              Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }