Пример #1
0
        private async void BtnSetup_Clicked(object sender, EventArgs e)
        {
            btnSetup.IsEnabled = false;
            await SignalRService.MultiplayerSetup(me);

            //After this you just wait for either for "waiting" or "newgame" events to run
        }
Пример #2
0
        public MainViewModel()
        {
            _signalR                     = new SignalRService();
            _signalR.Connected          += SignalR_ConnectionChanged;
            _signalR.ConnectionFailed   += SignalR_ConnectionChanged;
            _signalR.NewMessageReceived += SignalR_NewMessageReceived;

            Messages = new ObservableCollection <ChatMessage>();

            // localhost for UWP/iOS or special IP for Android
            //var ip = "localhost";
            //if (Device.RuntimePlatform == Device.Android)
            //    ip = "10.0.2.2";

            //_hubConnection = new HubConnectionBuilder()
            //    .WithUrl($"https://signalchatappapi20200125121336.azurewebsites.net/chatHub")
            //    .Build();

            //_hubConnection.On<string>("JoinChat", (user) =>
            //{
            //    Messages.Add(new ChatMessage() { User = Name, Message = $"{user} has joined the chat", IsSystemMessage = true });
            //});

            //_hubConnection.On<string>("LeaveChat", (user) =>
            //{
            //    Messages.Add(new ChatMessage() { User = Name, Message = $"{user} has left the chat", IsSystemMessage = true });
            //});

            //_hubConnection.On<string, string>("ReceiveMessage", (user, message) =>
            //{
            //    Messages.Add(new ChatMessage() { User = user, Message = message, IsSystemMessage = false, IsOwnMessage = Name == user });
            //});
        }
Пример #3
0
 private void InitializeHandlers()
 {
     signalR                     = new SignalRService();
     signalR.Connected          += SignalR_ConnectionChanged;
     signalR.ConnectionFailed   += SignalR_ConnectionChanged;
     signalR.NewMessageReceived += SignalR_NewMessageReceived;
 }
Пример #4
0
        public MainViewModel()
        {
            instance     = this;
            Pins         = new ObservableCollection <Pin>();
            Locations    = new ObservableCollection <TKCustomMapPin>();
            locations    = new ObservableCollection <TKCustomMapPin>();
            listlocation = new ObservableCollection <ListRequest>();

            myPosition = new TKCustomMapPin();

            LocationsRequest = new ObservableCollection <PinRequest>();
            apiService       = new ApiService();
            Menu             = new ObservableCollection <MenuItemViewModel>();
            EncabezadoMenu   = new MenuItemViewModel();


            navigationService = new NavigationService();
            NewLogin          = new LoginViewModel();
            AddnewClient      = new AddViewModel();
            CheckinClient     = new CheckinViewModel();
            signalRService    = new SignalRService();
            LoadClientes();
            if (Settings.IsLoggedIn)
            {
                Locator();
            }
        }
        public StartViewModel()
        {
            var canConnect = this.WhenAnyValue(x => x.Url, x => x.JoinCode, x => x.Username, (url, code, name) =>
                                               url != null &&
                                               Uri.IsWellFormedUriString(url, UriKind.Absolute) &&
                                               code != null &&
                                               Regex.IsMatch(code, @"^[a-z]{5}$") &&
                                               name != null &&
                                               Regex.IsMatch(name, @"^[A-Za-z]{3,20}$"));

            _connect = ReactiveCommand.CreateFromTask(async() =>
            {
                var service = await SignalRService.Initialize(Url);
                var player  = await service.JoinGameSession(Username, JoinCode);

                if (player == null)
                {
                    await Error.Handle("The Join Code was invalid");
                    return;
                }

                var vm = new GameViewModel(service, player);
                HostScreen.Router.Navigate.Execute(vm).Subscribe();
            }, canConnect, RxApp.TaskpoolScheduler);

            _isLoading = this.WhenAnyObservable(x => x.Connect.IsExecuting)
                         .StartWith(false)
                         .ToProperty(this, x => x.IsLoading);
        }
Пример #6
0
        private async Task LetsSingExecute()
        {
            try
            {
                await ExecuteBusyAction(async() =>
                {
                    if (string.IsNullOrWhiteSpace(UserName))
                    {
                        await PageDialogService.DisplayAlertAsync("Really?", "Maybe you forgot something!", "Ok");
                        return;
                    }

                    if (CurentUser == null)
                    {
                        await UserService.Add(UserName);
                    }

                    await SignalRService.Connect();
                    await NavigationService.NavigateAsync("../Home");
                });
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Пример #7
0
        private static void Main(string[] args)
        {
            //檢核僅能執行一個執行個體
            bool   isRun       = false;
            String ProcessName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
            Mutex  m           = new Mutex(true, ProcessName, out isRun);

            if (!isRun)
            {
                return;
            }

            Console.Title = "SignalR.ExSrv";
            IntPtr ParenthWnd = new IntPtr(0);
            IntPtr et         = new IntPtr(0);

            ParenthWnd = FindWindow(null, "SignalR.ExSrv");

            ShowWindow(ParenthWnd, 1);//隐藏本dos窗体, 0: 后台执行;1:正常启动;2:最小化到任务栏;3:最大化

            SignalRService service = new SignalRService();

            Console.WriteLine("Server running on {0}", service.URL);

            while (true)
            {
                string input = Console.ReadLine();
                service.BrocastMsgToAll(input, "Admin");
            }
        }
Пример #8
0
        public void ChangeSettings(object sender, EventArgs args)
        {
            bool CurrentConnectionStatus = SignalRService.IsConnected;

            if (CurrentConnectionStatus)
            {
                SignalRService.CloseConnection();
            }

            ConnectionSettings = ConnectionSettingsChanged;

            UserInfo = UserInfoChanged;

            IsActivated = IsActivatedChange;

            SignalRService.Settings = ConnectionSettings;

            SignalRService.UserInfo = UserInfo;

            if (CurrentConnectionStatus && IsActivated)
            {
                SignalRService.StartConnection();
            }

            ConnectionService.Settings = ConnectionSettings;

            DataStorageService.StoreData(UserInfo, "UserInfo.json", this);
            DataStorageService.StoreData(ConnectionSettings, "ConnectionSettings.json", this);
            DataStorageService.StoreData(IsActivated, "IsActivated.json", this);

            Reciver.OnReceive(this, new Intent());
        }
 public OrdersController(
     IOrderApplicationServices orderApplicationServices,
     SignalRService signalRService
     )
 {
     _orderApplicationServices = orderApplicationServices;
     _signalRService           = signalRService;
 }
Пример #10
0
 private async void btnRoundP1_Clicked(object sender, EventArgs e)
 {
     GameMessage newMessage = new GameMessage()
     {
         Type = "round_p1", RoomId = gameInfo.RoomId
     };
     await SignalRService.SendMessage(newMessage);
 }
Пример #11
0
 public TraderController(UserManager <ApplicationUser> userManager, TraderManager traderManager,
                         ApplicationDbContext dbContext, SignalRService signalRService)
 {
     _userManager    = userManager;
     _traderManager  = traderManager;
     _dbContext      = dbContext;
     _signalRService = signalRService;
 }
Пример #12
0
 public ChatViewModel(SignalRService signalRService)
 {
     _signalRService = signalRService;
     ConnectAsync();
     SubmitButtonCommand = new Command(() => {
         SubmitMessage(Message);
     });
 }
 public ClientsController(
     IClientApplicationServices ClientApplicationServices,
     SignalRService signalRService
     )
 {
     _ClientApplicationServices = ClientApplicationServices;
     _signalRService            = signalRService;
 }
Пример #14
0
        public MainViewModel(string username, SignalRService signalR)
        {
            Username = username;

            SendMessage = new SendMessage(this, signalR);

            signalR.MessageReceived += SignalR_MessageReceived;
        }
Пример #15
0
 private async void btnStartTimer_Clicked(object sender, EventArgs e)
 {
     GameMessage newMessage = new GameMessage()
     {
         Type = "startstoptimer", RoomId = gameInfo.RoomId, Content = TimerIsRunning
     };
     await SignalRService.SendMessage(newMessage);
 }
Пример #16
0
 private async void btnGuessP2_Clicked(object sender, EventArgs e)
 {
     GameMessage newMessage = new GameMessage()
     {
         Type = "guess_p2", RoomId = gameInfo.RoomId
     };
     await SignalRService.SendMessage(newMessage);
 }
        public CommunityPostingPage()
        {
            InitializeComponent();

            signalR                     = new SignalRService();
            signalR.Connected          += SignalR_ConnectionChanged;
            signalR.ConnectionFailed   += SignalR_ConnectionChanged;
            signalR.NewMessageReceived += SignalR_NewMessageReceived;
        }
Пример #18
0
        public App()
        {
            InitializeComponent();

            SignalRService signalRService = new SignalRService(signalREndPoint, negotiateUri, postUri);

            DependencyService.RegisterSingleton <ISignalRService>(signalRService);

            MainPage = new MainPage();
        }
Пример #19
0
 public TraderManager(StockDataReaderManager stockDataReaderManager, IConfiguration configuration,
                      IServiceProvider serviceProvider, TradingClientFactory tradingClientFactory,
                      ILogger <TraderManager> logger, SignalRService signalRService)
 {
     _stockDataReaderManager = stockDataReaderManager;
     _configuration          = configuration;
     _serviceProvider        = serviceProvider;
     _tradingClientFactory   = tradingClientFactory;
     _logger         = logger;
     _signalRService = signalRService;
 }
Пример #20
0
        private async void BtnStopWaiting_Clicked(object sender, EventArgs e)
        {
            BGMusics.Clicking_Sound().Play();

            lblMessages.Text = "Stopping waiting...";
            await SignalRService.MultiplayerStopWaiting(me);;

            LoadingBit.IsVisible = false;
            Fetch.IsRunning      = false;
            Btn_Find.IsVisible   = false;
        }
        public static IStockDataReader GetStockDataReader(string type, string stock, SignalRService signalRService)
        {
            switch (type)
            {
            case AppConstants.StockDataReaderTypeYahoo:
                return(new YahooStockDataReader(stock, signalRService));

            default:
                return(new YahooStockDataReader(stock, signalRService));
            }
        }
Пример #22
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _Deferral = taskInstance.GetDeferral();

            var signalServer = new SignalRService();

            var lightService = new LightsService();
            //  var chartService = new ChartService(lightService);
            var schedulePlan = new SchedulePlanService();

            var mqttService = new MQTTServer();
            await signalServer.Connect(lightService, mqttService, schedulePlan);

            await mqttService.ServerRun(signalServer);

            //            var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();
            //            var taskName = "test";
            //            if (backgroundAccessStatus == AlwaysAllowed)
            //            {
            //                foreach (var task in BackgroundTaskRegistration.AllTasks)
            //                {
            //                    if (task.Value.Name == taskName)
            //                    {
            //                        return;
            //                    }
            //                }
            //            }
            //
            //            BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();
            //            taskBuilder.Name = taskName;
            //            taskBuilder.TaskEntryPoint =
//            var status = await BackgroundExecutionManager.RequestAccessAsync();
//            var taskName = "test";
//            if (BackgroundTaskRegistration.AllTasks.All(x => x.Value.Name != taskName))
//            {
//                BackgroundTaskBuilder builder = new BackgroundTaskBuilder();
//                builder.Name = taskName;
//                builder.TaskEntryPoint = typeof(LightHBackgroundIotHttpService.TileUpdateTask).FullName;
//                builder.SetTrigger(new TimeTrigger(16,false));
//
//                if (status != BackgroundAccessStatus.Denied)
//                {
//                    builder.Register();
//                }
//            }

            // chartService.SmartSwitchingLights(true, lightService);

            //            await ThreadPool.RunAsync(workItem =>
            //            {
            //                webserver.Start();
            //
            //            });
        }
Пример #23
0
 protected Trader(IStockDataReader stockDataReader, ITradingClient tradingClient,
                  IServiceProvider serviceProvider,
                  ApplicationUser user, Strategy strategy, ILogger log, SignalRService signalRService)
 {
     _stockDataReader = stockDataReader;
     _tradingClient   = tradingClient;
     _serviceProvider = serviceProvider;
     _user            = user;
     Strategy         = strategy;
     _log             = log;
     _signalRService  = signalRService;
 }
Пример #24
0
        public YahooStockDataReader(string stock, SignalRService signalRService)
        {
            _stock          = stock;
            _signalRService = signalRService;
            var chromeOptions = new ChromeOptions();

            chromeOptions.AddArguments("--headless");

            _driver = new ChromeDriver(AppConstants.FilePath, chromeOptions);

            _driver.Navigate().GoToUrl($"https://finance.yahoo.com/quote/{_stock}");
        }
Пример #25
0
        public async System.Threading.Tasks.Task <ResponseModel_PlaceOrder> PlaceOrderAsync(PlaceOrderRequestModel listModel)
        {
            var response = new ResponseModel_PlaceOrder
            {
                Success  = false,
                Messages = new List <string>()
            };

            if (listModel == null || listModel.Items == null || listModel.Items.Count == 0 && string.IsNullOrEmpty(listModel.Cords))
            {
                response.Messages.Add("Data not mapped");
                response.Data = listModel;
            }
            else if (listModel.Cords.Split('_').Length != 2)
            {
                response.Messages.Add("Invalid Cord format. Please specify in Lat_Lang .i.e. '32.202895_74.176716'");
                response.Data = listModel;
            }
            else
            {
                try
                {
                    var orderById = listModel.OrderPlacedById;
                    if (string.IsNullOrEmpty(listModel.OrderPlacedById))
                    {
                        var contextnew  = new ApplicationDbContext();
                        var userStore   = new UserStore <ApplicationUser>(contextnew);
                        var userManager = new UserManager <ApplicationUser>(userStore);
                        var user        = userManager.FindByName(User.Identity.Name);
                        orderById = user.Id;
                    }

                    var signalRUrl = ConfigurationManager.AppSettings["signalRHubUrl"];
                    var item       = OrderService.Place(listModel, orderById);
                    response.Data     = item.EstimatedTime;
                    response.OrderId  = item.OrderIds;
                    response.SerialNo = item.SerailNo;
                    response.Messages.Add("Success");
                    response.Success = true;

                    //get orders by serial no here
                    var _order = OrderService.GetOrderDetailsBySerialNo(item.SerailNo);
                    await SignalRService.NotifyNewOrdersReceivedAsync(_order.Orders, signalRUrl);
                }
                catch (Exception excep)
                {
                    response.Messages.Add("Something bad happened.");
                }
            }
            return(response);
        }
Пример #26
0
        public void Execute(object parameter)
        {
            var connection = new HubConnectionBuilder()
                             .WithUrl("http://localhost:5000/MessageHub")
                             .Build();

            var signalRService = new SignalRService(connection);

            var mainView = new MainView
            {
                DataContext = new MainViewModel(LoginViewModel.Username, signalRService)
            };

            LoginViewModel.View.Close();
            mainView.Show();
        }
Пример #27
0
        public async Task <IActionResult> CancelInvitation([FromBody] FriendIdModel model)
        {
            if (!await Users.CheckIfExists(model.FriendId))
            {
                return(NotFound());
            }
            if (!await Friendships.CheckIfInvitationExistByInvitationRoles(model.FriendId, User.Id()))
            {
                return(NotFound());
            }

            await HubContext.Clients.Clients(await SignalRService.GetUserConnections(model.FriendId))
            .RefreshNotifications(await Friendships.RemoveInvitation(User.Id(), model.FriendId));

            return(Ok());
        }
Пример #28
0
 private async void OnTimedEvent(object sender, ElapsedEventArgs e)
 {
     if (isPlayer1)
     {
         if (timeCount > 0)
         {
             GameMessage newMessage = new GameMessage()
             {
                 Type = "time", Content = 1
             };
             await SignalRService.SendMessage(newMessage);
         }
         else
         {
             GameTimer.Stop();
         }
     }
 }
Пример #29
0
        private async void BtnStopWaiting_Clicked(object sender, EventArgs e)
        {
            lblStatus.Text           = "Stopping waiting...";
            waitingSpinner.IsVisible = true;
            waitingSpinner.IsRunning = true;

            //Clear the waiting list
            await SignalRService.MultiplayerStopWaiting(me);

            lblStatus.Text = "Click below to start a game:";

            waitingSpinner.IsVisible = false;
            waitingSpinner.IsRunning = false;
            btnStopWaiting.IsEnabled = false;
            btnStopWaiting.IsVisible = false;
            btnSetup.IsEnabled       = true;
            btnSetup.IsVisible       = true;
        }
Пример #30
0
        async Task SetSignalRService()
        {
            await SetIsLoading(true);

            try
            {
                signalRService = await SignalRService.GetSignalRService();

                signalRService.LiveMatchViewModelRecieved -= OnLiveViewMatchRecieved;
                signalRService.LiveMatchViewModelRecieved += OnLiveViewMatchRecieved;
            }
            catch (Exception)
            {
                //TODO: Implement
            }

            await SetIsLoading(false);
        }