public static async Task LoadPage(int offset, HostedGameFilters filters)
        {
            // Send API request
            var result = await BSSBMasterAPI.Browse(offset, filters);

            // Update state
            _offset           = offset;
            _lastServerResult = result;

            // If we got results, process and index the lobby info
            var nextLobbiesOnPage = new List <HostedGameData>();

            if (_lastServerResult != null)
            {
                foreach (var lobby in _lastServerResult.Lobbies)
                {
                    _lobbyObjects[lobby.Id.Value] = lobby;
                    nextLobbiesOnPage.Add(lobby);
                }
            }

            _lobbiesOnPage = nextLobbiesOnPage;

            // Fire update event for the UI
            OnUpdate.Invoke();
        }
Esempio n. 2
0
        public static async Task LoadPage(int offset, string searchQuery, bool filterFull = false, bool filterInProgress = false, bool filterModded = false)
        {
            // Send API request
            var result = await BSSBMasterAPI.Browse(offset, searchQuery, filterFull, filterInProgress, filterModded);

            // Update state
            _offset           = offset;
            _lastServerResult = result;

            // If we got results, process and index the lobby info
            var nextLobbiesOnPage = new List <HostedGameData>();

            if (_lastServerResult != null)
            {
                foreach (var lobby in _lastServerResult.Lobbies)
                {
                    _lobbyObjects[lobby.Id.Value] = lobby;
                    nextLobbiesOnPage.Add(lobby);
                }

                // Server message
                if (!String.IsNullOrEmpty(_lastServerResult.Message))
                {
                    FloatingNotification.Instance.ShowMessage("Server Browser Message", _lastServerResult.Message,
                                                              FloatingNotification.NotificationStyle.Cerise, Sprites.Portal);
                }
            }

            _lobbiesOnPage = nextLobbiesOnPage;

            // Fire update event for the UI
            OnUpdate.Invoke();
        }
Esempio n. 3
0
        /// <summary>
        /// Ensures that any host announcements made by us are removed:
        ///  - If a previous announcement was made, a DELETE request is sent to the master server, removing it.
        ///  - If no previous announcement was made, or it was already deleted, this is a no-op.
        /// </summary>
        public static async Task UnAnnounce()
        {
            if (_lastCompleteAnnounce != null && !_sentUnAnnounce)
            {
                _sentUnAnnounce = true;

                if (await BSSBMasterAPI.UnAnnounce(_lastCompleteAnnounce))
                {
                    Plugin.Log?.Info($"Host announcement was deleted OK!");

                    _didAnnounce          = false;
                    _lastCompleteAnnounce = null;
                }
                else
                {
                    _sentUnAnnounce = false;
                }
            }
        }
Esempio n. 4
0
        private static async Task DoAnnounce(HostedGameData announce)
        {
            _sentUnAnnounce = false;

            if (await BSSBMasterAPI.Announce(announce))
            {
                _didAnnounce          = true;
                _lastCompleteAnnounce = announce;

                StatusText = $"Players can now join from the browser!\r\n{announce.Describe()}";
                HasErrored = false;
            }
            else
            {
                _didAnnounce          = false;
                _lastCompleteAnnounce = null;

                StatusText = $"Could not announce to master server!";
                HasErrored = true;
            }

            LobbyConfigPanel.UpdatePanelInstance();
        }