예제 #1
0
        override public void Execute(INotification notification)
        {
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("RequestConnectionCommand.Execute", LogLevel.Info);
            ConfigManagerClient configManager   = GameFacade.Instance.RetrieveProxy <ConfigManagerClient>();
            ConnectionProxy     connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();

            connectionProxy.SetConfiguration(configManager);

            if (Application.isEditor || configManager.GetBool("override_boss_server", false))
            {
                GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("RequestConnectionCommand, using in editor settings, connection ip " + connectionProxy.IpAddress + " port " + connectionProxy.Port, LogLevel.Info);
                GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>().Connect(connectionProxy.IpAddress, connectionProxy.Port);
                Console.Log("connection ip " + connectionProxy.IpAddress + " port " + connectionProxy.Port);
            }
            else
            {
                string resolvedPath = connectionProxy.WebServicesBaseUrl + "/Boss/GetStateServer";
                GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("RequestConnectionCommand boss server path = " + resolvedPath, LogLevel.Info);
                GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>().CallToService(resolvedPath, delegate(XmlDocument serverDocument)
                {
                    //Expected format:
                    //<ConnectTo>
                    //   <StateServer Ip="64.106.173.25" Port="8000" Population="0" />
                    //</ConnectTo>
                    XmlElement serverNode = (XmlElement)serverDocument.SelectSingleNode("/ConnectTo/StateServer");
                    string ipAddress      = serverNode.GetAttribute("Ip");
                    int port = int.Parse(serverNode.GetAttribute("Port"));

                    GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("Connecting to state server at " + ipAddress + ":" + port, LogLevel.Info);
                    Console.WriteLine("Connecting to state server at " + ipAddress + ":" + port);

                    GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>().Connect(ipAddress, port);
                });
            }
        }
예제 #2
0
        /// <summary>
        /// Loads and sends a feed from the given path and name. Javascript will hide unity until the feed
        /// is taken care of and then when Unity is shown again, onFeedSent will be executed.
        /// </summary>
        public void PostFeed(long?targetId, string feedCopyDataPath, string feedDataName, Hangout.Shared.Action onFeedSent, string param)
        {
            if (String.IsNullOrEmpty(feedCopyDataPath))
            {
                throw new ArgumentNullException("feedCopyDataPath");
            }
            if (String.IsNullOrEmpty(feedDataName))
            {
                throw new ArgumentNullException("feedDataName");
            }
            if (onFeedSent == null)
            {
                throw new ArgumentNullException("onFeedSent");
            }

            // Log the post
            ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();
            long            fromId          = connectionProxy.FacebookAccountId;
            string          extraProps      = String.Format("{0}|{1}", fromId, targetId);

            EventLogger.Log(LogGlobals.CATEGORY_FACEBOOK, LogGlobals.FACEBOOK_FEED_POST, feedDataName, extraProps);

            mAssetRepo.LoadAssetFromPath <XmlAsset>(feedCopyDataPath, delegate(XmlAsset asset)
            {
                mTaskCollection.Add(mScheduler.StartCoroutine(SendFeedJavascript(targetId, asset.XmlDocument, feedDataName, onFeedSent, param)));
            });
        }
예제 #3
0
        /// <summary>
        /// Handle initial entry into the game.  Put user in a default location based on their if they are a first time user,
        /// and their entry point into the client from the web
        /// </summary>
        private void HandleInitialEntryToGame()
        {
            UserAccountProxy userAccountProxy = GameFacade.Instance.RetrieveProxy <UserAccountProxy>();
            bool             isFirstTimeUser  = false;

            Console.WriteLine("User properties " + userAccountProxy.ToString());
            if (!userAccountProxy.TryGetAccountProperty <bool>(UserAccountProperties.FirstTimeUser, ref isFirstTimeUser))
            {
                Console.WriteLine("First time user property not set, assume it our first time in");
                isFirstTimeUser = true;
            }

            ConfigManagerClient configManager = GameFacade.Instance.RetrieveProxy <ConfigManagerClient>();
            bool returnUsersStartMinigame     = configManager.GetBool("return_users_start_minigame", true);

            if (isFirstTimeUser)
            {
                ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();
                switch (connectionProxy.WebEntryPointId)
                {
                case FunnelGlobals.PUBLIC_LOBBY:
                    RoomManagerProxy roomManager = GameFacade.Instance.RetrieveProxy <RoomManagerProxy>();
                    roomManager.JoinLastRoom();
                    break;

                case FunnelGlobals.FASHION_MINIGAME:
                    SendNotification(GameFacade.SWITCHING_TO_FASHION_MINI_GAME);
                    break;

                default:
                    throw new Exception("Unexpected entry point received: " + connectionProxy.WebEntryPointId);
                }
                // Set firstTimeUser property to false
                userAccountProxy.SetAccountProperty <bool>(UserAccountProperties.FirstTimeUser, false);
            }
            else
            {
                if (returnUsersStartMinigame)
                {
                    SendNotification(GameFacade.SWITCHING_TO_FASHION_MINI_GAME);
                }
                else
                {
                    Console.WriteLine("Not a First time user go to room");
                    // Returning user.  Go to default room
                    RoomManagerProxy roomManager = GameFacade.Instance.RetrieveProxy <RoomManagerProxy>();
                    roomManager.JoinLastRoom();
                }
            }
        }
예제 #4
0
        private void SendLoginCredentials()
        {
            ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();
            List <object>   data            = new List <object>();

            data.Add(connectionProxy.FacebookAccountId);
            data.Add(connectionProxy.SessionKey);
            data.Add(connectionProxy.NickName);   //nickname
            data.Add(connectionProxy.FirstName);  //first name
            data.Add(connectionProxy.LastName);   //last name
            data.Add(connectionProxy.CampaignId); //campaign
            data.Add(connectionProxy.ReferrerId); //referrerId
            data.Add(connectionProxy.SelectedAvatar);

            SendNotification(GameFacade.LOGIN_REQUEST, data);
            // Hide login gui so we can't keep pressing login
            HideLoginWindow();
        }
예제 #5
0
        private IEnumerator <IYieldInstruction> SendFeedJavascript(long?targetId, XmlDocument xml, string feedDataName, Hangout.Shared.Action onFeedSent, string param)
        {
            XmlNode feedDataNode = xml.SelectSingleNode("//FeedData[@name='" + feedDataName + "']");

            if (feedDataNode == null)
            {
                throw new Exception("Unable to find a FeedData node named (" + feedDataName + ")\n" + xml.OuterXml);
            }

            // User Message
            XmlNode defaultUserMessage = feedDataNode.SelectSingleNode("DefaultUserMessage");

            if (defaultUserMessage == null)
            {
                throw new Exception("Unable to find node (DefaultUserMessage) in FeedData:\n" + feedDataNode.OuterXml);
            }

            // User Message
            XmlNode userMessagePrompt = feedDataNode.SelectSingleNode("UserMessagePrompt");

            if (userMessagePrompt == null)
            {
                throw new Exception("Unable to find node (UserMessagePrompt) in FeedData:\n" + feedDataNode.OuterXml);
            }

            // Action
            XmlNode actionName = feedDataNode.SelectSingleNode("Action/Name");

            if (actionName == null)
            {
                throw new Exception("Unable to find node (Action/Name) in FeedData:\n" + feedDataNode.OuterXml);
            }

            XmlNode actionUrl = feedDataNode.SelectSingleNode("Action/Url");

            if (actionUrl == null)
            {
                throw new Exception("Unable to find node (Action/Url) in FeedData:\n" + feedDataNode.OuterXml);
            }

            // Attachment
            XmlNode attachmentName = feedDataNode.SelectSingleNode("Attachment/Name");

            if (attachmentName == null)
            {
                throw new Exception("Unable to find node (Attachment/Name) in FeedData:\n" + feedDataNode.OuterXml);
            }

            XmlNode attachmentUrl = feedDataNode.SelectSingleNode("Attachment/Url");

            if (attachmentUrl == null)
            {
                throw new Exception("Unable to find node (Attachment/Url) in FeedData:\n" + feedDataNode.OuterXml);
            }

            XmlNode attachmentCaption = feedDataNode.SelectSingleNode("Attachment/Caption");

            if (attachmentCaption == null)
            {
                throw new Exception("Unable to find node (Attachment/Caption) in FeedData:\n" + feedDataNode.OuterXml);
            }

            XmlNode attachmentDescription = feedDataNode.SelectSingleNode("Attachment/Description");

            if (attachmentDescription == null)
            {
                throw new Exception("Unable to find node (Attachment/Description) in FeedData:\n" + feedDataNode.OuterXml);
            }

            XmlNode attachmentImgSrcUrl = feedDataNode.SelectSingleNode("Attachment/ImageSrcUrl");

            if (attachmentImgSrcUrl == null)
            {
                throw new Exception("Unable to find node (Attachment/ImageSrcUrl) in FeedData:\n" + feedDataNode.OuterXml);
            }

            XmlNode attachmentImgLinkUrl = feedDataNode.SelectSingleNode("Attachment/ImageLinkUrl");

            if (attachmentImgLinkUrl == null)
            {
                throw new Exception("Unable to find node (Attachment/ImageLinkUrl) in FeedData:\n" + feedDataNode.OuterXml);
            }

            string targetIdStr = "";

            if (targetId != null)
            {
                targetIdStr = targetId.ToString();
            }

            ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();
            string          referrer        = connectionProxy.FacebookAccountId.ToString();

            bool jsReturned = false;

            mJavascriptDispatch.RequestFeedPost
            (
                targetIdStr,
                feedDataName,
                userMessagePrompt.InnerText.Replace("{0}", param),
                defaultUserMessage.InnerText.Replace("{0}", param),
                actionName.InnerText.Replace("{0}", param),
                actionUrl.InnerText.Replace("{0}", param).Replace("{1}", referrer),
                attachmentName.InnerText.Replace("{0}", param),
                attachmentUrl.InnerText.Replace("{0}", param).Replace("{1}", referrer),
                attachmentCaption.InnerText.Replace("{0}", param),
                attachmentDescription.InnerText.Replace("{0}", param),
                attachmentImgSrcUrl.InnerText.Replace("{0}", param),
                attachmentImgLinkUrl.InnerText.Replace("{0}", param).Replace("{1}", referrer),
                delegate(string result)
            {
                jsReturned = true;
            }
            );

            if (!Application.isEditor)
            {
                yield return(new YieldWhile(delegate() { return !jsReturned; }));
            }
            else
            {
                yield return(new YieldUntilNextFrame());
            }

            onFeedSent();
        }