Пример #1
0
        private void UpdateWindowTitleLabel(MessageSubType MessageSubType)
        {
            // Enable all the tabs, then selectively disable the one that is selected
            Button clientOwnedRoomsButton   = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/ClientOwnedRoomsButton");
            Button friendsRoomsButton       = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/FriendsRoomsButton");
            Button hangoutPublicRoomsButton = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/HangoutPublicRoomsButton");

            clientOwnedRoomsButton.Enabled   = true;
            friendsRoomsButton.Enabled       = true;
            hangoutPublicRoomsButton.Enabled = true;

            switch (MessageSubType)
            {
            case MessageSubType.ClientOwnedRooms:
                mTitleLabel.Text = Translation.ROOM_PICKER_MY_ROOMS;
                clientOwnedRoomsButton.Enabled = false;
                break;

            case MessageSubType.FriendsRooms:
                mTitleLabel.Text           = Translation.ROOM_PICKER_FRIENDS_ROOMS;
                friendsRoomsButton.Enabled = false;
                break;

            case MessageSubType.PublicRooms:
                mTitleLabel.Text = Translation.ROOM_PICKER_PUBLIC_ROOMS;
                hangoutPublicRoomsButton.Enabled = false;
                break;
            }
        }
Пример #2
0
 public Message(MessageType type, MessageSubType messageSubType, List <object> data)
     : this()
 {
     mMessageType = type;
     mCallback    = (int)messageSubType;
     mData        = data;
 }
Пример #3
0
        public static Message ErrorToUser(ErrorIndex errorIndex, MessageSubType errorActionType)
        {
            List <object> errorMessageData = new List <object>();

            errorMessageData.Add(errorIndex);

            Message errorMessage = new Message();

            errorMessage.Callback = (int)errorActionType;
            errorMessage.ErrorMessage(errorMessageData);
            return(errorMessage);
        }
Пример #4
0
        private void JoinRoomForClient(Message receivedMessage, Guid senderId)
        {
            RoomId         newRoomId       = CheckType.TryAssignType <RoomId>(receivedMessage.Data[0]);
            MessageSubType roomRequestType = CheckType.TryAssignType <MessageSubType>(receivedMessage.Data[1]);


            JoinRoom(senderId, newRoomId, delegate()
            {
                AccountId accountId = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(senderId).AccountId;
                Metrics.Log(LogGlobals.CATEGORY_ROOMS, LogGlobals.ROOM_ENTERED, LogGlobals.ROOM_LABEL, newRoomId.ToString(), accountId.ToString());
                SendClientAvailableRooms(senderId, roomRequestType);
            });
        }
Пример #5
0
        public static void RequestRoomsFromServer(MessageSubType roomRequestType)
        {
            ClientMessageProcessor clientMessageProcessor = GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>();
            Message requestRoomsMessage = new Message();

            requestRoomsMessage.Callback = (int)MessageSubType.RequestRooms;
            List <object> messageData = new List <object>();

            messageData.Add(roomRequestType);
            requestRoomsMessage.RoomMessage(messageData);

            clientMessageProcessor.SendMessageToReflector(requestRoomsMessage);
        }
Пример #6
0
        protected virtual void SendClientAvailableRooms(Guid sessionId, MessageSubType roomRequestType)
        {
            ServerAccount        account = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(sessionId);
            Action <XmlDocument> getAvailableRoomsCallback = delegate(XmlDocument xmlResponse)
            {
                List <IServerDistributedRoom> availableRooms     = new List <IServerDistributedRoom>();
                List <RoomProperties>         roomPropertiesList = RoomXmlUtil.GetRoomsPropertiesFromXml(xmlResponse, mServerStateMachine.ServerAssetRepository);
                foreach (RoomProperties roomProperties in roomPropertiesList)
                {
                    availableRooms.Add(CreateServerDistributedRoom(roomProperties));
                }
                Message availableRoomsMessage = GenerateSendClientAvailableRoomsMessage(availableRooms);
                //send message to client
                SendMessageToClient(availableRoomsMessage, sessionId);
            };

            switch (roomRequestType)
            {
            case MessageSubType.ClientOwnedRooms:
                RoomManagerServiceAPI.GetSessionOwnedRoomsService(account.AccountId, getAvailableRoomsCallback);
                break;

            case MessageSubType.PublicRooms:
                RoomManagerServiceAPI.GetAllSystemRoomsService(getAvailableRoomsCallback);
                break;

            case MessageSubType.FriendsRooms:

                IList <AccountId> friendAccountIds =
                    Functionals.MapImmediate <FacebookFriendInfo, AccountId>
                    (
                        delegate(FacebookFriendInfo facebookFriendInfo)
                {
                    return(facebookFriendInfo.AccountId);
                },
                        account.HangoutFacebookFriends
                    );

                RoomManagerServiceAPI.GetSessionOwnedRoomsWithPrivacyService(friendAccountIds, PrivacyLevel.Default, getAvailableRoomsCallback);
                break;

            default:
                //Console.WriteLine("be patient! not implemented yet!");
                List <IServerDistributedRoom> availableRooms = new List <IServerDistributedRoom>();
                Message availableRoomsMessage = GenerateSendClientAvailableRoomsMessage(availableRooms);
                //send message to client
                SendMessageToClient(availableRoomsMessage, sessionId);
                break;
            }
        }
Пример #7
0
        public static void SwitchRoom(RoomId newRoomIdToJoin, MessageSubType roomRequestType)
        {
            ClientMessageProcessor clientMessageProcessor = GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>();
            Message switchRoomMessage = new Message();

            switchRoomMessage.Callback = (int)MessageSubType.SwitchRoom;
            List <object> messageData = new List <object>();

            messageData.Add(newRoomIdToJoin);
            messageData.Add(roomRequestType);
            switchRoomMessage.RoomMessage(messageData);

            clientMessageProcessor.SendMessageToReflector(switchRoomMessage);
        }
Пример #8
0
        private void LoginError(Guid sessionId, ErrorIndex errorIndex, MessageSubType errorActionType)
        {
            ServerAccount serverAccount = mSessionManager.GetServerAccountFromSessionId(sessionId);
            string        accountId     = "unknown account";

            if (serverAccount != null)
            {
                accountId = serverAccount.AccountId.ToString();
            }
            mLogger.Warn(String.Format("LoginError | sessionId={0} | accountId={1}", sessionId, accountId));
            Metrics.Log(LogGlobals.CATEGORY_CONNECTION, LogGlobals.EVENT_LOGIN, LogGlobals.LOGIN_FAILED, accountId);
            Message loginErrorMessage = StateServerError.ErrorToUser(errorIndex, errorActionType);

            SendMessageToReflector(loginErrorMessage, sessionId);
            DisconnectUser(sessionId);
        }
Пример #9
0
        public override void HandleNotification(INotification notification)
        {
            if (mRoomPickerGui == null)
            {
                Init();
            }
            switch (notification.Name)
            {
            case GameFacade.CLOSE_ALL_WINDOWS:
                mRoomPickerGui.Showing = false;
                mMapGui.Showing        = false;
                break;

            case GameFacade.TOGGLE_ROOM_PICKER_GUI:
                mRoomPickerGui.Showing = !mRoomPickerGui.Showing;
                if (mRoomPickerGui.Showing)
                {
                    MessageSubType roomRequestTypeToggleRoomPickerGui = (MessageSubType)notification.Body;
                    mRoomPickerGui.RequestRooms(roomRequestTypeToggleRoomPickerGui);
                }
                break;

            case GameFacade.SHOW_ROOM_PICKER_GUI:
                MessageSubType MessageSubTypehowRoomPickerGui = (MessageSubType)notification.Body;
                mRoomPickerGui.Showing = true;
                mRoomPickerGui.RequestRooms(MessageSubTypehowRoomPickerGui);
                break;

            case GameFacade.SHOW_SERVER_ROOM_API:
                RoomAPICommands.RequestRoomsFromServer(MessageSubType.ClientOwnedRooms);
                mRoomAPIGui.Showing = true;
                break;

            case GameFacade.ROOM_LOADING_STARTED:
                mCurrentRoomId = (RoomId)notification.Body;
                mRoomAPIGui.UpdateCurrentRoomId(mCurrentRoomId);
                break;

            case GameFacade.MAP_BUTTON_CLICKED:
                mMapGui.Showing = !mMapGui.Showing;
                break;
            }
        }
Пример #10
0
        private void SwitchRoomForClient(Message receivedMessage, Guid senderId)
        {
            RoomId         newRoomId       = CheckType.TryAssignType <RoomId>(receivedMessage.Data[0]);
            MessageSubType roomRequestType = CheckType.TryAssignType <MessageSubType>(receivedMessage.Data[1]);

            ServerAccount account   = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(senderId);
            RoomId        oldRoomId = account.LastRoomId;

            SwitchRoom(senderId, newRoomId, oldRoomId, delegate()
            {
                string newRoom = "";
                if (newRoomId != null)
                {
                    newRoom = newRoomId.ToString();
                }
                Metrics.Log(LogGlobals.CATEGORY_ROOMS, LogGlobals.ROOM_ENTERED, LogGlobals.ROOM_LABEL, newRoom, account.AccountId.ToString());
                SendClientAvailableRooms(senderId, roomRequestType);
            }
                       );
        }
Пример #11
0
 private void should_convert_to_expected_enum(MessageSubType inbound, SlackMessageSubType expected)
 {
     inbound
     .ToSlackMessageSubType()
     .ShouldBe(expected);
 }
Пример #12
0
        private void SendClientAvailableRooms(Message receivedMessage, Guid senderId)
        {
            MessageSubType roomRequestType = CheckType.TryAssignType <MessageSubType>(receivedMessage.Data[0]);

            SendClientAvailableRooms(senderId, roomRequestType);
        }
Пример #13
0
        public RoomPickerGui(IGuiManager guiManager, System.Action <RoomType> sendSwitchingToRoomTypeNotification)
            : base(guiManager, mResourcePath)
        {
            mSendSwitchingToRoomTypeNotification = sendSwitchingToRoomTypeNotification;
            foreach (IGuiElement element in this.AllElements)
            {
                if (element.Name == "RoomPickerGui" && element is Window)
                {
                    mMainWindow = (Window)element;
                    mMainWindow.OnShowing(OnShowingCallback);

                    mTitleLabel = mMainWindow.SelectSingleElement <Label>("MainFrame/RoomListingsFrame/TitleBarLabel");
                    //we're going to initially display the client's rooms so the "My Rooms" title should be displayed first
                    mTitleLabel.Text = Translation.ROOM_PICKER_MY_ROOMS;

                    Button closeButton = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingsFrame/CancelButton");
                    closeButton.AddOnPressedAction(
                        delegate()
                    {
                        mMainWindow.Showing = false;
                    }
                        );

                    //setup the buttons for displaying the various types of rooms
                    Button clientOwnedRoomsButton   = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/ClientOwnedRoomsButton");
                    Button friendsRoomsButton       = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/FriendsRoomsButton");
                    Button hangoutPublicRoomsButton = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/HangoutPublicRoomsButton");

                    clientOwnedRoomsButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        ClearRoomsWindow();
                        UpdateWindowTitleLabel(MessageSubType.ClientOwnedRooms);
                        RoomAPICommands.RequestRoomsFromServer(MessageSubType.ClientOwnedRooms);
                        mCurrentRoomRequestType = MessageSubType.ClientOwnedRooms;
                    }
                    );
                    friendsRoomsButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        ClearRoomsWindow();
                        UpdateWindowTitleLabel(MessageSubType.FriendsRooms);
                        RoomAPICommands.RequestRoomsFromServer(MessageSubType.FriendsRooms);
                        mCurrentRoomRequestType = MessageSubType.FriendsRooms;
                    }
                    );
                    hangoutPublicRoomsButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        ClearRoomsWindow();
                        UpdateWindowTitleLabel(MessageSubType.PublicRooms);
                        RoomAPICommands.RequestRoomsFromServer(MessageSubType.PublicRooms);
                        mCurrentRoomRequestType = MessageSubType.PublicRooms;
                    }
                    );

                    //set up the grid view / scroll area where the rooms are listed
                    mRoomListScrollFrame       = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/RoomListingsFrame/RoomListScrollFrame");
                    mRoomListingPrototypeFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/RoomListingsFrame/RoomListScrollFrame/RoomListingPrototypeFrame");
                    mRoomListScrollFrame.RemoveChildWidget(mRoomListingPrototypeFrame);
                }
            }
        }
Пример #14
0
 public void RequestRooms(MessageSubType roomRequestType)
 {
     RoomAPICommands.RequestRoomsFromServer(roomRequestType);
     UpdateWindowTitleLabel(roomRequestType);
     ClearRoomsWindow();
 }
Пример #15
0
 public static SlackMessageSubType ToSlackMessageSubType(this MessageSubType subType)
 {
     return((SlackMessageSubType)subType);
 }
Пример #16
0
 protected override void SendClientAvailableRooms(Guid sessionId, MessageSubType roomRequestType)
 {
 }