Example #1
0
        private void SubmitBugReport(ILobbyService service, Stream s, string message)
        {
            Stream          upload      = new MemoryStream();
            UnicodeEncoding uniEncoding = new UnicodeEncoding();

            if (s != null && s.Length > Misc.MaxBugReportSize)
            {
                s = null;
            }
            byte[] messageBytes = uniEncoding.GetBytes(message);
            byte[] intBytes     = BitConverter.GetBytes(messageBytes.Length);
            upload.Write(intBytes, 0, intBytes.Length);
            upload.Write(messageBytes, 0, messageBytes.Length);
            if (s != null)
            {
                try
                {
                    byte[] bytes = new byte[4];
                    s.Read(bytes, 0, 4);
                    int length = BitConverter.ToInt32(bytes, 0);
                    s.Seek(length, SeekOrigin.Current);

                    s.CopyTo(upload);
                    s.Flush();
                }
                catch (Exception)
                {
                    s = null;
                }
            }

            upload.Flush();
            upload.Seek(0, SeekOrigin.Begin);
            service.SubmitBugReport(upload);
        }
Example #2
0
 public GameHub(ILobbyService lobbyService, IMessageService messageService, IPlayerService playerService, IGameService gameService)
 {
     _lobbyService   = lobbyService;
     _messageService = messageService;
     _playerService  = playerService;
     _gameService    = gameService;
 }
 public LobbiesController(
     ILobbyService lobbyService,
     Services.Interfaces.IAuthorizationService authorizationService)
 {
     _lobbyService         = lobbyService;
     _authorizationService = authorizationService;
 }
 public ManageInterestVM(IUserService userService,
                         ILobbyService lobbyService, IInterestProviderService interestProviderService)
 {
     _interestService = interestProviderService;
     _userService     = userService;
     _lobbyService    = lobbyService;
     _timer           = new Timer(state =>
     {
         Changed(nameof(ServerTime));
         PushUpdates();
     }, null, 0, 1000);
 }
Example #5
0
 public ApplicationViewModel(ILobbyFactory lobbyFactory,
                             IGameFactory gameFactory,
                             ILobbyService lobbyService,
                             IConsoleService consoleService,
                             IUserService userService)
 {
     _lobbyFactory   = lobbyFactory;
     _gameFactory    = gameFactory;
     _lobbyService   = lobbyService;
     _consoleService = consoleService;
     _userService    = userService;
 }
Example #6
0
 public LobbyWorker(
     IUserService userService,
     ILobbyService lobbyService,
     IOptions <AppConfiguration> appconfig,
     IHubContext <TjommisHub> hubContext,
     ILoggerFactory loggerFactory)
 {
     _lobbyService = lobbyService;
     _userService  = userService;
     _appConfig    = appconfig.Value;
     _hub          = hubContext;
     _logger       = loggerFactory.CreateLogger <LobbyWorker>();
 }
        public FrontEndManagementVM(IUserService userService, ILobbyService lobbyService)
        {
            _userService  = userService;
            _lobbyService = lobbyService;
            _timer        = new Timer(state =>
            {
                //Notify dotnetify to send these values
                Changed(nameof(ServerTime));
                Changed(nameof(TotalUsers));
                Changed(nameof(TotalLobbies));
                Changed(nameof(Lobbies));
                Changed(nameof(Users));
                Changed(nameof(UsersInHangout));
                Changed(nameof(TempLobbies));

                PushUpdates();
            }, null, 0, 1000);
        }
        public GameController(
            IRoomManager roomManager,
            IVerificationService <PlayerVerificationResponseModel> VerificationService,
            IIdentifierGenerator identifierGenerator,
            ILobbyService lobbyService,
            IChatRoomService chatRoomService)
        {
            verificationService = VerificationService;
            RoomManager         = roomManager;
            IdentifierGenerator = identifierGenerator;
            LobbyService        = lobbyService;
            ChatRoomService     = chatRoomService;

            GameFactory = new GameFactory();
            ReadyTimer  = new ReadyTimer();
            Thread timerThread = new Thread(ReadyTimer.StartTimer);

            timerThread.Start();

            Players   = new HashSet <IPlayer>();
            GameTypes = new Dictionary <int, string>();
        }
Example #9
0
        public LobbyHub(ILobbyService lobbyService, IConnectionMultiplexer redisConnection, IGameNodeService gameNodeService, IOptions <AuthTokenOptions> tokenOptions)
        {
            this.lobbyService    = lobbyService;
            this.gameNodeService = gameNodeService;

            this.tokenOptions = tokenOptions.Value;

            var subscriber = redisConnection.GetSubscriber();

            database = redisConnection.GetDatabase();

            if (setupDone)
            {
                return;
            }

            subscriber.Subscribe(RedisChannels.LobbyMessage).OnMessage(OnLobbyMessageAsync);
            subscriber.Subscribe(RedisChannels.LobbyMessageRemoved).OnMessage(OnLobbyMessageRemovedAsync);
            subscriber.Subscribe("RemoveRunningGame").OnMessage(OnRemoveGameAsync);

            setupDone = true;
        }
Example #10
0
        public LobbyClient(ILobbyStore lobbyStore,
                           ILobbyService lobbyService,
                           IHubService hubService,
                           INavigationService navigationService,
                           IDialogService dialogService,
                           IMessageService messageService,
                           IMessageStore messageStore)
        {
            this.lobbyStore        = lobbyStore;
            this.hubService        = hubService;
            this.lobbyService      = lobbyService;
            this.navigationService = navigationService;
            this.dialogService     = dialogService;
            this.messageService    = messageService;
            this.messageStore      = messageStore;

            hubService.Connection.On <Guid>(nameof(LobbyDeleted), LobbyDeleted);
            hubService.Connection.On <LobbyDataWrapper>(nameof(LobbyChanged), LobbyChanged);
            hubService.Connection.On(nameof(KickedFromLobby), KickedFromLobby);
            hubService.Connection.On <LobbyDataWrapper>(nameof(LobbyAdded), LobbyAdded);
            hubService.Connection.On <Guid, Message>(nameof(ReceiveLobbyMessage), ReceiveLobbyMessage);
            hubService.Connection.On <LobbyDataWrapper>(nameof(ReceiveLobbyInvite), ReceiveLobbyInvite);
        }
Example #11
0
 public OfferAggregator(ILobbyService lobbyService, IUserOfferService userOfferService, IPlaceService placeService)
 {
     _lobbyService     = lobbyService;
     _userOfferService = userOfferService;
     _placeService     = placeService;
 }
Example #12
0
 public LobbyController(ILobbyService lobbyService, IGamesService gamesService, IMapper mapper)
 {
     _lobbyService = lobbyService;
     _gamesService = gamesService;
     _mapper       = mapper;
 }
Example #13
0
 public ChatHub(ILobbyService lobbyService, IUserService userService)
 {
     _lobbyService = lobbyService;
     _userService  = userService;
 }
Example #14
0
 public LobbiesController(ILobbyService lobbyService, IClientNotifier clientNotifier)
 {
     this.lobbyService   = lobbyService;
     this.clientNotifier = clientNotifier;
 }
Example #15
0
        private void SubmitBugReport(ILobbyService service, Stream s, string message)
        {
            Stream upload = new MemoryStream();
            UnicodeEncoding uniEncoding = new UnicodeEncoding();
            if (s != null && s.Length > Misc.MaxBugReportSize) s = null;
            byte[] messageBytes = uniEncoding.GetBytes(message);
            byte[] intBytes = BitConverter.GetBytes(messageBytes.Length);
            upload.Write(intBytes, 0, intBytes.Length);
            upload.Write(messageBytes, 0, messageBytes.Length);
            if (s != null)
            {
                try
                {
                    byte[] bytes = new byte[4];
                    s.Read(bytes, 0, 4);
                    int length = BitConverter.ToInt32(bytes, 0);
                    s.Seek(length, SeekOrigin.Current);

                    s.CopyTo(upload);
                    s.Flush();
                }
                catch (Exception)
                {
                    s = null;
                }
            }

            upload.Flush();
            upload.Seek(0, SeekOrigin.Begin);
            service.SubmitBugReport(upload);
        }
Example #16
0
 public UserHub(IUserService userService, ILobbyService lobbyService)
 {
     this.userService = userService;
 }
Example #17
0
 public MainHub(ILobbyService lobbyService, IMessageService messageService, IPlayerService playerService)
 {
     _lobbyService   = lobbyService;
     _messageService = messageService;
     _playerService  = playerService;
 }
Example #18
0
 public GameHub(ILobbyService lobbyService)
 {
     _lobbyService = lobbyService;
 }
Example #19
0
 public GameHub(IUserService userService, ILobbyService lobbyService)
 {
     this.userService  = userService;
     this.lobbyService = lobbyService;
 }
Example #20
0
        private void _createAccount()
        {
            string userName = tab0UserName.Text;
            string passwd   = tab0Password.Password;

            Properties.Settings.Default.LastHostName = tab0HostName.Text;
            Properties.Settings.Default.LastUserName = tab0UserName.Text;
            Properties.Settings.Default.Save();
#if !DEBUG
            if (string.IsNullOrEmpty(userName))
            {
                _Warn("Please provide a username");
                return;
            }
#endif
            busyIndicator.BusyContent = Resources["Busy.ConnectServer"];
            busyIndicator.IsBusy      = true;
            ILobbyService server   = null;
            string        hostName = tab0HostName.Text;
            if (!hostName.Contains(":"))
            {
                hostName = hostName + ":" + DefaultLobbyPort;
            }

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (o, ea) =>
            {
                try
                {
                    ea.Result = LoginStatus.UnknownFailure;
                    var binding = new NetTcpBinding();
                    binding.Security.Mode = SecurityMode.None;
                    var endpoint       = new EndpointAddress(string.Format("net.tcp://{0}/GameService", hostName));
                    var channelFactory = new DuplexChannelFactory <ILobbyService>(LobbyViewModel.Instance, binding, endpoint);
                    server = channelFactory.CreateChannel();
                    var stat = server.CreateAccount(userName, passwd);
                    ea.Result = stat;
                }
                catch (Exception e)
                {
                    string s = e.StackTrace;
                }
            };

            worker.RunWorkerCompleted += (o, ea) =>
            {
                busyIndicator.IsBusy = false;
                switch ((LoginStatus)ea.Result)
                {
                case LoginStatus.Success:
                    MessageBox.Show("Account created successfully");
                    break;

                case LoginStatus.OutdatedVersion:
                    MessageBox.Show("Outdated version. Please update.");
                    break;

                case LoginStatus.InvalidUsernameAndPassword:
                    MessageBox.Show("Invalid Username and Password.");
                    break;

                default:
                    MessageBox.Show("Failed to launch client.");
                    break;
                }
            };

            worker.RunWorkerAsync();
        }
Example #21
0
        private void _startClient()
        {
            _userName = tab0UserName.Text;
            _passWd   = tab0Password.Password;
            Properties.Settings.Default.LastHostName = tab0HostName.Text;
            Properties.Settings.Default.LastUserName = tab0UserName.Text;
            Properties.Settings.Default.Save();
#if !DEBUG
            bool createdNew;
            if (appMutex == null)
            {
                appMutex = new System.Threading.Mutex(true, "Sanguosha", out createdNew);
                ///if creation of mutex is successful
                if (!createdNew && tab0HostName.Text != "127.0.0.1")
                {
                    appMutex = null;
                    _Warn("You already have another Sanguosha running!");
                    return;
                }
            }
#endif

            if (string.IsNullOrEmpty(_userName))
            {
                _Warn("Please provide a username");
                return;
            }

            busyIndicator.BusyContent = Resources["Busy.ConnectServer"];
            busyIndicator.IsBusy      = true;
            ILobbyService server    = null;
            LoginToken    token     = new LoginToken();
            string        reconnect = null;
            _hostName = tab0HostName.Text;
            if (!_hostName.Contains(":"))
            {
                _hostName = _hostName + ":" + DefaultLobbyPort;
            }

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (o, ea) =>
            {
                try
                {
                    ea.Result = LoginStatus.UnknownFailure;

                    _LogOut();
                    var lobbyModel = LobbyViewModel.Instance;
                    var binding    = new NetTcpBinding();
                    binding.Security.Mode = SecurityMode.None;
                    var endpoint = new EndpointAddress(string.Format("net.tcp://{0}/GameService", _hostName));
                    _channelFactory = new DuplexChannelFactory <ILobbyService>(lobbyModel, binding, endpoint);
                    server          = _channelFactory.CreateChannel();

                    _channelFactory.Faulted += channelFactory_Faulted;
                    Account ret;
                    var     stat = server.Login(Misc.ProtocolVersion, _userName, _passWd, out ret, out reconnect, out token);
                    if (stat == LoginStatus.Success)
                    {
                        LobbyViewModel.Instance.CurrentAccount = ret;

                        if (reconnect != null)
                        {
                            Application.Current.Dispatcher.Invoke((ThreadStart) delegate()
                            {
                                MainGame.BackwardNavigationService = this.NavigationService;
                                busyIndicator.BusyContent          = Resources["Busy.Reconnecting"];
                            });
                        }
                    }
                    ea.Result = stat;
                }
                catch (Exception e)
                {
                    string s = e.StackTrace;
                }
            };

            worker.RunWorkerCompleted += (o, ea) =>
            {
                bool success = false;
                if ((LoginStatus)ea.Result == LoginStatus.Success)
                {
                    LobbyView lobby = LobbyView.Instance;
                    LobbyView.Instance.OnNavigateBack += lobby_OnNavigateBack;
                    var lobbyModel = LobbyViewModel.Instance;
                    lobbyModel.Connection = server;
                    lobbyModel.LoginToken = token;

                    if (reconnect == null)
                    {
                        this.NavigationService.Navigate(lobby);
                        busyIndicator.IsBusy = false;
                    }
                    else
                    {
                        lobbyModel.NotifyGameStart(reconnect, token);
                        busyIndicator.IsBusy = true;
                    }

                    success = true;
                }
                if (!success)
                {
                    if ((LoginStatus)ea.Result == LoginStatus.InvalidUsernameAndPassword)
                    {
                        MessageBox.Show("Invalid Username and Password");
                        busyIndicator.IsBusy = false;
                    }
                    else if ((LoginStatus)ea.Result == LoginStatus.OutdatedVersion)
                    {
                        // MessageBox.Show("Outdated version. Please update");
                        busyIndicator.BusyContent = Resources["Busy.Updating"];
                    }
                    else
                    {
                        MessageBox.Show("Cannot connect to server.");
                        busyIndicator.IsBusy = false;
                    }
                }
                startButton.IsEnabled = true;
            };

            worker.RunWorkerAsync();
        }
Example #22
0
 public TjommisHub(IUserService userService, ILobbyService lobbyService, IInterestProviderService interestProvider)
 {
     _interestProvider = interestProvider;
     _userService      = userService;
     _lobbyService     = lobbyService;
 }
Example #23
0
 public LobbyHub(IUserService userService, ILobbyService lobbyService)
 {
     field             = new FieldDefault();
     this.userService  = userService;
     this.lobbyService = lobbyService;
 }
Example #24
0
 public LobbyController(ILobbyService service, IHttpContextAccessor httpContextAccessor)
 {
     _service      = service;
     currentUserId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
 }
Example #25
0
 public LobbyController(ILobbyService lobbyService) => _lobbyService = lobbyService;
Example #26
0
 private void SubmitBugReport(ILobbyService service, Stream s, string message)
 {
     Stream upload = new MemoryStream();
     UnicodeEncoding uniEncoding = new UnicodeEncoding();
     if (s != null && s.Length > Misc.MaxBugReportSize) s = null;
     byte[] messageBytes = uniEncoding.GetBytes(message);
     byte[] intBytes = BitConverter.GetBytes(messageBytes.Length + 4);
     upload.Write(intBytes, 0, intBytes.Length);
     upload.Write(messageBytes, 0, messageBytes.Length);
     if (s != null)
     {
         s.CopyTo(upload);
         s.Flush();
     }
     upload.Flush();
     upload.Seek(0, SeekOrigin.Begin);
     service.SubmitBugReport(upload);
 }
 public SignalRHub(ILobbyService lobbyService) : base()
 {
     this.lobbyService = lobbyService;
 }