예제 #1
0
 public static bool Interpret(int clientId, IMessage message, IServerService service)
 {
     switch (message.Header)
       {
     case MessageHeaders.LOGIN:
       MessageHelper.ResolveMessage(message, reader => service.Login(clientId, reader.ReadString()));
       break;
     case MessageHeaders.COMPLETELOGIN:
       MessageHelper.ResolveMessage(message, reader => service.CompleteLogin(clientId, reader.ReadAvatar()));
       break;
     case MessageHeaders.SEND_MESSAGE:
       MessageHelper.ResolveMessage(message, reader =>
     service.SendMessage(clientId, reader.ReadArray((Func<int>)reader.ReadUserId), reader.ReadString()));
       break;
     case MessageHeaders.BROADCAST:
       MessageHelper.ResolveMessage(message, reader =>
     service.BroadcastMessage(clientId, reader.ReadString()));
       break;
     case MessageHeaders.LOGOUT:
       service.Logout(clientId);
       break;
     case MessageHeaders.CHANGE_STATE:
       MessageHelper.ResolveMessage(message, reader => service.ChangeState(clientId, reader.ReadUserState()));
       break;
     case MessageHeaders.CHANGE_INFO:
       MessageHelper.ResolveMessage(message, reader =>
     service.ChangeInfo(clientId, reader.ReadUserState(), reader.ReadString()));
       break;
     default:
       return false;
       }
       return true;
 }
예제 #2
0
 public TorznabController(IIndexerManagerService i, Logger l, IServerService s, ICacheService c)
 {
     indexerService = i;
     logger = l;
     serverService = s;
     cacheService = c;
 }
예제 #3
0
파일: HomeService.cs 프로젝트: sap-sh/t
 public HomeService(IMaintenanceService maintenanceService,
 ISystemUpdateService systemUpdateService, IServerService serverService)
 {
     _systemUpdateService = systemUpdateService;
     _maintenanceService = maintenanceService;
     _serverService = serverService;
 }
예제 #4
0
 public PotatoController(IIndexerManagerService i, Logger l, IServerService s, ICacheService c, IWebClient w)
 {
     indexerService = i;
     logger = l;
     serverService = s;
     cacheService = c;
     webClient = w;
 }
예제 #5
0
파일: HomeController.cs 프로젝트: sap-sh/t
 public HomeController(IMaintenanceService maintenanceService, ISystemUpdateService systemUpdateService, IServerService serverService, IServerDetailService serverDetailService, IHomeService homeService)
 {
     _maintenanceService = maintenanceService;
     _serverService = serverService;
     _serverDetailService = serverDetailService;
     _systemUpdateService = systemUpdateService;
     _homeService = homeService;
 }
예제 #6
0
 public AdminController(IConfigurationService config, IIndexerManagerService i, IServerService ss, ISecuityService s, IProcessService p, ICacheService c)
 {
     this.config = config;
     indexerService = i;
     serverService = ss;
     securityService = s;
     processService = p;
     cacheService = c;
 }
예제 #7
0
        /// <summary>
        /// Recupera o serviço do tipo informado.
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="creator"></param>
        /// <returns></returns>
        public IServerService GetService(Type serviceType, Func <IServerService> creator)
        {
            IServerService service = null;

            lock (_serviceAccessLock)
                _managedServices.TryGetValue(serviceType, out service);
            if (service == null)
            {
                object obj2 = null;
                lock (_serviceAccessLock)
                {
                    if (!_loadingServices.TryGetValue(serviceType, out obj2))
                    {
                        obj2 = new object();
                        _loadingServices[serviceType] = obj2;
                    }
                }
                lock (obj2)
                {
                    lock (_serviceAccessLock)
                    {
                        _managedServices.TryGetValue(serviceType, out service);
                    }
                    if (service == null)
                    {
                        try
                        {
                            try
                            {
                                service = creator();
                            }
                            catch (MissingMethodException exception)
                            {
                                throw new ArgumentException(ResourceMessageFormatter.Create(() => Properties.Resources.GetServiceArgumentError, serviceType).Format(), exception);
                            }
                            service.Initialize(_logger);
                            service.ServiceStart();
                            lock (_serviceAccessLock)
                            {
                                _managedServices.Add(serviceType, service);
                                _loadingServices.Remove(serviceType);
                            }
                        }
                        catch (Exception)
                        {
                            DisposeService(ref service);
                            throw;
                        }
                    }
                }
            }
            return(service);
        }
예제 #8
0
 public NoteModule(INoteRepository noteRepository,
                   ILogger <NoteModule> logger,
                   IUserService userService,
                   ISettings settings,
                   IServerService serverService)
 {
     _noteRepository = noteRepository;
     _logger         = logger;
     _userService    = userService;
     _settings       = settings;
     _serverService  = serverService;
 }
예제 #9
0
 //Set up constructor injection
 public DeploymentScheduleController(IServerService serverService, IEventLoggerService eventLoggerService, IDeploymentScheduleListService deploymentScheduleListService, IServerApplicationService serverApplicationService, IServerDeploymentStatusService serverDeploymentStatusService, IServerDetailService serverDetailService, IDeploymentService deploymentService, IDeploymentScheduleService deploymentScheduleService, IRnowService rnowService)
 {
     _serverService = serverService;
     _eventLoggerService = eventLoggerService;
     _deploymentScheduleListService = deploymentScheduleListService;
     _serverApplicationService = serverApplicationService;
     _serverDeploymentStatusService = serverDeploymentStatusService;
     _serverDetailService = serverDetailService;
     _deploymentService = deploymentService;
     _deploymentScheduleService = deploymentScheduleService;
     _rnowService = rnowService;
 }
예제 #10
0
 public AdminController(IConfigurationService config, IIndexerManagerService i, IServerService ss, ISecuityService s, IProcessService p, ICacheService c, Logger l, ILogCacheService lc, IUpdateService u)
 {
     this.config     = config;
     indexerService  = i;
     serverService   = ss;
     securityService = s;
     processService  = p;
     cacheService    = c;
     logger          = l;
     logCache        = lc;
     updater         = u;
 }
예제 #11
0
        public PaperPool()
        {
            InitializeComponent();
            finishPaperButton.Enabled = false;
            //updateButton.Enabled = false;

            saveAndNextButton.Enabled = false;
            cancelPaperButton.Enabled = false;
            channelFactory            = new ChannelFactory <IServerService>("AdmissionSystemEndPoint");
            api = channelFactory.CreateChannel();
            populateComboBox();
        }
예제 #12
0
 public ServerConfigurationController(IConfigurationService c, IServerService s, IProcessService p, IIndexerManagerService i, ISecuityService ss, IUpdateService u, ILogCacheService lc, Logger l, ServerConfig sc)
 {
     configService   = c;
     serverConfig    = sc;
     serverService   = s;
     processService  = p;
     indexerService  = i;
     securityService = ss;
     updater         = u;
     logCache        = lc;
     logger          = l;
 }
예제 #13
0
 public AdminController(IConfigurationService config, IIndexerManagerService i, IServerService ss, ISecuityService s, IProcessService p, ICacheService c, Logger l, ILogCacheService lc, IUpdateService u)
 {
     this.config = config;
     indexerService = i;
     serverService = ss;
     securityService = s;
     processService = p;
     cacheService = c;
     logger = l;
     logCache = lc;
     updater = u;
 }
예제 #14
0
        // ----- Primary methods for Replicas -----
        public void RegisterReplica(IServerService replica, String id)
        {
            CheckFreeze();
            lock (_replicas) {
                foreach (IServerService rep in _replicas.Values)   // update replicas of new replicas
                {
                    rep.AddReplica(replica, id);
                }

                _replicas[id] = replica;
            }
        }
예제 #15
0
 public ServerCommandHandler(IBusClient busClient,
                             IServerService serverService,
                             IDatabaseService databaseService,
                             IMapper mapper,
                             ILogger <ServerCommandHandler> logger)
 {
     _busClient       = busClient;
     _serverService   = serverService;
     _databaseService = databaseService;
     _mapper          = mapper;
     _logger          = logger;
 }
예제 #16
0
 public OriginalDocSearchingController(IOriginalDocSearchingService originalDocSearchingService,
                                       IMultiDocScanService multiDocScanService,
                                       IOwnerProperIdentityService ownerProperIdentityRepository,
                                       IDocPropertyService docPropertyService, IServerService serverService)
 {
     _originalDocSearchingService = originalDocSearchingService;
     _multiDocScanService         = multiDocScanService;
     _ownerProperIdentityService  = ownerProperIdentityRepository;
     _docPropertyService          = docPropertyService;
     _serverService = serverService;
     UserID         = SILAuthorization.GetUserID();
 }
예제 #17
0
        public ServerStatisticService(IStatisticRepository <BaseServerStatistics> repository, IServerService serverService)
        {
            _repository    = repository;
            _serverService = serverService;

            cache = new ConcurrentDictionary <string, BaseServerStatistics>();

            foreach (BaseServerStatistics stats in _repository.GetAll())
            {
                var trimStat = stats.Trim();
                cache.TryAdd(trimStat.EndPoint, trimStat);
            }
        }
예제 #18
0
        private void Unfreeze(string command)
        {
            string[] args = command.Split(' ');
            if (args.Count() != 2)
            {
                throw new Exception("Wrong format for Unfreeze command");
            }
            string serverURL = name2URL[args[1]];

            IServerService sever = (IServerService)Activator.GetObject(typeof(IServerService), serverURL);

            sever.Unfreeze(args[1]);
        }
예제 #19
0
        public JoystickViewModel(IServerService server)
        {
            StartCommand = new Command(() => StartListening());
            StopCommand  = new Command(() => StopListening());
            _server      = server;
            IsListening  = false;

            UpColor     = Color.LightGray;
            LeftColor   = Color.LightGray;
            MiddleColor = Color.LightGray;
            RightColor  = Color.LightGray;
            DownColor   = Color.LightGray;
        }
예제 #20
0
 public RoomController(ILiveClassService liveClass
                       , IUserService _userService
                       , IServerService _serverService
                       , IAnchorService _anchorService
                       , IFollowService _followService
                       )
 {
     _liveClass          = liveClass;
     this._userService   = _userService;
     this._serverService = _serverService;
     this._anchorService = _anchorService;
     this._followService = _followService;
 }
예제 #21
0
 internal static void InvokeServerService(Action <IServerService> action)
 {
     try
     {
         using (ChannelFactory <IServerService> channelFactory = new ChannelFactory <IServerService>(UdpBinding, new EndpointAddress(_serverUdpUri)))
         {
             IServerService service = channelFactory.CreateChannel();
             action(service);
         }
     }
     catch//异常暂不处理
     { }
 }
예제 #22
0
 public WelcomeModule(IServerService servers,
                      ILogger <WelcomeModule> logger,
                      IServerRepository serverRepository,
                      IWelcomeMessageRepository welcomeMessageRepository,
                      IPartMessageRepository partMessageRepository,
                      ISettings settings)
 {
     _servers                  = servers;
     _logger                   = logger;
     _serverRepository         = serverRepository;
     _welcomeMessageRepository = welcomeMessageRepository;
     _partMessageRepository    = partMessageRepository;
     _settings                 = settings;
 }
예제 #23
0
        public CommandHandler(DiscordSocketClient client,
                              CommandService commands,
                              ISettings settings,
                              IServiceProvider serviceProvider,
                              ILogger <CommandHandler> logger,
                              IServerService servers,
                              BannerImageService bannerImageService,
                              IAutoRoleService autoRoleService,
                              IProfanityRepository profanityRepository,
                              IApiService apiService,
                              IWelcomeMessageRepository welcomeMessageRepository,
                              IPartMessageRepository partMessageRepository,
                              IUserRepository userRepository,
                              IInviteRepository inviteRepository,
                              IServerInviteRepository serverInviteRepository,
                              IServerRepository serverRepository)
        {
            _client                   = client;
            _commands                 = commands;
            _settings                 = settings;
            _serviceProvider          = serviceProvider;
            _logger                   = logger;
            _servers                  = servers;
            _bannerImageService       = bannerImageService;
            _autoRoleService          = autoRoleService;
            _profanityRepository      = profanityRepository;
            _apiService               = apiService;
            _welcomeMessageRepository = welcomeMessageRepository;
            _partMessageRepository    = partMessageRepository;
            _userRepository           = userRepository;
            _inviteRepository         = inviteRepository;
            _serverInviteRepository   = serverInviteRepository;
            _serverRepository         = serverRepository;

            _client.MessageReceived += OnMessageReceived;
            _client.UserJoined      += OnUserJoined;
            _client.ReactionAdded   += OnReactionAdded;
            _client.MessageUpdated  += OnMessageUpated;
            _client.UserLeft        += OnUserLeft;
            _client.JoinedGuild     += OnJoinedGuild;
            _client.Ready           += OnReady;
            _client.InviteCreated   += OnInviteCreated;

            _commands.CommandExecuted += OnCommandExecuted;

            ProfanityHelper.ProfanityRepository = profanityRepository;

            Task.Run(async() => await MuteHandler.MuteWorker(client));
            Task.Run(async() => await PomodoroHandler.PomodoroWorker(client));
        }
예제 #24
0
        public void Initialize()
        {
            var serverInfo = new ServerInfo("TestServer", new[] { "TestModeA", "TestModeB" });
            var server     = new Domain.Server("192.168.0.1-80", serverInfo);

            _serverRepository    = A.Fake <IServerService>();
            _matchRepository     = A.Fake <IService <Match> >();
            _statisticController = A.Fake <IStatisticController>();

            _controller = new MatchController(_matchRepository, _serverRepository, _statisticController);

            A.CallTo(() => _serverRepository.Get("192.168.0.1-80")).Returns(server);
            A.CallTo(() => _serverRepository.Get("192.168.0.2-80")).Throws(() => new NullReferenceException());
        }
예제 #25
0
 private static void ResolveDependencies()
 {
     _leagueInfo       = Container.Resolve <IGetLeagueInfo>();
     _connection       = Container.Resolve <IConnection>();
     _summoner         = Container.Resolve <IGetSummoner>();
     _masters          = Container.Resolve <IGetMasters>();
     _leagueOfSummoner = Container.Resolve <IGetLeagueOfSummonerInformation>();
     _serverService    = Container.Resolve <IServerService>();
     _summonerGame     = Container.Resolve <IGetSummonerGame>();
     _spectator        = Container.Resolve <ISpectator>();
     _lastGames        = Container.Resolve <IGetLastGames>();
     _printMethods     = Container.Resolve <IPrintMethods>();
     _dateHandler      = Container.Resolve <IDateHandler>();
 }
예제 #26
0
 public void Unfreeze(string id)
 {
     Console.WriteLine("Unfreezing " + id);
     if (serverUrl.ContainsKey(id))
     {
         IServerService i = (IServerService)Activator.GetObject(typeof(IServerService), serverUrl[id]);
         i.Unfreeze();
     }
     else if (clientUrl.ContainsKey(id))
     {
         IClientService i = (IClientService)Activator.GetObject(typeof(IClientService), clientUrl[id]);
         i.Unfreeze();
     }
 }
예제 #27
0
 public WarningModule(ILogger <WarningModule> logger,
                      IUserRepository userRepository,
                      IServerRepository serverRepository,
                      IWarningRepository warningRepository,
                      DiscordSocketClient client,
                      IServerService servers)
 {
     _logger            = logger;
     _userRepository    = userRepository;
     _serverRepository  = serverRepository;
     _warningRepository = warningRepository;
     _client            = client;
     _servers           = servers;
 }
예제 #28
0
        /// <summary>
        /// Initializes a new instance of the DispatchedServerService class
        /// </summary>
        /// <param name="wrappedService">the wrapped service</param>
        /// <param name="dispatcher">the thread dispatcher</param>
        public DispatchedServerService(IServerService wrappedService, Dispatcher dispatcher)
            : base(dispatcher)
        {
            if (wrappedService == null)
            {
                throw new ArgumentNullException("wrappedService");
            }

            this.wrappedService = wrappedService;

            this.wrappedService.GetMethodTableCompleted += (s, e) => this.DispatchEvent(this.GetMethodTableCompleted, s, e);
            this.wrappedService.GetServerEpochCompleted += (s, e) => this.DispatchEvent(this.GetServerEpochCompleted, s, e);
            this.wrappedService.PingCompleted += (s, e) => this.DispatchEvent(this.PingCompleted, s, e);
        }
예제 #29
0
 public InviteModule(IInviteRepository inviteRepository,
                     ILogger <InviteModule> logger,
                     IUserRepository userRepository,
                     IServerRepository serverRepository,
                     IServerService serverService,
                     CommandHandler commandHandler)
 {
     _inviteRepository = inviteRepository;
     _logger           = logger;
     _userRepository   = userRepository;
     _serverRepository = serverRepository;
     _serverService    = serverService;
     _commandHandler   = commandHandler;
 }
예제 #30
0
 public GeneralModule(ILogger <GeneralModule> logger,
                      DiscordSocketClient client,
                      BannerImageService bannerImageService,
                      IServerService servers,
                      IUserTimeZonesRepository userTimeZones,
                      ISettings settings)
 {
     _logger             = logger;
     _client             = client;
     _bannerImageService = bannerImageService;
     _servers            = servers;
     _userTimeZones      = userTimeZones;
     _settings           = settings;
 }
예제 #31
0
        // TODO: Detect when WCF sends a closed signal
        public IServerService Connect(IClientCallback clientCallback)
        {
            InstanceContext context = new InstanceContext(clientCallback);

            DuplexChannelFactory <IServerService> channelFactory = new DuplexChannelFactory <IServerService>(context, new NetNamedPipeBinding(), new EndpointAddress(ConnectionConstants.EndpointFullAddress));

            channelFactory.Closed  += (sender, args) => ConnectionClosed?.Invoke(this, EventArgs.Empty);
            channelFactory.Faulted += (sender, args) => ConnectionFaulted?.Invoke(this, EventArgs.Empty);

            IServerService service = channelFactory.CreateChannel();

            service.Connect();
            return(service);
        }
예제 #32
0
        public LedViewModel(IDataServiceProvider dataService, IServerService server)
        {
            _ledMatrix   = dataService.GetLedMatrix();
            _server      = server;
            LedGrid      = LedGridInitialzation();
            CurrentColor = SetDefaultColor();
            RBrush       = DefaultParams.defaultLedColor[0].ToString();
            GBrush       = DefaultParams.defaultLedColor[1].ToString();
            BBrush       = DefaultParams.defaultLedColor[2].ToString();
            Debug.WriteLine("Im Created LVM"); //DEBUG


            DefaultCommand = new Command(() => ResetToDefault());
            SendCommand    = new Command(() => SendData());
        }
예제 #33
0
 public void Freeze(string id)
 {
     Console.WriteLine("Freezing " + id);
     if (serverUrl.ContainsKey(id))
     {
         IServerService i = (IServerService)Activator.GetObject(typeof(IServerService), serverUrl[id]);
         i.Freeze();
     }
     else if (clientUrl.ContainsKey(id))
     {
         IClientService i = (IClientService)Activator.GetObject(typeof(IClientService), clientUrl[id]);
         i.Freeze();
     }
     Console.WriteLine(id.ToString() + " frozen");
 }
예제 #34
0
 public override void startClock(int term, string url)
 {
     //Console.WriteLine("Started clock on Follower");
     //quando vem de candidato
     Console.WriteLine("UPDATE TERM IN START");
     if (term > _term)
     {
         _term = term;
     }
     SetTimer();
     //electionTimeout.Interval = wait;
     //electionTimeout.Enabled = true;
     _leaderUrl    = url;
     _leaderRemote = _serverRemoteObjects[url];
 }
예제 #35
0
 public MetricsProcessingService(
     IBusClient busClient,
     IServerService serverService,
     IDatabaseService databaseService,
     IDatabaseBackupMetricsService databaseBackupMetricsService,
     IDatabaseSpaceMetricsService databaseSpaceMetricsService,
     IMemoryUsageMetricsService memoryUsageMetricsService
     )
 {
     _busClient       = busClient;
     _serverService   = serverService;
     _databaseService = databaseService;
     _databaseBackupMetricsService = databaseBackupMetricsService;
     _databaseSpaceMetricsService  = databaseSpaceMetricsService;
     _memoryUsageMetricsService    = memoryUsageMetricsService;
 }
예제 #36
0
        public Window1(IServerService serverChannel, Guid userId, string username, ServerProxy serverProxy, ClientService clientService)
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            this._serverChannel   = serverChannel;
            this._userId          = userId;
            this._username        = username;
            this._serverProxy     = serverProxy;
            this._clientService   = clientService;

            _clientService.ConnectedClientsListUpdatedEvent += UpdateListOfConnectedClients;
            _clientService.NewMessageReceivedEvent          += DisplayNewMessage;

            clientsListBox.SelectionChanged += OnClientSelect;
            Closed += OnClosed;
        }
예제 #37
0
 public OwnerModule(DiscordSocketClient client,
                    ISettings settings,
                    ILogger <OwnerModule> logger,
                    IDiscordBotSettingsRepository discordBotSettingsRepository,
                    LavaNode lavaNode,
                    IServerService servers,
                    IServerRepository serverRepository)
 {
     _client   = client;
     _settings = settings;
     _logger   = logger;
     _discordBotSettingsRepository = discordBotSettingsRepository;
     _lavaNode         = lavaNode;
     _servers          = servers;
     _serverRepository = serverRepository;
 }
예제 #38
0
 /// <summary>
 /// Executes any necessary start up code for the hub.
 ///
 /// Exceptions:
 ///     ArgumentNullException: When any parameter is null.
 /// </summary>
 public ChatHub(
     ILogger <ChatHub> logger,
     IUserService userService,
     IServerService serverService,
     IPrivateGroupMessagingService privateGroupMessagingService,
     IChannelsService channelsService,
     IDirectMessagingService directMessagingService
     )
 {
     _logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     _userService   = userService ?? throw new ArgumentNullException(nameof(userService));
     _serverService = serverService ?? throw new ArgumentNullException(nameof(serverService));
     _privateGroupMessagingService = privateGroupMessagingService ?? throw new ArgumentNullException(nameof(privateGroupMessagingService));
     _channelsService        = channelsService ?? throw new ArgumentNullException(nameof(channelsService));
     _directMessagingService = directMessagingService ?? throw new ArgumentNullException(nameof(directMessagingService));
 }
예제 #39
0
        public MatchService(IMatchRepository matchRepository, IServerService serverService)
        {
            this.matchRepository = matchRepository;
            this.serverService   = serverService;
            cache = new ConcurrentBag <Match>();

            foreach (Match match in matchRepository.GetAll())
            {
                cache.Add(match);
                if (cache.Count > 1000)
                {
                    cache = new ConcurrentBag <Match>(cache.OrderByDescending(m => m.Timestamp).Take(50));
                }
            }

            _timer = new Timer(UpdateCache, null, 30000, 30000);
        }
예제 #40
0
 public BotServices(ILoggingService loggingService,
     IEventService eventService,
     ITickerService tickerService,
     IDefenceService defenceService, 
     INewsService newsService,
     IKarmaService karmaService,
     IReplyService replyService,
     IStatsService statsService,
     IServerService serverService,
     IUrlService urlService,
     IJobService jobs)
 {
     Logging = loggingService;
     Events = eventService;
     Ticker = tickerService;
     Defence = defenceService;
     News = newsService;
     Karma = karmaService;
     AI = replyService;
     Stats = statsService;
     Server = serverService;
     Tools = urlService;
     Jobs = jobs;
 }
예제 #41
0
 public SecuityService(IServerService ss)
 {
     serverService = ss;
 }
예제 #42
0
 public BlackholeController(IIndexerManagerService i, Logger l, IServerService s)
 {
     logger = l;
     indexerService = i;
     serverService = s;
 }
        public PreferenceWindow()
        {
            InitializeComponent();

            ServerService = (IServerService) Windsor.Instance.GetValue(typeof(IServerService));
        }
        /// <summary>
        /// Closes the specified trigger disconnect event.
        /// </summary>
        /// <param name="triggerDisconnectEvent">if set to <c>true</c> trigger the disconnect event.</param>
        protected virtual void Close(bool triggerDisconnectEvent)
        {
            if (_socket == null)
                return;

            try
            {
                //_socket.Shutdown(SocketShutdown.Send);
                _socket.Disconnect(true);
                _socket.Close();
            }
            catch (Exception err)
            {
                // Do not care
                Console.WriteLine(err.ToString());
            }
            _socket = null;

            if (_client == null)
                return;

            _client.Dispose();
            _client = null;
            _writer.Reset();

            if (triggerDisconnectEvent)
            {
                OnDisconnect(SocketError.Success);
            }
        }
        /// <summary>
        /// Assign a new socket &amp; client to this context.
        /// </summary>
        /// <param name="socket">Socket that connected</param>
        /// <param name="client">Your own class dealing with this particular client.</param>
        public void Assign(Socket socket, IServerService client)
        {
            if (socket == null) throw new ArgumentNullException("socket");
            if (client == null) throw new ArgumentNullException("client");
            _socket = socket;
            _client = client;
            _client.Assign(this);
            _writer.Assign(socket);

            var willRaiseEvent = _socket.ReceiveAsync(_readArgs);
            if (!willRaiseEvent)
                OnReadCompleted(_socket, _readArgs);
        }
 public CertifyIMAPServerCommand(IServerService serverService)
 {
     _serverService = serverService;
 }
        /// <summary>
        /// The connect.
        /// </summary>
        public void Connect()
        {
            string port = this.userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);

            if (backgroundProcess == null)
            {
                ProcessStartInfo processStartInfo = new ProcessStartInfo(
                    "HandBrake.Server.exe", port)
                {
                    UseShellExecute = false,
                    CreateNoWindow = true,
                    RedirectStandardOutput = true,
                };

                backgroundProcess = new Process { StartInfo = processStartInfo };
                backgroundProcess.Start();
            }

            // When the process writes out a line, it's pipe server is ready and can be contacted for
            // work. Reading line blocks until this happens.
            backgroundProcess.StandardOutput.ReadLine();

            ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        pipeFactory = new DuplexChannelFactory<IServerService>(
                            new InstanceContext(this),
                            new NetTcpBinding(),
                            new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));

                        // Connect and Subscribe to the Server
                        Service = pipeFactory.CreateChannel();
                        Service.Subscribe();
                        IsConnected = true;
                    }
                    catch (Exception exc)
                    {
                        Caliburn.Micro.Execute.OnUIThread(() => this.errorService.ShowError("Unable to connect to background worker service", "Please restart HandBrake", exc));
                    }
                });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ClientConnected" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 public ClientConnected(IServerService client)
 {
     if (client == null) throw new ArgumentNullException("client");
     Client = client;
 }
예제 #49
0
 public DownloadController(IIndexerManagerService i, Logger l, IServerService s)
 {
     logger = l;
     indexerService = i;
     serverService = s;
 }