public RemotePresentationClient(IPresentationNotifier presentationNotifier,
            IClientConfiguration clientConfiguration, ISourceDAL sourceDAL, IDeviceSourceDAL deviceSourceDAL)
        {
            _sourceDAL = sourceDAL;
            _deviceSourceDAL = deviceSourceDAL;
            _presentationNotifier = presentationNotifier;
            _configuration = clientConfiguration;
            _presentationClient = new DuplexClient<IPresentationService>(new InstanceContext(presentationNotifier),
                clientConfiguration.PingInterval);
            _presentationClient.Open();
            _presentationClient.OnChanged += new EventHandler<ClientState>(_presentationClient_OnChanged);

            _deviceDescriptorCache = new DeviceDescriptorCache(presentationNotifier);
        }
Beispiel #2
0
 private DuplexClient<IDuplexServer, IDuplexCallback> ConnectDuplex(Int32 portOffset)
 {
     var client = new DuplexClient<IDuplexServer, IDuplexCallback>(
     new ClientCallback(),
     new CustomBinding(
        new ReliableSessionBindingElement(false)
        {
           MaxPendingChannels = 16384
        },
        new CompositeDuplexBindingElement()
        {
           ClientBaseAddress = new Uri(
              String.Format(
                 "udp://{0}:{1}/",
                 System.Net.Dns.GetHostName(),
                 43000 + portOffset
              )
           )
        },
        new WcfEx.Udp.BindingElement()
     ),
     DuplexClientUri
      );
      client.Open();
      return client;
 }
Beispiel #3
0
        public bool Authenticate(IUserCredential tool, string role)
        {
            if (IsStandAlone)
            {
                UserIdentity principal = new UserIdentity(UserInfo.Empty, true, new TimeSpan(0), "local");
                AppDomain.CurrentDomain.SetThreadPrincipal(principal);

                _userCollection.Add(principal);
            }
            else
            {
                if (_loginServiceClient == null)
                {
                    _callBack = new LoginServiceCallback(_userCollection);
                    _loginServiceClient = new DuplexClient<ILoginService>(new InstanceContext(_callBack), _configuration.PingInterval);
                    _loginServiceClient.Open();
                    _loginServiceClient.OnChanged += new EventHandler<ClientState>(_loginServiceClient_OnChanged);
                }
                string loginName, password;
            again: ;

                if (tool.GetUserCredential(out loginName, out password))
                {
                    byte[] hash = SecurityUtils.PasswordToHash(password);

                    UserIdentity principal = loginService.Login(loginName, hash, Environment.MachineName);
                    if (principal == null || !principal.IsAuthenticated)
                    {
                        tool.FailedLogin();
                        goto again;
                    }

                    if (role != null && !principal.IsInRole(role))
                    {
                        tool.FailedRole(role);
                        loginService.Logoff(principal);
                        goto again;
                    }

                    AppDomain.CurrentDomain.SetThreadPrincipal(principal);

                    loginService.Subscribe(principal);

                    _userCollection.AddRange(loginService.GetUserLoginCollection());
                }
                else
                {
                    return false;
                    //throw new ApplicationException("User cancel");
                }
            }
            return true;
        }
Beispiel #4
0
        public bool Authenticate(UserIdentity previousId)
        {
            if (_loginServiceClient == null)
            {
                _callBack = new LoginServiceCallback(_userCollection);
                _loginServiceClient = new DuplexClient<ILoginService>(new InstanceContext(_callBack), _configuration.PingInterval);
                _loginServiceClient.Open();
                _loginServiceClient.OnChanged += new EventHandler<ClientState>(_loginServiceClient_OnChanged);
            }

            UserIdentity principal = loginService.Login(previousId.User.Name, previousId.User.Hash, Environment.MachineName);
            if (principal == null || !principal.IsAuthenticated)
            {
                return false;
            }

            AppDomain.CurrentDomain.SetThreadPrincipal(principal);

            loginService.Subscribe(principal);

            _userCollection.AddRange(loginService.GetUserLoginCollection());
            return true;
        }
Beispiel #5
0
        public static void Initialize(bool skipServer = false)
        {
            uint desktopPID;

            PInvoke.GetWindowThreadProcessId(WindowUtils.GetShellTrayWnd(), out desktopPID);
            isServer = desktopPID == PInvoke.GetCurrentProcessId();

            const string PipeName = "QTTabBarPipe";
            string       address  = "net.pipe://localhost/" + PipeName + desktopPID;
            Thread       thread   = null;

            // WFC channels should never be opened on any thread that has a message loop!
            // Otherwise reentrant calls will deadlock, for some reason.
            // So, create a new thread and open the channels there.
            thread = new Thread(() => {
                if (isServer && !skipServer)
                {
                    serviceHost = new ServiceHost(
                        typeof(CommService),
                        new Uri[] { new Uri(address) });
                    serviceHost.AddServiceEndpoint(
                        typeof(ICommService),
                        new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
                    {
                        ReceiveTimeout         = TimeSpan.MaxValue,
                        ReaderQuotas           = { MaxArrayLength = int.MaxValue },
                        MaxBufferSize          = int.MaxValue,
                        MaxReceivedMessageSize = int.MaxValue,
                    },
                        new Uri(address));
                    serviceHost.Open();
                }


                commClient = new DuplexClient(new InstanceContext(new CommClient()),
                                              new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
                {
                    ReceiveTimeout         = TimeSpan.MaxValue,
                    ReaderQuotas           = { MaxArrayLength = int.MaxValue },
                    MaxBufferSize          = int.MaxValue,
                    MaxReceivedMessageSize = int.MaxValue,
                },
                                              new EndpointAddress(address));
                try {
                    commClient.Open();
                    commClient.Channel.Subscribe();
                    using (new Keychain(rwLockTabBar, false)) {
                        foreach (IntPtr handle in sdTabHandles.Keys)
                        {
                            commClient.Channel.PushInstance(handle);
                        }
                    }
                }
                catch (EndpointNotFoundException) {
                }
                lock (thread) {
                    Monitor.Pulse(thread);
                }
                // Yes, we can just let the thread die here.
            });
            thread.Start();
            lock (thread) {
                Monitor.Wait(thread);
            }
        }
Beispiel #6
0
 //!! Метод Вызывается из Дизайнера!!
 public void InitializeFromDisigner(IClientConfiguration configuration)
 {
     try
     {
         _configuration = configuration;
         _showNotifier = new ShowNotifier(_configuration);
         _showNotifier.OnPreparationFinished += _showNotifier_OnPreparationFinished;
         _showNotifier.OnProgressChanged += _showNotifier_OnProgressChanged;
         _showNotifier.OnEquipmentStateChanged += _showNotifier_OnEquipmentStateChanged;
         _showNotifier.OnNotEnoughSpace += _showNotifier_OnNotEnoughSpace;
         _showNotifier.OnShownStatusChanged += (_showNotifier_OnShownStatusChanged);
         _showNotifier.OnReceiveAgentResourcesList += _showNotifier_OnReceiveAgentResourcesList;
         _showNotifier.OnUploadSpeed += new Action<double, string, string>(_showNotifier_OnUploadSpeed);
         _showNotifier.OnPreparationForDisplayEnded += new Action<string, bool>(_showNotifier_OnPreparationForDisplayEnded);
         _showNotifier.OnLogMessage+=new Action<string>(_showNotifier_OnLogMessage);
         _svc = new DuplexClient<IShowCommon>(new InstanceContext(_showNotifier), _pingInterval);
         _svc.Open();
         _created = true;
     }
     catch (CommunicationException)
     {
         _svc.Dispose();
         _svc = null;
         _created = false;
     }
 }
Beispiel #7
0
 public bool InitializeFromPlayer(IPlayerConfiguration configuration)
 {
     _configuration = configuration;
     _showNotifier = new ShowNotifier(_configuration);
     _showNotifier.OnPreparationFinished += _showNotifier_OnPreparationFinished;
     _showNotifier.OnProgressChanged += _showNotifier_OnProgressChanged;
     _showNotifier.OnReceiveAgentResourcesList += _showNotifier_OnReceiveAgentResourcesList;
     _showNotifier.OnUploadSpeed +=new Action<double,string, string>(_showNotifier_OnUploadSpeed);
     _showNotifier.OnPreparationForDisplayEnded += new Action<string, bool>(_showNotifier_OnPreparationForDisplayEnded);
     _showNotifier.OnEquipmentStateChanged += _showNotifier_OnEquipmentStateChanged;
     _showNotifier.OnNotEnoughSpace += _showNotifier_OnNotEnoughSpace;
     _showNotifier.OnLogMessage += new Action<string>(_showNotifier_OnLogMessage);
     _showNotifier.OnExternalSystemCommand += _showNotifier_OnExternalSystemCommand;
     _svc = new DuplexClient<IShowCommon>(new InstanceContext(_showNotifier), configuration.PingInterval);
     try
     {
         _svc.Open();
     }
     catch (Exception /*ex*/)
     {
         _svc.Dispose();
         _svc = null;
         return false;
     }
     return true;
 }