예제 #1
0
        private static IEnumerator SendTakePutBackCardPostMessage(BgoSessionObject sessionObject, BgoGame game, String postUrl, String idNote, Action callback)
        {
            postUrl = RemoveCharacterEntities(postUrl);

            WWWForm myPostData = new WWWForm();

            myPostData.AddField("idNote", idNote);
            myPostData.AddField("idMsgChat", "");

            var cookieHeaders = myPostData.headers;

            cookieHeaders.Add("Cookie", "PHPSESSID=" + sessionObject._phpSession + "; identifiant=" + sessionObject._identifiant + "; mot_de_passe=" + sessionObject._motDePasse);

            //var data = Encoding.UTF8.GetString(myPostData.data);

            var www = new WWW(BgoBaseUrl + postUrl, myPostData.data, cookieHeaders);

            yield return(www);

            if (www.error != null)
            {
                Assets.CSharpCode.UI.Util.LogRecorder.Log(www.error);

                yield break;
            }

            var responseText = www.text;

            BgoPageProvider.FillGameBoard(responseText, game);

            if (callback != null)
            {
                callback();
            }
        }
예제 #2
0
        private static IEnumerator PerformAction(BgoSessionObject sessionObject, BgoGame game, String actionValue, Dictionary <String, String> overrideData, Action callback)
        {
            var postUrl = RemoveCharacterEntities(game.ActionFormSubmitUrl);

            WWWForm myPostData = new WWWForm();

            foreach (var pair in game.ActionForm)
            {
                if (pair.Key == "action")
                {
                    myPostData.AddField("action", actionValue);
                }
                else
                {
                    if (overrideData != null && overrideData.ContainsKey(pair.Key))
                    {
                        myPostData.AddField(pair.Key, overrideData[pair.Key]);
                        overrideData.Remove(pair.Key);
                    }
                    else
                    {
                        myPostData.AddField(pair.Key, pair.Value);
                    }
                }
            }
            if (overrideData != null)
            {
                foreach (var pair in overrideData)
                {
                    myPostData.AddField(pair.Key, pair.Value);
                }
            }


            var cookieHeaders = myPostData.headers;

            cookieHeaders.Add("Cookie", "PHPSESSID=" + sessionObject._phpSession + "; identifiant=" + sessionObject._identifiant + "; mot_de_passe=" + sessionObject._motDePasse);

            //var data = Encoding.UTF8.GetString(myPostData.data);

            var www = new WWW(BgoBaseUrl + postUrl, myPostData.data, cookieHeaders);

            yield return(www);

            if (www.error != null)
            {
                Assets.CSharpCode.UI.Util.LogRecorder.Log(www.error);

                yield break;
            }

            var responseText = www.text;

            BgoPageProvider.FillGameBoard(responseText, game);

            if (callback != null)
            {
                callback();
            }
        }
예제 #3
0
 public IEnumerator ListGames(Action <List <TtaGame> > callback)
 {
     return(BgoPageProvider.GameLists(sessionObject._phpSession, bgoGames =>
     {
         List <TtaGame> games = new List <TtaGame>();
         bgoGames.ForEach(game => games.Add(game));
         if (callback != null)
         {
             callback(games);
         }
     }));
 }
예제 #4
0
        public IEnumerator RefreshBoard(TtaGame game, Action callback)
        {
            var html = Resources.Load <TextAsset>(File);;

            BgoPageProvider.FillGameBoard(html.text, game as BgoGame);

            if (callback != null)
            {
                callback();
            }

            yield break;
        }
예제 #5
0
 public IEnumerator LogIn(String username, String password, Action callback)
 {
     return(BgoPageProvider.HomePage(username, password, (session, mot) =>
     {
         sessionObject = new BgoSessionObject();
         sessionObject._phpSession = session;
         sessionObject._identifiant = username;
         sessionObject._motDePasse = mot;
         if (callback != null)
         {
             callback();
         }
     }));
 }
예제 #6
0
        public IEnumerator RefreshBoard(TtaGame game, Action callback)
        {
            if (!(game is BgoGame))
            {
                return(null);
            }

            var bgoGame = (BgoGame)game;

            return(BgoPageProvider.RefreshBoard(sessionObject._phpSession, bgoGame, () =>
            {
                if (callback != null)
                {
                    callback();
                }
            }));
        }