public bool PushData(string data)
        {
            // data = System.IO.File.ReadAllText("C:\\temp\\TemProjectFormPcsd\\conv.txt"); // <- loading JSON from file for tests
            Trace.Info($"PushData(), data length: {data.Length}");
            if (string.IsNullOrEmpty(data))
            {
                Trace.Error("PushData() was executed with empty content, exiting... :-(");
                return(false);
            }
            // http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config
            var serializer = new JavaScriptSerializer {
                MaxJsonLength = int.MaxValue
            };

            var dataType = ((serializer).Deserialize <Dictionary <string, object> >(data)).Keys.FirstOrDefault();

            Trace.Info($"Detected data type: {dataType}");
            switch (dataType)
            {
            case "conversations":
                ConversationManager.SaveConversations(ConversationManager.ParseConversations(data), ConnectionString);
                break;

            case "participantattrs":
                ParticipantAttrManager.SaveAttrs(ParticipantAttrManager.ParseAttrs(data), ConnectionString);
                break;

            case "conversationmetrics":
                ConversationMetricManager.SaveMetrics(ConversationMetricManager.ParseMetrics(data), ConnectionString);
                break;

            case "userdetailsdata":
                UserDetailsManager.SaveUserDetails(UserDetailsManager.ParseUserDetails(data), ConnectionString);
                break;

            case "userdata":
                UserAggregatesManager.SaveUserAggregates(UserAggregatesManager.ParseUserAggregates(data), ConnectionString);
                break;

            case "queuedata":
                ConversationAggregatesManager.SaveConversationAggregates(ConversationAggregatesManager.ParseConversationAggregates(data), ConnectionString);
                break;

            default:
                Trace.Error("Unsupported data type. :-(");
                break;
            }
            return(true);
        }
Beispiel #2
0
        public void BookMyRoom_LogedUser_CorrectDetails()
        {
            //Arrange
            UserDetailsManager userDetailsManager = new UserDetailsManager();
            UserDetails        loggeduser         = new UserDetails();

            loggeduser.userName = "******";
            loggeduser.password = "******";

            //Act
            UserDetails userDetails = userDetailsManager.LoggedUser(loggeduser);

            //Assert
            Assert.AreNotEqual(null, userDetails);
        }
Beispiel #3
0
        public void BookMyRoom_UpdateRewardPoints_CorrectDetails()
        {
            //Arrange
            UserDetailsManager userDetailsManager = new UserDetailsManager();
            UserDetails        loggeduser         = new UserDetails();

            loggeduser.userName = "******";
            loggeduser.password = "******";

            //Act

            UserDetails userDetails = userDetailsManager.LoggedUser(loggeduser);

            userDetails.rewardPoints = 100;
            bool result = userDetailsManager.UpdateRewards(userDetails);

            //Assert
            Assert.AreEqual(true, result);
        }
    public IEnumerator CreatePool()
    {
        //string otherUserId = WhotOpponent.instance.userId;
        //Debug.Log("other User Id: " + otherUserId);
        string url = UserDetailsManager.serverUrl + "createpool";
        string uId = SystemInfo.deviceUniqueIdentifier;

        betAmount = int.Parse(betAmountText.text);
#if UNITY_ANDROID && !UNITY_EDITOR
        uId = UserDetailsManager.androidUnique();
#elif UNITY_IOS && !UNITY_EDITOR
        uId = Device.advertisingIdentifier;
#endif
        Debug.Log("Whot pool url: " + url);
        Debug.Log("bet Amount: " + betAmount);
        Debug.Log("device_id: " + uId);
        Debug.Log("Receiver: " + receiverName);
        if (PhotonNetwork.connected && PhotonNetwork.room == null)
        {
            WWWForm form = new WWWForm();
            form.AddField("bet", betAmount);
            //form.AddField("otheruser", otherUserId);
            form.AddField("device_id", uId);
            Debug.Log("Time1: " + Time.timeScale);

            UnityWebRequest www = UnityWebRequest.Post(url, form);
            www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            www.SetRequestHeader("Authorization", "Bearer " + UserDetailsManager.accessToken);
            www.timeout = 15;
            Debug.Log("Time2: " + Time.timeScale);
            yield return(www.SendWebRequest());

            Debug.Log("Time3: " + Time.timeScale);
            Debug.Log("Pool Creation Response: " + www.downloadHandler.text);

            if (www.isNetworkError)
            {
                Debug.Log("Network Error!! " + www.error);
            }
            else
            {
                var roomList = MiniJSON.Json.Deserialize(www.downloadHandler.text) as IDictionary;
                if (www.downloadHandler.text.Contains("error"))
                {
                    Debug.Log("Error Occured: " + www.downloadHandler.text);
                }
                else
                {
                    //WHOTMultiplayerManager.instance.gameStarted = false;
                    isOpponentReady = false;
                    isPlayerReady   = false;
                    var poolDetails = (IDictionary)roomList["result"];
                    poolId = poolDetails["poolid"].ToString();
                    RoomOptions roomOptions = new RoomOptions();
                    roomOptions.PublishUserId = true;
                    winAmt = int.Parse(poolDetails["winning_amount"].ToString());
                    roomOptions.CustomRoomPropertiesForLobby = new string[] { "ownername", "ownerid", "bet", "isAvailable", "appVer", "poolId", "isChallenge", "winAmt", "game" };
                    roomOptions.CustomRoomProperties         = new ExitGames.Client.Photon.Hashtable()
                    {
                        { "ownername", UserDetailsManager.userName }, { "ownerid", UserDetailsManager.userId }, { "bet", betAmount }, { "isAvailable", true }, { "appVer", Application.version }, { "poolId", poolId }, { "isChallenge", isChallenge }, { "winAmt", winAmt }, { "game", "Whot" }
                    };
                    //ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "bet", MAtchMakeString }, { "isAvailable", true }, { "appVer", Application.version } };
                    roomOptions.MaxPlayers = 2;
                    roomOptions.IsVisible  = true;
                    roomOptions.IsOpen     = true;
                    PhotonNetwork.CreateRoom(poolId, roomOptions, TypedLobby.Default);

                    if (isChallenge)
                    {
                        ChatGui.instance.sendPhotonNotification(receiverName, UserDetailsManager.userName, "sendChallenge;" + poolId + ";" + betAmount + ";" + winAmt + ";" + "Whot");
                    }
                }
            }
        }
        else if (PhotonNetwork.room != null)
        {
            DisconnectFromPhoton();
        }
        else
        {
            GetPhotonToken();
        }
    }