Пример #1
0
        protected async Task LogoutAsync()
        {
            await HubConnectionManager.CloseConnectionAsync();

            HasToken = false;
            StateHasChanged();
        }
Пример #2
0
 protected async Task LoginAsync()
 {
     var connection = await HubConnectionManager.ConnectAsync(Username, Password);
     HasToken = true;
     DownloadManager.SetConnection(connection);
     StateHasChanged();
 }
Пример #3
0
        static void Main(string[] args)
        {
            string CLIENT_HUB  = "ClientHub";
            string WORKING_URL = "http://localhost:6790";

            _manager = HubConnectionManager.GetHubConnectionManager(WORKING_URL);

            Console.WriteLine("Attmepting to connect to SignalR endpoint...");

            IHubProxy hubProxy = _manager.CreateHubProxy(CLIENT_HUB);

            SetupNotifications(_manager);
            _manager.Initialize().ContinueWith(task => Console.WriteLine(task.IsFaulted ? "There was an error opening the connection." : "Connected.")).Wait();

            while (true)
            {
                if (_manager.State == ConnectionState.Connected)
                {
                    try
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(hubProxy.Invoke <string>("Greetings", "User").Result);
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Connected via " + _manager.ConnectionType.Name);
                    }
                    catch
                    { }
                }

                //Chill
                Thread.Sleep(5000);
            }
        }
Пример #4
0
 public IActionResult ReadWithdrawal(string contractAddress)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 Withdrawal withdrawal = PensionFundsServices.ReadWithdrawal(contractAddress);
                 if (withdrawal == null || withdrawal.Completed)
                 {
                     hubContext.Clients.Client(ConnectionId).withdrawalCompleted(Json(withdrawal).Value);
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).withdrawalUncompleted(Json(withdrawal).Value);
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(3), ex, string.Format("Erro on ReadWithdrawal {0}.", contractAddress));
                 hubContext.Clients.Client(ConnectionId).readWithdrawalError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
Пример #5
0
 public ServersListener(IHubContext <ServersHub> hub,
                        HubConnectionManager hubConnectionManager,
                        IMapper mapper,
                        IServiceProvider serviceProvider,
                        //IAuthorizationService authorizationService,
                        MonitorComsCallback monitorComsCallback)
 {
     _hub = hub;
     _hubConnectionManager = hubConnectionManager;
     _mapper          = mapper;
     _serviceProvider = serviceProvider;
     //_authorizationService = authorizationService;
     _monitorComsCallback = monitorComsCallback;
 }
Пример #6
0
 private async void HubconnectionCallback(object state)
 {
     try
     {
         Task <HubConnection> task = HubConnectionManager.CreateHubConnection(HubUrl);
         hubConnection = await task;
         //hubConnection.StateChanged += HubConnection_StateChanged;
         //hubConnection.Error += HubConnection_Error;
         HubConnection_StateChanged(new StateChange(HubConnectionState.Disconnected, HubConnectionState.Connected));
         //RaisePropertyChanged(nameof(ConnectionState));
     }
     catch (Exception e)
     {
         HandleSignalRError(e);
     }
 }
Пример #7
0
 public IActionResult ReadPayments(string contractAddress)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 if (CanTransactWith(contractAddress))
                 {
                     try
                     {
                         Progress progress = PensionFundsServices.ReadPayments(contractAddress);
                         if (progress.Completed)
                         {
                             hubContext.Clients.Client(ConnectionId).paymentsCompleted(Json(progress).Value);
                         }
                         else
                         {
                             hubContext.Clients.Client(ConnectionId).paymentsUncompleted(Json(progress).Value);
                         }
                     }
                     finally
                     {
                         ReleaseTransactionWith(contractAddress);
                     }
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).readPaymentsError();
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(2), ex, string.Format("Erro on ReadPayments {0}.", contractAddress));
                 hubContext.Clients.Client(ConnectionId).readPaymentsError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
Пример #8
0
        public HubManager(
            ILogger <HubService> log,
            IOptions <ChainSettings> chainSettings,
            IOptions <HubSettings> hubSettings,
            IServiceProvider serviceProvider,
            IHubContext <WebSocketHub> hubContext,
            HubConnectionManager connectionManager)
        {
            this.log             = log;
            this.chainSettings   = chainSettings.Value;
            this.hubSettings     = hubSettings.Value;
            this.hubContext      = hubContext;
            this.serviceProvider = serviceProvider;

            Connections = connectionManager;

            TrustedHubs   = new List <string>();
            AvailableHubs = new Dictionary <string, HubInfo>();
            ConnectedHubs = new Dictionary <string, HubInfo>();
        }
Пример #9
0
 public IActionResult CheckContractCreationTransaction(String transactionHash)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 var pensionFundContract = PensionFundsServices.CheckContractCreationTransaction(transactionHash);
                 if (pensionFundContract.BlockNumber.HasValue)
                 {
                     hubContext.Clients.Client(ConnectionId).deployCompleted(Json(
                                                                                 new
                     {
                         Address         = pensionFundContract.Address,
                         BlockNumber     = pensionFundContract.BlockNumber,
                         TransactionHash = pensionFundContract.TransactionHash
                     }));
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).deployUncompleted(pensionFundContract.TransactionHash);
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(1), ex, string.Format("Erro on CheckContractCreationTransaction {0}.", transactionHash));
                 hubContext.Clients.Client(ConnectionId).deployError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
 public NotificationMessageHandler(HubManager manager, HubConnectionManager connections)
 {
     this.manager     = manager;
     this.connections = connections;
 }
Пример #11
0
 public BroadcastMessageHandler(HubManager connectionManager, HubConnectionManager connections)
 {
     this.connectionManager = connectionManager;
     this.connections       = connections;
 }
Пример #12
0
 public NotifyHub(HubConnectionManager connectionManager, IHubContext <NotifyHub> context)
 {
     ConnectionManager = connectionManager;
     _context          = context;
 }
Пример #13
0
 public override void Cleanup()
 {
     HubConnectionManager.Dispose();
     base.Cleanup();
 }
Пример #14
0
 public HubConnectionViewModel(HubConnectionManager hubConnectionManager)
 {
     HubConnectionManager = hubConnectionManager;
 }
Пример #15
0
 public AckMessageHandler(ILogger <AckMessageHandler> log, HubManager manager, HubConnectionManager connections)
 {
     this.log         = log;
     this.manager     = manager;
     this.connections = connections;
 }
Пример #16
0
 public PositionHub(HubConnectionManager connectionManager, IHubContext <PositionHub> context, HubPositionManager positionManager)
 {
     ConnectionManager    = connectionManager;
     _context             = context;
     this.PositionManager = positionManager;
 }