Exemple #1
0
 /// <summary>
 /// Returns a list of the user's friends.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void ListFriends(int index, RuyiNetTask <RuyiNetListFriendsResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.Script_RunParentScriptAsync("ListFriends", "{}", "RUYI", index, token).Result);
     }, callback);
 }
Exemple #2
0
        /// <summary>
        /// Prepares a video upload.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
        /// <param name="localPath">The path and fileName of the local file.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void UploadVideo(int index, string cloudFilename, string localPath,
                                RuyiNetTask <RuyiNetUploadFileResponse> .CallbackType callback)
        {
            EnqueuePlatformTask(index, () =>
            {
                var response     = mClient.BCService.File_UploadFileAsync(VIDEO_LOCATION, cloudFilename, true, false, localPath, index, token).Result;
                var uploadedFile = JsonConvert.DeserializeObject <RuyiNetUploadFileResponse>(response);

                if (uploadedFile.status == RuyiNetHttpStatus.OK)
                {
                    var cdnResponse = mClient.BCService.File_GetCDNUrlAsync(VIDEO_LOCATION, cloudFilename, index, token).Result;
                    var cdnUrl      = JsonConvert.DeserializeObject <RuyiNetGetCDNResponse>(cdnResponse);
                    if (cdnUrl.status == RuyiNetHttpStatus.OK)
                    {
                        var videoEntity = JsonConvert.SerializeObject(new RuyiNetVideo()
                        {
                            appServerUrl  = cdnUrl.data.appServerUrl,
                            cloudFilename = cloudFilename
                        });

                        var acl = JsonConvert.SerializeObject(new RuyiNetAcl()
                        {
                            other = 1
                        });

                        mClient.BCService.Entity_CreateEntityAsync(VIDEO_LOCATION, videoEntity, acl, index, token).Wait();
                    }
                }

                return(response);
            }, callback);
        }
Exemple #3
0
        /// <summary>
        /// Ends a telemetry event.
        /// </summary>
        /// <param name="clientIndex">The index of the client making the call.</param>
        /// <param name="timestamp">The timestamp when the event occurred.</param>
        /// <param name="sessionId">The ID of the session to End the event with.</param>
        /// <param name="eventType">The type of event.</param>
        /// <param name="participantId">The ID or the participant in the event.</param>
        /// <param name="customData">The custom data to attach to the event.</param>
        /// <param name="callback">The callback to call when the operation is complete.</param>
        public void EndTelemetryEvent(int clientIndex, int timestamp,
                                      string sessionId, string eventType, string participantId,
                                      Dictionary <string, string> customData,
                                      RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                try
                {
                    var data = mClient.BCService.Telemetry_EndTelemetryEvent(
                        sessionId, timestamp, eventType, participantId,
                        customData, clientIndex);
                    return(data);
                }
                catch (Exception e)
                {
#if DEBUG
                    var response = new RuyiNetResponse()
                    {
                        status  = 999,
                        message = e.ToString()
                    };

                    return(JsonConvert.SerializeObject(response));
#else
                    throw;
#endif
                }
            }, callback);
        }
Exemple #4
0
 /// <summary>
 /// Prepares a video download.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void DownloadVideo(int index, string cloudFilename, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EnqueuePlatformTask(index, () =>
     {
         return(mClient.BCService.File_DownloadFileAsync(VIDEO_LOCATION, cloudFilename, true, index, token).Result);
     }, callback);
 }
Exemple #5
0
 /// <summary>
 /// Ends a telemetry event.
 /// </summary>
 /// <param name="clientIndex">The index of the client making the call.</param>
 /// <param name="timestamp">The timestamp when the event occurred.</param>
 /// <param name="sessionId">The ID of the session to End the event with.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="customData">The custom data to attach to the event.</param>
 /// <param name="callback">The callback to call when the operation is complete.</param>
 public void EndTelemetryEvent(int clientIndex, int timestamp,
                               string sessionId, string eventType,
                               Dictionary <string, string> customData,
                               RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EndTelemetryEvent(clientIndex, timestamp, sessionId, eventType, "", customData, callback);
 }
Exemple #6
0
 /// <summary>
 /// Ends a telemetry event.
 /// </summary>
 /// <param name="clientIndex">The index of the client making the call.</param>
 /// <param name="sessionId">The ID of the session to End the event with.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="participantId">The ID or the participant in the event.</param>
 /// <param name="customData">The custom data to attach to the event.</param>
 /// <param name="callback">The callback to call when the operation is complete.</param>
 public void EndTelemetryEvent(int clientIndex, string sessionId,
                               string eventType, string participantId,
                               Dictionary <string, string> customData,
                               RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EndTelemetryEvent(clientIndex, CurrentTimestamp, sessionId, eventType, participantId, customData, callback);
 }
Exemple #7
0
 /// <summary>
 /// List all the current user's videos.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void ListVideos(int index, RuyiNetTask <RuyiNetListUserFilesResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_ListUserFiles_SNSFOAsync(VIDEO_LOCATION, false, index, token).Result);
     }, callback);
 }
 /// <summary>
 /// List all user files.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void ListUserFiles(int index, RuyiNetTask <RuyiNetListUserFilesResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_ListUserFiles_SFO(index));
     }, callback);
 }
 /// <summary>
 /// Removes a user from the player's friend list.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="playerId">The  ID of the player to remove.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void RemoveFriend(int index, string playerId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.Friend_RemoveFriend(playerId, index));
     }, callback);
 }
Exemple #10
0
 /// <summary>
 /// Send an invitation to be friends.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="playerId">The  ID of the player to send the invitation to.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void SendFriendInvitation(int index, string playerId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.Friend_SendFriendInvitation(playerId, index));
     }, callback);
 }
Exemple #11
0
 /// <summary>
 /// Get information on the party members in the current party.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void GetPartyMembersInfo(int index, RuyiNetTask <RuyiNetGetProfilesResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.Script_RunParentScriptAsync("GetPartyMembers", "{}", "RUYI", index, token).Result);
     }, callback);
 }
 /// <summary>
 /// Returns the CDN url for a file object.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudPath">The desired cloud path of the file.</param>
 /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void GetCDNUrl(int index, string cloudPath, string cloudFilename,
                       RuyiNetTask <RuyiNetGetCDNResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_GetCDNUrl(cloudPath, cloudFilename, index));
     }, callback);
 }
 /// <summary>
 /// Deletes multiple user files.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudPath">The desired cloud path of the file.</param>
 /// <param name="recursive">Whether to recurse into sub-directories</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void DeleteUserFiles(int index, string cloudPath, bool recursive,
                             RuyiNetTask <RuyiNetListUserFilesResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_DeleteUserFiles(cloudPath, recursive, index));
     }, callback);
 }
 /// <summary>
 /// Deletes a single user file.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudPath">The desired cloud path of the file.</param>
 /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void DeleteUserFile(int index, string cloudPath, string cloudFilename,
                            RuyiNetTask <RuyiNetUploadFileResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_DeleteUserFile(cloudPath, cloudFilename, index));
     }, callback);
 }
Exemple #15
0
 public void CreateLeaderboard(int index, string id, RuyiNetLeaderboardType type,
                               RuyiNetRotationType rotationType, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     if (callback != null)
     {
         callback(null);
     }
 }
 /// <summary>
 /// List all user files.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudPath">File path.</param>
 /// <param name="recursive">Whether to recurse into sub-directories</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void ListUserFiles(int index, string cloudPath, bool recursive,
                           RuyiNetTask <RuyiNetListUserFilesResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_ListUserFiles_SNSFOAsync(cloudPath, recursive, index, token).Result);
     }, callback);
 }
Exemple #17
0
 /// <summary>
 /// Returns the CDN url for a video.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void GetVideoUrl(int index, string cloudFilename,
                         RuyiNetTask <RuyiNetGetCDNResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_GetCDNUrlAsync(VIDEO_LOCATION, cloudFilename, index, token).Result);
     }, callback);
 }
Exemple #18
0
 /// <summary>
 /// Deletes a video.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void DeleteVideo(int index, string cloudFilename,
                         RuyiNetTask <RuyiNetUploadFileResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_DeleteUserFileAsync(VIDEO_LOCATION, cloudFilename, index, token).Result);
     }, callback);
 }
Exemple #19
0
        /// <summary>
        /// Starts a lobby game
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="lobbyId">The ID of the lobby to start the game for.</param>
        /// <param name="connectionString">A connection string used to connect to the host.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void StartGame(int index, string lobbyId, string connectionString, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            var payload = new RuyiNetLobbyStartGameRequest()
            {
                lobbyId = lobbyId, connectionString = connectionString
            };

            RunPlatformScript(index, "Lobby_StartGame", JsonConvert.SerializeObject(payload), callback);
        }
 /// <summary>
 /// Prepares a user file upload.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="cloudPath">The desired cloud path of the file.</param>
 /// <param name="cloudFilename">The desired cloud fileName of the file.</param>
 /// <param name="shareable">True if the file is shareable.</param>
 /// <param name="replaceIfExists">Whether to replace file if it exists.</param>
 /// <param name="localPath">The path and fileName of the local file.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void UploadFile(int index, string cloudPath, string cloudFilename,
                        bool shareable, bool replaceIfExists, string localPath,
                        RuyiNetTask <RuyiNetUploadFileResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         return(mClient.BCService.File_UploadFile(cloudPath, cloudFilename, shareable, replaceIfExists, localPath, index));
     }, callback);
 }
Exemple #21
0
        /// <summary>
        /// Closes a lobby and kicks all players.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="lobbyId">The ID of the lobby to close.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void CloseLobby(int index, string lobbyId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            mCurrentLobby = null;

            var payload = new RuyiNetLobbyCloseRequest()
            {
                lobbyId = lobbyId
            };

            RunPlatformScript(index, "Lobby_Close", JsonConvert.SerializeObject(payload), callback);
        }
Exemple #22
0
 public void GetProfiles(int index, string[] profileIds, RuyiNetTask <RuyiNetGetProfilesResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         var payload = new RuyiNetProfileIdsRequest()
         {
             profileIds = profileIds
         };
         return(mClient.BCService.Script_RunParentScript("GetProfiles", JsonConvert.SerializeObject(payload), "RUYI", index));
     }, callback);
 }
Exemple #23
0
 public void AddFriend(int index, string profileId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         var payload = new RuyiNetProfileIdRequest()
         {
             profileId = profileId
         };
         return(mClient.BCService.Script_RunParentScript("AddFriend", JsonConvert.SerializeObject(payload), "RUYI", index));
     }, callback);
 }
Exemple #24
0
 /// <summary>
 /// Get the profile of the specified user.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="profileId">The profile ID of the user to get the profile for.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void GetProfile(int index, string profileId, RuyiNetTask <RuyiNetGetProfileResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         var payload = new RuyiNetProfileIdRequest()
         {
             profileId = profileId
         };
         return(mClient.BCService.Script_RunParentScriptAsync("GetProfile", JsonConvert.SerializeObject(payload), "RUYI", index, token).Result);
     }, callback);
 }
Exemple #25
0
        /// <summary>
        /// Reject a party invitation.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="groupId">The group ID of the party to reject.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void RejectPartyInvitation(int index, string groupId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                var payload = new RuyiNetGroupIdRequest()
                {
                    groupId = groupId
                };

                return(mClient.BCService.Script_RunParentScriptAsync("RejectPartyInvitation", JsonConvert.SerializeObject(payload), "RUYI", index, token).Result);
            }, callback);
        }
Exemple #26
0
        /// <summary>
        /// Queue up a request to the online service that needs to be called on the RUYI platform level.
        /// </summary>
        /// <typeparam name="Response">A serialisiable class we can receive the data in.</typeparam>
        /// <param name="index">The index of user</param>
        /// <param name="onExecute">The method to call when we execute the task.</param>
        internal async Task <Response> EnqueuePlatformTask <Response>(int index, RuyiNetTask <Response> .ExecuteType onExecute)
        {
            await BCService.Identity_SwitchToParentProfileAsync("RUYI", index, token);

            var response = await onExecute();

            await BCService.Identity_SwitchToSingletonChildProfileAsync(AppId, false, index, token);

            var data = JsonConvert.DeserializeObject <Response>(response, jsonSerializerSettings);

            return(data);
        }
Exemple #27
0
        /// <summary>
        /// Invite someone to join a party.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="profileId">The profile ID of the player to invite.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void SendPartyInvitation(int index, string profileId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                var payload = new RuyiNetProfileIdRequest()
                {
                    profileId = profileId
                };

                var response = mClient.BCService.Script_RunParentScriptAsync("SendPartyInvitation", JsonConvert.SerializeObject(payload), "RUYI", index, token).Result;
                return(response);
            }, callback);
        }
Exemple #28
0
        /// <summary>
        /// Returns a list of friends videos.
        /// </summary>
        /// <param name="index">The index of the user</param>
        /// <param name="profileId">The profile of the ID to fetch the videos for.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void GetFriendsVideos(int index, string profileId,
                                     RuyiNetTask <RuyiNetGetFriendsVideosResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                var query = JsonConvert.SerializeObject(new VideoQuery()
                {
                    entityType = VIDEO_LOCATION
                });

                return(mClient.BCService.Entity_GetSharedEntitiesListForProfileIdAsync(profileId, query, "{}", 100, index, token).Result);
            }, callback);
        }
Exemple #29
0
        /// <summary>
        /// Retrieves a leaderboard with all the user's friends.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="id">The ID of the leaderboard to retrieve.</param>
        /// <param name="replaceName">If true, the player's name is replaced by the string "You".</param>
        /// <param name="callback">The function to call when the data is retrieved.</param>
        public void GetSocialLeaderboard(int index, string id, bool replaceName,
                                         RuyiNetTask <RuyiNetSocialLeaderboardResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                var data = new RuyiNetGetSocialLeaderboardRequest()
                {
                    leaderboardId = mClient.AppId + "_" + id,
                    replaceName   = replaceName
                };

                return(mClient.BCService.Script_RunParentScriptAsync("GetSocialLeaderboard", JsonConvert.SerializeObject(data), "RUYI", index, token).Result);
            }, callback);
        }
Exemple #30
0
        /// <summary>
        /// Posts a score to the leaderboard for the player.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="id">The ID of the leaderboard to post to.</param>
        /// <param name="score">The score to post.</param>
        /// <param name="callback">The function to call when the data is retrieved.</param>
        public void PostScoreToLeaderboard(int index, string id, int score,
                                           RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                var data = new RuyiNetPostScoreToLeaderboardRequest()
                {
                    leaderboardId = mClient.AppId + "_" + id,
                    score         = score
                };

                return(mClient.BCService.Script_RunParentScriptAsync("PostScoreToLeaderboard", JsonConvert.SerializeObject(data), "RUYI", index, token).Result);
            }, callback);
        }