void Start()
 {
     #if UNITY_EDITOR
     ServicePointManager.ServerCertificateValidationCallback = Validator;
     #endif
     sp = new ServiceAPI (cons.apiKey,cons.secretKey);
 }
 public static void App42Init(string apiKey , string secretKey)
 {
     sc_Listener_App42 = new SC_Listener_App42(); //initiate Listener with current GameLogic Script
     api = new ServiceAPI(apiKey, secretKey);
     userService = api.BuildUserService();
     Debug.Log("apiKey " + apiKey + Environment.NewLine + "secretKey " + secretKey);
     //    sessionService = api.BuildSessionService();
     //    Debug.Log(sessionService.GetSessionId());
 }
        /// <summary>
        /// Test Method for saving the user score in App42 Cloud. 
        /// </summary>
        public static void SaveUserScore()
        {
            /// Enter your Public Key and Private Key Here in Constructor. You can
            /// get it once you will create a app in app42 console.

            ServiceAPI sp = new ServiceAPI("<Your_API_Key>", "<Your_Secret_Key>");

            String gameName = "PokerGame";
            String userName = "******";
            double gameScore = 3500;
            String description = "description";
            /// Create Instance of ScoreBoard Service
            ScoreBoardService scoreBoardService = sp.BuildScoreBoardService();
            GameService gameService = sp.BuildGameService();

            try
            {
                Game saveScore = scoreBoardService.SaveUserScore(gameName,userName,gameScore);
                Console.WriteLine("gameName is " + saveScore.GetName());
                for (int i = 0; i < saveScore.GetScoreList().Count; i++)
                {
                    Console.WriteLine("userName is : " + saveScore.GetScoreList()[i].GetUserName());
                    Console.WriteLine("score is : " + saveScore.GetScoreList()[i].GetValue());
                    Console.WriteLine("scoreId is : " + saveScore.GetScoreList()[i].GetScoreId());
                }
            }
            catch (App42Exception ex)
            {
                /// Exception Caught
                /// Do exception Handling of Score Board Service functions.
                if (ex.GetAppErrorCode() == 3002)
                {
                    Game createGame = gameService.CreateGame(gameName, description);
                    Console.WriteLine("gameName is " + createGame.GetName());
                    Game game = scoreBoardService.SaveUserScore(gameName, userName, gameScore);
                    Console.WriteLine("gameName is " + game.GetName());
                    for (int i = 0; i < game.GetScoreList().Count; i++)
                    {
                        Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
                        Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
                        Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
                    }
                }
                else if (ex.GetAppErrorCode() == 1401)
                {
                    Console.WriteLine("Please verify your API_KEY and SECRET_KEY From AppHq Console (Apphq.shephertz.com).");
                }
                else
                {
                    Console.WriteLine("Exception is : " + ex.ToString());
                }

            }
            Console.ReadKey();
        }
        private void Fill()
        {
            ServiceAPI api = new ServiceAPI();
            var result = api.GetLatestQuestion().Result;

            if (!string.IsNullOrEmpty(result.Content))
            {
                var list = JsonConvert.DeserializeObject<Rootobject>(result.Content).items;

                Stack_Question question;

                foreach (var item in list)
                {
                    question = Mapper.Map<Item, Stack_Question>(item);

                    if (!this.QuestionList.Any(x => x.Question_id == question.Question_id))
                    {
                        this.QuestionList.Insert(0, question);
                    }
                }

                //this.QuestionList.OrderBy(x => x.Creation_date);
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("On navigated to loading");
            timeout = 0;

            MediaElementData[0] = t1;
            MediaElementData[1] = t2;

            Global.MyAudio[0] = App.GlobalMediaElement0;
            Global.MyAudio[1] = App.GlobalMediaElement1;
            Global.MyAudio[2] = App.GlobalMediaElement2;
            Global.MyAudio[3] = App.GlobalMediaElement3;
            Global.MyAudio[4] = App.GlobalMediaElement4;

            Global.opponentUsername = "";
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ready.Text = Global.localUsername + " \nvs\n";
            });

            _dispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
            _dispatcherTimer.Tick += UpdateMediaData;
            _dispatcherTimer.Start();

            i = 0;
            k = 0;
            B(false);

            requestCallback = this;
            App42API.Initialize(Constants.API_KEY, Constants.SECRET_KEY);
            App42Log.SetDebug(true);

            ServiceAPI api = new ServiceAPI(Constants.API_KEY, Constants.SECRET_KEY);

            storage = api.BuildStorageService();
            uploadService = api.BuildUploadService();

            System.Diagnostics.Debug.WriteLine("Before warp");

            WarpClient.initialize(Constants.API_KEY, Constants.SECRET_KEY);

            WarpClient.setRecoveryAllowance(60);

            Global.warpClient = WarpClient.GetInstance();


            //trivia
            if ((int)settings["trigger"] == 0)
                TriviaTB.Text = Global.TriviaB[(new Random()).Next(Global.TriviaB.Length)];
            else
                TriviaTB.Text = Global.TriviaH[(new Random()).Next(Global.TriviaH.Length)];

            Global.disconnectSuccess = false;
            Global.deleteSuccess = false;
            Global.conListenObj = new ConnectionListener(this);
            Global.roomReqListenerObj = new RoomReqListener(this);
            Global.zoneReqListenerObj = new ZoneRequestListener(this);
            Global.notificationListenerObj = new NotificationListener(this);
     
            Global.warpClient.AddConnectionRequestListener(Global.conListenObj);
            Global.warpClient.AddRoomRequestListener(Global.roomReqListenerObj);
            Global.warpClient.AddNotificationListener(Global.notificationListenerObj);
            Global.warpClient.AddZoneRequestListener(Global.zoneReqListenerObj);

            Global.warpClient.Connect(Global.localUsername);

            System.Diagnostics.Debug.WriteLine("after warp");
        }
Beispiel #6
0
 void Start()
 {
     sp = new ServiceAPI (cons.apiKey,cons.secretKey);
 }
 public void SocialConnectWithApp42(string userId, string fbAccessToken)
 {
     sp = AppConstant.GetServce();
      scoreService = AppConstant.GetScoreService(sp);
      storageService = AppConstant.GetStorageService(sp);
      storageService.FindAllDocuments(AppConstant.DBName,AppConstant.CollectionName,this);
      AppConstant.GetInstance().ExecuteGet("https://graph.facebook.com/"+userId);
 }
	void Start () {
		api = new ServiceAPI(API_KEY, SECRET_KEY);  
		scoreBoardService = api.BuildScoreBoardService();    
	}
 //Sends push to a given user
 void SendPushToUser(string userName,string message)
 {
     ServiceAPI serviceAPI = new ServiceAPI(api_key,secret_key);
     PushNotificationService pushService = serviceAPI.BuildPushNotificationService();
     pushService.SendPushMessageToUser(userName,message);
 }
 //Registers a user with the given device token to APP42 push notification service
 void registerDeviceTokenToApp42PushNotificationService(string devToken,string userName)
 {
     ServiceAPI serviceAPI = new ServiceAPI(api_key,secret_key);
     PushNotificationService pushService = serviceAPI.BuildPushNotificationService();
     pushService.StoreDeviceToken(userName,devToken,"iOS");
 }
 void Awake()
 {
     instance = this;
     serviceAPI = new ServiceAPI (App42Manager.Instance.API_KEY, App42Manager.Instance.SECRET_KEY);
 }
 //=============================GUI_CONTENT===========================================
 // Use this for initialization
 void Start()
 {
     sp = new ServiceAPI("YOUR_API_KEY","YOUR_SECRET_KEY");
     uploadService = sp.BuildUploadService(); // Initializing Upload Service.
 }
 public static StorageService GetStorageService(ServiceAPI sp)
 {
     return sp.BuildStorageService();
 }
 public static ScoreBoardService GetScoreService(ServiceAPI sp)
 {
     return sp.BuildScoreBoardService();
 }