Beispiel #1
0
 void SignInCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.SIGNIN);
     if (handle.Success)
     {
     }
 }
Beispiel #2
0
 void QuitGameCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOBBY || mode == Mode.INGAME);
     if (handle.Success)
     {
         LoadTables();
     }
 }
Beispiel #3
0
 void OpenGameCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOBBY);
     if (handle.Success)
     {
         LoadTables();
     }
 }
Beispiel #4
0
 void GetGameDataCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOBBY || mode == Mode.INGAME);
     if (handle.Success)
     {
         JSONObject data = handle.ResultData;
         Logger.Instance.Log("DETAIL", "gamedata: " + data.ToString());
         handle.dataCallback(data);
     }
 }
Beispiel #5
0
 void CreateGameCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOBBY);
     if (handle.Success)
     {
         JSONObject data        = handle.ResultData;
         string     activeTable = data.GetField("table").ToString();
         OpenGame(activeTable);
     }
 }
Beispiel #6
0
 public bool SendNotification(string type, Dictionary <string, string> args, Web.RequestHandle.SuccessCallBackType callback)
 {
     Debug.Assert(mode == Mode.INGAME);
     Web.RequestHandle handle = sendRequest(serverData.GameName, type, args, SendNotificationCallBack, "Notify");
     if (handle != null)
     {
         handle.successCallback = callback;
     }
     return(handle != null);
 }
Beispiel #7
0
        /////// Send Requests ////////

        /////// Request callbacks ////////
        void LoadTablesCallBack(Web.RequestHandle handle)
        {
            Debug.Assert(mode == Mode.LOBBY || mode == Mode.INGAME);
            if (handle.Success)
            {
                JSONObject data   = handle.ResultData;
                JSONObject tables = data.GetField("tables");
                Logger.Instance.Log("DETAIL", tables.ToString());
                Lobby.UpdateTables(tables);
            }
        }
Beispiel #8
0
        public bool GetGameData(string tableId, Web.RequestHandle.DataCallBackType callback)
        {
            Debug.Assert(mode == Mode.LOBBY || mode == Mode.INGAME);
            var args = new Dictionary <string, string>();

            args["table"] = tableId;
            Web.RequestHandle handle = sendRequest(serverData.GameName, "gamedataonly", args, GetGameDataCallBack, "GetGameData");
            if (handle != null)
            {
                handle.dataCallback = callback;
            }
            return(handle != null);
        }
Beispiel #9
0
 void LogOutCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOGIN);
     logInData.ClearUserInfos();
     if (handle.Success)
     {
         JSONObject data = handle.ResultData;
         if (data.GetField("success").b)
         {
         }
         else
         {
             Logger.Instance.Log("NW_WARNING", "Not properly disconnected");
         }
     }
 }
Beispiel #10
0
 void JoinGameCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOBBY);
     if (handle.Success)
     {
         JSONObject data = handle.ResultData;
         if (data.str == "ok")
         {
             LoadTables();
         }
         else
         {
             Logger.Instance.Log("NW_WARNING", "Server Error");
         }
     }
 }
Beispiel #11
0
        public bool GetNotificationHistory(string tableId, int from, bool simpleNoteHistoric, Web.RequestHandle.DataCallBackType callback)
        {
            Debug.Assert(mode == Mode.INGAME);
            var args = new Dictionary <string, string>();

            args["table"]      = tableId;
            args["from"]       = from.ToString();
            args["privateinc"] = "1";
            args["history"]    = simpleNoteHistoric ? "1" : "0";
            Web.RequestHandle handle = sendRequest(serverData.GameName, "notificationHistory", args, GetNotificationHistoryCallBack, "GetHistory");
            if (handle != null)
            {
                handle.dataCallback = callback;
            }
            return(handle != null);
        }
Beispiel #12
0
 void GetNotificationHistoryCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.INGAME);
     if (handle.Success)
     {
         JSONObject data = handle.ResultData;
         if (data.GetField("valid").n == 1)
         {
             JSONObject history = data.GetField("data");
             Logger.Instance.Log("DETAIL", "history: " + history.ToString());
             handle.dataCallback(history);
         }
         else
         {
             Logger.Instance.Log("WARNING", "Server History Result Invalid");
             Logger.Instance.Log("DETAIL", "data: " + data.ToString());
             handle.dataCallback(null);
         }
     }
 }
Beispiel #13
0
        void SendNotificationCallBack(Web.RequestHandle handle)
        {
            Debug.Assert(mode == Mode.INGAME);
            bool success = false;

            if (handle.Success)
            {
                JSONObject data = handle.ResultData;
                if (data.HasField("valid") && data.GetField("valid").n == 1)
                {
                    success = true;
                }
                else
                {
                    Logger.Instance.Log("WARNING", "Server Notification Result Invalid");
                    Logger.Instance.Log("DETAIL", "data: " + data.ToString());
                }
            }

            handle.successCallback(success);
        }
Beispiel #14
0
 void LogInCallBack(Web.RequestHandle handle)
 {
     Debug.Assert(mode == Mode.LOGIN || mode == Mode.ONLINE);
     if (handle.Success)
     {
         JSONObject data = handle.ResultData;
         if (data.GetField("success").b)
         {
             logInData.UpdateUserInfos(data);
             SavePersistantData();
         }
         else
         {
             Logger.Instance.Log("NW_WARNING", "Incorrect username or password");
             logInData.ClearUserInfos();
         }
     }
     else
     {
         logInData.ClearUserInfos();
     }
 }