public void Subscribe(IRemoteService subscriber) { SubscriberIsNotNull(subscriber); var relayLink = _channelFactory.CreateHttpChannel(subscriber); _dispatcherService.AddChannel(relayLink); }
public TorrentRunner(ISettings settings, ITorrents torrents, IDownloads downloads, IRemoteService remoteService) { _settings = settings; _torrents = torrents; _downloads = downloads; _remoteService = remoteService; }
public AreaInfo(IRemoteService svc) { this.service = svc; this.key = svc.Address.ServiceName; this.currentRoleCount = 0; this.currentZoneCount = 0; }
internal MainWindowViewModel( WorkingFolder workingFolder, WindowOwner owner, IRepositoryCommands repositoryCommands, IRemoteService remoteService, ICommitsService commitsService, ILatestVersionService latestVersionService, IStartInstanceService startInstanceService, IRecentReposService recentReposService, IGitInfoService gitInfoService, IMessage message, IMainWindowService mainWindowService, MainWindowIpcService mainWindowIpcService, RepositoryViewModel repositoryViewModel) { this.workingFolder = workingFolder; this.owner = owner; this.repositoryCommands = repositoryCommands; this.remoteService = remoteService; this.commitsService = commitsService; this.startInstanceService = startInstanceService; this.recentReposService = recentReposService; this.gitInfoService = gitInfoService; this.message = message; this.mainWindowService = mainWindowService; this.mainWindowIpcService = mainWindowIpcService; RepositoryViewModel = repositoryViewModel; workingFolder.OnChange += (s, e) => Notify(nameof(WorkingFolder)); latestVersionService.OnNewVersionAvailable += (s, e) => IsNewVersionVisible = true; latestVersionService.StartCheckForLatestVersion(); IsRepoView = true; }
protected override async Task OnStartAsync() { //创建异步锁(内存) this.coinLocker = Provider.CreateLock(); //获得消耗者 this.machine = await this.Provider.GetAsync(new RemoteAddress("Machine")); }
public LocalRegistScoreViewModel() { try { _tourService = Resolver.Resolve <ITourService>(); _commonFun = Resolver.Resolve <ICommonFun>(); _commonHelper = Resolver.Resolve <CommonHelper>(); _localScoreService = Resolver.Resolve <ILocalScoreService>(); _remoteService = Resolver.Resolve <IRemoteService>(); _tapCommand = new Command(ImageTaped); MessagingCenter.Subscribe <LocalRegistScorePage>(this, "CheckBoxChanged", (obj) => { if (CSList.Any(p => p.IsCheck == true)) { CurrentScore = "0"; CurrentSystem.Score = 0; } else { CurrentScore = "1"; CurrentSystem.Score = 1; } }); MessagingCenter.Subscribe <StandardPic>(this, "DeleteLossImage", (obj) => { //删除失分照片 DeleteImage(obj); }); MessagingCenter.Subscribe <PictureStandard>(this, "RegistScoreItemTapped", (obj) => { UploadStandPic(obj.StandardPicId); }); MessagingCenter.Subscribe <PictureStandard>(this, "PreviewPlanAttechment", (obj) => { if (!string.IsNullOrEmpty(obj.Url)) { PreviewStanderImage(obj.Url); } }); MessagingCenter.Subscribe <PictureStandard>(this, "DeletePlanAttechment", (obj) => { if (!string.IsNullOrEmpty(obj.Url)) { DeleteStanderImage(obj); } }); } catch (Exception) { _commonFun.AlertLongText("操作异常,请重试。-->CustImproveViewModel"); return; } }
internal async Task <bool> OnEnterAsync() { this.remote_session = await service.Provider.GetAsync(new RemoteAddress(enter.roleSessionName, enter.roleSessionNode)); this.remote_logic = await service.Provider.GetAsync(new RemoteAddress(enter.roleLogicName, enter.roleLogicNode)); return(remote_session != null && remote_logic != null); }
protected override async Task OnStartAsync() { this.area_manager = await this.Provider.GetAsync(ServerNames.AreaManager); this.sync_state_timer = this.Provider.CreateTimer(timer_SyncState, this, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(TimerConfig.timer_sec_AreaStateNotify)); }
public JsonPlaceholderRemoteService( IRemoteServiceFactory remoteServiceFactory, IHttpClientFactory httpClientFactory, ILogManager logManager) { _logger = logManager.GetLogger <JsonPlaceholderRemoteService>(); var httpClient = httpClientFactory.CreateClient(ApiUrl, _logger); _remoteService = remoteServiceFactory.Create <IPhotosApiService>(httpClient); }
public HttpChannel(IRemoteService subscriber) { _subscriber = subscriber; _queue = new Queue <Message>(); _backgroundWorker = new BackgroundWorker(); _backgroundWorker.DoWork += SendMessage; _backgroundWorker.RunWorkerCompleted += MessageRecived; _retryPolicy = Policy.Handle <HttpRequestException>() .OrResult <HttpStatusCode>(result => result != HttpStatusCode.Accepted && result != HttpStatusCode.OK) .WaitAndRetryForever(retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); }
public RemoteServiceTests() { var testException = new Exception("TEST EXCEPTION"); _apiService = Substitute.For <IStubApiInterface>(); _apiService.GetData(Arg.Any <CancellationToken>()).Returns(ResultData); _apiService.DoException().Throws(testException); _apiService.DoException(Arg.Any <CancellationToken>()).Throws(testException); _executorBuilder = new DefaultExecutorBuilderFactory(); _remoteService = new RemoteService <IStubApiInterface>(_apiService, _executorBuilder); }
public bool CheckHeartbeat(TimeSpan heartbeat_timeout) { if (DateTime.Now - last_heartbeat > heartbeat_timeout) { if (session != null) { session.ShutdownAsync("timeout"); session = null; return(true); } } return(false); }
public HttpBinRemoteService( IHttpClientFactory httpClientFactory, IRemoteServiceFactory remoteServiceFactory, ILogManager logManager) { var logger = logManager.GetLogger <HttpBinRemoteService>(); var httpClient = httpClientFactory.CreateClient(ApiUrl, logger); httpClient.Timeout = TimeSpan.FromSeconds(5); // custom timeout on http handler level _remoteService = remoteServiceFactory.Create <IHttpBinApiService>(httpClient); }
public DiffusionRC(string url, string controlTopic, string rootTopic) { theRemoteService = RemoteServiceFactory.CreateRemoteService(ConnectionFactory.CreateServerDetails(url),controlTopic,rootTopic); theRemoteService.Registered += Registered; theRemoteService.ClientConnected += clientConnected; theRemoteService.ClientDisconnected += clientDisconnected; theRemoteService.ClientSubscribe += clientSubscribe; theRemoteService.Closed += closed; theRemoteService.MessageFromClient += messageFromClient; theRemoteService.RegisterFailed += RegisterFailed; theRemoteService.TopicAddFailed += TopicAddFailed; theRemoteService.TopicSubscribeFailed += TopicSubscribeFailed; theRemoteService.Register(); }
/// <summary> /// Opens a remote service that remote programs can connect (subscribe) to. /// </summary> /// <param name="service"></param> public RemoteService(IRemoteService service, int port) { //Starting network-layer this.m_InternalService = service; this.m_Communicator = new TcpCommunicator <BoxedObject>("127.0.0.1", port) { DispatchMessageInEvent = true, }; this.m_Communicator.Open(); this.m_Communicator.MessageReceived += M_Communicator_MessageReceived; //Getting all methodinfos in the start this.m_ServiceMethods = service.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(mi => mi.IsSpecialName == false).ToArray(); }
public SslTestRemoteService( IRemoteServiceFactory remoteServiceFactory, ILogManager logManager, HttpMessageHandler customHttpMessageHandler) { _logger = logManager.GetLogger <SslTestRemoteService>(); var customHttpMessageHandlerBuilder = new DefaultHttpMessageHandlerBuilder(customHttpMessageHandler); var httpClientBuilder = new HttpClientBuilder(customHttpMessageHandlerBuilder).WithBaseUrl(ApiUrl) .WithLogger(_logger) .Build(); _remoteService = remoteServiceFactory.Create <ISslApiService>(httpClientBuilder); }
void Start() { iRemoteService = RemoteServiceBuilder.GetRemoteService(this, _serverIp); cameraPostion = Camera.main.transform.position; bodyPoints = new GameObject[1000]; for (int i = 0; i < bodyPoints.Length; i++) { bodyPoints[i] = Instantiate(refCube) as GameObject; bodyPoints[i].SetActive(false); bodyPoints[i].transform.parent = gameObject.transform; } var localScale = gameObject.transform.localScale; localScale = localScale.Div(new Vector3(22.5F, 22.5F, 22.5F)); gameObject.transform.localScale = localScale; }
/// <summary> /// Make a safe remote request with getting result and logging errors. /// Returns <see langword="null"/> when an exception was thrown during execution. /// </summary> /// <param name="remoteService">Instance of <see cref="IRemoteService{TApiService}"/>.</param> /// <param name="operation"> /// Delegate that encapsulates request operation (call the method from <see cref="TApiService"/>). /// </param> /// <param name="cancellationToken">Token for canceling the request.</param> /// <param name="logger">Instance of <see cref="ILogger"/> (optional).</param> /// <typeparam name="TApiService">The type of API service.</typeparam> /// <typeparam name="TResult">The type of request result.</typeparam> /// <returns>Task with result.</returns> public static async Task <TResult> SafeRequest <TApiService, TResult>( this IRemoteService <TApiService> remoteService, Func <TApiService, CancellationToken, Task <TResult> > operation, CancellationToken cancellationToken, ILogger?logger = null) { try { return(await remoteService.MakeRequest( operation, new RequestOptions { CancellationToken = cancellationToken })); } catch (Exception ex) { logger?.Error(ex); return(default !);
public AppController( IUnityContainer container, IEventAggregator eventAggregator, IRegionManager regionManager, IRemoteService remoteService, IDeployService deployService, IScreenshotService screenshotService) { _container = container; _eventAggregator = eventAggregator; _regionManager = regionManager; _remoteService = remoteService; _deployService = deployService; _screenshotService = screenshotService; _container = container; _injectStrings = new Dictionary <DebuggerCommandEnum, string>(); _injectStrings.Add(DebuggerCommandEnum.bt, "Backtrace: "); _injectStrings.Add(DebuggerCommandEnum.var, "Local Variables: "); _injectStrings.Add(DebuggerCommandEnum.list, "Current Function: "); }
public RemoteViewModel(IRemoteView view, IRemoteService remoteService) { _remoteService = remoteService; View = view; View.DataContext = this; SendCommand = new DelegateCommand <EventKey?>(cmd => { if (cmd.HasValue) { _remoteService.SendAsync(GetIp(), new EventModel(EventType.KeyPress, cmd.Value)); } }, cmd => Connected); BackspaceCommand = new DelegateCommand(() => { _remoteService.SendAsync(GetIp(), new EventModel(EventType.KeyPress, EventKey.Backspace)); }, () => Connected); Connected = true; }
public SingletonServer() { try { if (ServerStaticMembers.Observers == null) { ServerStaticMembers.Observers = new ArrayList(); } if (ServerStaticMembers.ConnectedClients == null) { ServerStaticMembers.ConnectedClients = new ObservableCollection<ConnectedClient>(); } _remoteService = new RemoteService(); Thread t = new Thread(ThreadProc); t.SetApartmentState(ApartmentState.STA); t.Start(); Thread.Sleep(5000); _dispatcher = _smw.Dispatcher; _worker = new BackgroundWorker(); _worker.WorkerSupportsCancellation = true; ServerStaticMembers.ServerModel = this; ServerStaticMembers.ServerView = _smw; ServerStaticMembers.ServerControl = new ServerControl(ServerStaticMembers.ServerModel, ServerStaticMembers.ServerView); ServerStaticMembers.ServerView.WireUp(ServerStaticMembers.ServerControl, ServerStaticMembers.ServerModel); ServerStaticMembers.Logger.Info("Remoting Server Initialized"); _isListening = true; // todo: use some encryption algorithm to encrypt the server address and decrypt in the client logic } catch (Exception ex) { _isListening = false; ServerStaticMembers.Logger.Error("Remoting Server Initialization failed - " + ex.Message, ex); } }
public SubscriberService(IRemoteService remoteService) { _remoteService = remoteService; }
public MoviesService(IRemoteService <IMovieItem> remoteDataService, ICacheService <IMovieItem> cacheService) { _remoteDataService = remoteDataService; _cacheService = cacheService; }
public TaskListViewModel() { try { _tourService = Resolver.Resolve<ITourService>(); _localScoreService = Resolver.Resolve<ILocalScoreService>(); _commonFun = Resolver.Resolve<ICommonFun>(); _commonHelper = Resolver.Resolve<CommonHelper>(); _remoteService = Resolver.Resolve<IRemoteService>(); MessagingCenter.Subscribe<TourDistributorDto>(this, "SendShopItem", (obj) => { _disId = obj.DisId; _isChecking = true; _statu = "N"; //if (_commonHelper.IsNetWorkConnected() == true) //{ // GetPlans(_disId, "", "", _statu); //} //else //{ GetLocalPlans(_disId); //} }); //MessagingCenter.Subscribe<TaskListPage>(this, "RefreshTask", (obj) => //{ // if (_disId != 0) // { // GetPlans(_disId); // } //}); MessagingCenter.Subscribe<TaskOfPlanDto>(this, "CheckTask", async (obj) => { if (_isChecking) { //if (_commonHelper.IsNetWorkConnected() == true) //{ // if (obj.TPStatus == "E") // { // if (obj.TPType == "C") // { // CheckCustomizedTask(obj.TPId, "A", obj.TPStatus); // } // else // { // CheckPlan(obj.TPId, "A"); // } // } // else // { // var action = await _commonFun.ShowActionSheet("开始检查", "结束检查"); // if (action == "开始检查") // { // if (obj.TPType == "C")// 自定义任务 // { // CheckCustomizedTask(obj.TPId, "S", obj.TPStatus); // } // else // { // CheckStartPlan(obj.TPId); // } // } // else if (action == "结束检查") // { // if (obj.TPType == "C")// 自定义任务 // { // CheckCustomizedTask(obj.TPId, "E", obj.TPStatus); // } // else // { // CheckEndPlan(obj.TPId); // } // } // } //} // 没有网络的状态下 if (obj.TPStatus == "E") { if (obj.TPType == "C") { //CheckCustomizedTask(obj.TPId, "A", obj.TPStatus); LocalCheckCustomizedTask(obj.TPId, "A", obj.TPStatus); } else { LocalCheckPlan(obj.TPId, "A"); } } else { var action = await _commonFun.ShowActionSheet("开始检查", "结束检查");//, "取消任务"); if (action == "开始检查") { if (obj.TPType == "C")// 自定义任务 { //CheckCustomizedTask(obj.TPId, "S", obj.TPStatus); LocalCheckCustomizedTask(obj.TPId, "S", obj.TPStatus); } else { LocalCheckStartPlan(obj.TPId); } } else if (action == "结束检查") { if (obj.TPType == "C")// 自定义任务 { //CheckCustomizedTask(obj.TPId, "E", obj.TPStatus); LocalCheckCustomizedTask(obj.TPId, "E", obj.TPStatus); } else { LocalCheckEndPlan(obj.TPId); } } else if (action == "取消任务") { if (await _commonFun.Confirm("确定取消该任务吗?")) { if (obj.TPType == "C")// 自定义任务 { LocalCheckCustomizedTask(obj.TPId, "C", obj.TPStatus); } else { LocalClosePlanTask(obj.TPId); } } } } } else { if (obj.TPType == "C") { CheckCustomizedTask(obj.TPId, "A", obj.TPStatus); } else { CheckPlan(obj.TPId, ""); } } }); MessagingCenter.Subscribe<string>(this, "SearchTaskList", (disId) => { _isChecking = true; _statu = "N"; GetLocalPlans(Convert.ToInt32(disId)); }); } catch (Exception) { _commonFun.AlertLongText("操作异常,请重试。-->TaskListViewModel"); return; } }
public void Setup() { _remoteService = A.Fake <IRemoteService>(); _httpChannel = new HttpChannel(_remoteService); _message = new Message(); }
public RemoteClient(IRemoteService remoteService) { this.remoteService = remoteService; }
public MoviesService() { _remoteDataService = DependencyService.Get <IRemoteService <IMovieItem> >(); _cacheService = DependencyService.Get <ICacheService <IMovieItem> >(); }
public Worker(IRemoteService remoteService, IOutputQueue outputQueue) { this.remoteService = remoteService; this.outputQueue = outputQueue; }
public void RegisterRemoteService(IRemoteService remoteService) { _remoteServices.Add(remoteService); }
/// <summary> /// 注册远程服务的实现,请确保<paramref name="implement"/>是线程访问安全的 /// </summary> /// <typeparam name="TRepository"></typeparam> /// <param name="repository"></param> public static void Register(IRemoteService implement) { _implementByRegister = implement; }
public IChannel CreateHttpChannel(IRemoteService subscriber) { return(new HttpChannel(subscriber)); }
public SessionInfo(IRemoteService session) { this.session = session; }
public IRemoteClient CreateRemoteClient(IRemoteService remoteService) { return(new RemoteClient(remoteService)); }