コード例 #1
0
 /// <summary>
 /// Inicia el proceso de login del usuario
 /// </summary>
 /// <param name="username">nombre de usuario</param>
 /// <param name="password">contraseña</param>
 /// <param name="callback">callback para eventos de errores y exito</param>
 public async void LogIn(string username, string password, ResultCallback<User> callback = null)
 {
     if (callback == null)
         callback = new ResultCallback<User>();
     try
     {
         var user = await new ServerTokenAuth().LogInAsync(username, password);
         if (user != null)
         {
             if (PermissionManager.Instance.HasAdminAccessPermission(user))
             {
                 UserDAL.CurrentUser = AuthTokenProtect.ProtectToken(user);
                 RaisePropertyChanged("CurrentLoggedUser");
                 callback.OnSuccess(this, user);
                 return;
             }
             else callback.AddErrors(new PermissionException(user, Permission.ADMIN_ACCESS));
         }
     }
     catch (ApiException e)
     {
         callback.AddErrors(RestErrorInterpreter.InterpretError(e));
     }
     catch (HttpRequestException)
     {
         callback.AddErrors(new ServerConnectException());
     }
     callback.OnFailure(this);
 }
コード例 #2
0
ファイル: Reactor.cs プロジェクト: gregorypilar/interlace
        public void AddPermanentHandle(WaitHandle handle, ResultCallback callback, int integerState, object state)
        {
            ReactorSlot slot = new ReactorSlot();
            slot.Result = null;
            slot.Callback = callback;
            slot.State = state;
            slot.IsPermanent = true;

            slot.Handle = handle;

            if (_slotsInUse) throw new InvalidOperationException("Cross-thread use of a reactor detected.");

            _slots.Add(slot);
        }
コード例 #3
0
        public void T00_TelnetSuccess()
        {
            ProtocolServiceTestPlugin.Instance.Reset();

            ITCPParameter tcp = _protocolService.CreateDefaultTelnetParameter();
            tcp.Destination = GetTelnetConnectableHost();
            Assert.AreEqual(23, tcp.Port);

            ResultCallback client = new ResultCallback();
            IInterruptable t = _protocolService.AsyncTelnetConnect(client, tcp);
            client.AssertSuccess();

            ProtocolServiceTestPlugin.Instance.AssertSuccess();
        }
コード例 #4
0
        public void GetTweets(ResultCallback<Response> callback, string query)
        {
            var request = new RestRequest();

            request.AddParameter("q", query);

            _client.ExecuteAsync(request, (RestResponse<Response> restResponse) =>
                                             {
                                                 if (restResponse.ErrorException != null)
                                                     callback(new Result<Response>(restResponse.ErrorException));
                                                 else
                                                     callback(new Result<Response>(restResponse.Data));
                                             }

                );
        }
コード例 #5
0
        public IEnumerator CreateChannel(string @namespace, string userId, string accessToken, string channelName, ResultCallback <UGCChannelResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't create channel! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't create channel! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create channel! AccessToken parameter is null!");
            Assert.IsNotNull(channelName, "Can't create channel! channelName parameter is null!");

            var request = HttpRequestBuilder
                          .CreatePost(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/channels")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(string.Format("{{ \"name\": \"{0}\" }}", channelName))
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <UGCChannelResponse>();

            callback.Try(result);
        }
コード例 #6
0
ファイル: Reactor.cs プロジェクト: gregorypilar/interlace
 public void AddResult(IAsyncResult result, ResultCallback callback, int integerState)
 {
     AddResult(result, callback, integerState, null);
 }
コード例 #7
0
 /// <summary>
 /// Send get friendship status request.
 /// </summary>
 /// <param name="userId">Targeted user ID.</param>
 /// <param name="callback">Result of the function with an enum of relationship status code.</param>
 public void GetFriendshipStatus(string userId, ResultCallback <FriendshipStatus> callback)
 {
     this.SendRequest(MessageType.getFriendshipStatusRequest, new TargetedUserId {
         friendId = userId
     }, callback);
 }
コード例 #8
0
        public IEnumerator GrantUserEntitlement(string @namespace, string userId, string accessToken,
                                                GrantUserEntitlementRequest[] grantUserEntitlementsRequest, ResultCallback <StackableEntitlementInfo[]> callback)
        {
            Assert.IsNotNull(@namespace, nameof(@namespace) + " cannot be null");
            Assert.IsNotNull(userId, nameof(userId) + " cannot be null");
            Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null");
            Assert.IsNotNull(grantUserEntitlementsRequest, nameof(grantUserEntitlementsRequest) + " cannot be null");

            var request = HttpRequestBuilder
                          .CreatePost(this.baseUrl + "/admin/namespaces/{namespace}/users/{userId}/entitlements")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBody(grantUserEntitlementsRequest.ToUtf8Json())
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpWorker.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <StackableEntitlementInfo[]>();

            callback.Try(result);
        }
コード例 #9
0
 /// <summary>
 /// Send load friends list request.
 /// </summary>
 /// <param name="callback">Returns a Result that contains Friends via callback when completed.</param>
 public void LoadFriendsList(ResultCallback <Friends> callback)
 {
     Report.GetFunctionLog(this.GetType().Name);
     SendRequest(MessageType.listOfFriendsRequest, callback);
 }
コード例 #10
0
 /// <summary>
 /// Send reject friend request.
 /// </summary>
 /// <param name="userId">Targeted user ID.</param>
 /// <param name="callback">Result of the function.</param>
 public void RejectFriend(string userId, ResultCallback callback)
 {
     this.SendRequest(MessageType.rejectFriendsRequest, new TargetedUserId {
         friendId = userId
     }, callback);
 }
コード例 #11
0
        /// <summary>
        /// Get the content of the legal document.
        /// </summary>
        /// <param name="url">The url of the legal document, you can get it from GetLegalPolicies query</param>
        /// <param name="callback">Returns a Result that contains a string via callback when completed</param>
        public void GetLegalDocument(string url, ResultCallback <string> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);

            coroutineRunner.Run(api.GetLegalDocument(url, callback));
        }
コード例 #12
0
        private void SSHBadPassword(SSHProtocol sshprotocol) {
            ProtocolServiceTestPlugin.Instance.Reset();

            ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter();
            ssh.Method = sshprotocol;
            ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account");
            ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_wrongpassword");
            ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));
            tcp.Destination = GetSSHConnectableHost();
            Assert.AreEqual(22, tcp.Port);

            ResultCallback client = new ResultCallback();
            IInterruptable t = _protocolService.AsyncSSHConnect(client, ssh);
            client.AssertFail();

            ProtocolServiceTestPlugin.Instance.AssertFail();
            Socket s = ((InterruptableConnector)t).RawSocket;
            Assert.IsFalse(s.Connected);
        }
コード例 #13
0
        public IEnumerator ModifyContent(string @namespace, string userId, string accessToken, string channelId, string contentId, UGCRequest modifyRequest, ResultCallback <UGCResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't modify content! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't modify content! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't modify content! AccessToken parameter is null!");
            Assert.IsNotNull(channelId, "Can't modify content! channelId parameter is null!");
            Assert.IsNotNull(contentId, "Can't modify content! name parameter is null!");
            Assert.IsNotNull(modifyRequest, "Can't modify content! type parameter is null!");

            UGCRequest Req = modifyRequest;

            if (string.IsNullOrEmpty(Req.contentType))
            {
                Req.contentType = "application/octet-stream";
            }

            var request = HttpRequestBuilder
                          .CreatePut(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/channels/{channelId}/contents/s3/{contentId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("channelId", channelId)
                          .WithPathParam("contentId", contentId)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(Req.ToUtf8Json())
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <UGCResponse>();

            callback.Try(result);
        }
コード例 #14
0
        /// <summary>
        /// Sign multiple user's legal eligibility documents.
        /// </summary>
        /// <param name="acceptAgreementRequests">Signed agreements</param>
        /// <param name="callback">Returns a Result that contains an AcceptAgreementResponse via callback when completed</param>
        public void BulkAcceptPolicyVersions(AcceptAgreementRequest[] acceptAgreementRequests, ResultCallback <AcceptAgreementResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);

            if (session == null || session.AuthorizationToken == null)
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);
                return;
            }

            coroutineRunner.Run(
                api.BulkAcceptPolicyVersions(session.AuthorizationToken, acceptAgreementRequests, callback));
        }
コード例 #15
0
        public IEnumerator CreateContent(string @namespace, string userId, string accessToken, string channelId, string name, string type, string subtype,
                                         string[] tags, byte[] preview, string fileExtension, ResultCallback <UGCResponse> callback, string contentType)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't create content! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't create content! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create content! AccessToken parameter is null!");
            Assert.IsNotNull(channelId, "Can't create content! channelId parameter is null!");
            Assert.IsNotNull(name, "Can't create content! name parameter is null!");
            Assert.IsNotNull(type, "Can't create content! type parameter is null!");
            Assert.IsNotNull(subtype, "Can't create content! subType parameter is null!");
            Assert.IsNotNull(tags, "Can't create content! tags parameter is null!");
            Assert.IsNotNull(preview, "Can't create content! preview parameter is null!");
            Assert.IsNotNull(fileExtension, "Can't create content! fileExtension parameter is null!");

            UGCRequest createRequest = new UGCRequest
            {
                name          = name,
                type          = type,
                subtype       = subtype,
                tags          = tags,
                preview       = System.Convert.ToBase64String(preview),
                fileExtension = fileExtension,
                contentType   = contentType
            };

            yield return(CreateContent(@namespace, userId, accessToken, channelId, createRequest, callback));
        }
コード例 #16
0
        public IEnumerator DeleteChannel(string @namespace, string userId, string accessToken, string channelId, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't delete channel! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't delete channel! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't delete channel! AccessToken parameter is null!");
            Assert.IsNotNull(channelId, "Can't delete channel! ChannelId parameter is null!");

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/channels/{channelId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("channelId", channelId)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParse();

            callback.Try(result);
        }
コード例 #17
0
        public IEnumerator GetChannels(string @namespace, string userId, string accessToken, ResultCallback <UGCChannelPagingResponse> callback, int offset, int limit)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get channels! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get channels! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get channels! AccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/channels")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithQueryParam("offset", offset.ToString())
                          .WithQueryParam("limit", limit.ToString())
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <UGCChannelPagingResponse>();

            callback.Try(result);
        }
コード例 #18
0
ファイル: Reactor.cs プロジェクト: gregorypilar/interlace
 public void AddHandle(WaitHandle handle, ResultCallback callback, int integerState)
 {
     AddHandle(handle, callback, integerState, null);
 }
コード例 #19
0
        /// <summary>
        /// Retrieve all active latest policies based on a namespace.
        /// The country will be read from user token.
        /// </summary>
        /// <param name="namespace">Filter the responded policy by namespace</param>
        /// <param name="agreementPolicyType">Filter the responded policy by policy type. Choose the AgreementPolicyType.EMPTY if you want to be responded with all policy type.</param>
        /// <param name="defaultOnEmpty">Specify with true if you want to be responded with default country-specific policy if your requested country is not exist.</param>
        /// <param name="callback">Returns a Result that contains an array of public policy via callback when completed</param>
        public void GetLegalPolicies(string namespace_, AgreementPolicyType agreementPolicyType, string[] tags, bool defaultOnEmpty, ResultCallback <PublicPolicy[]> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);

            if (session == null || session.AuthorizationToken == null)
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);
                return;
            }

            coroutineRunner.Run(
                api.GetLegalPolicies(namespace_, agreementPolicyType, tags, defaultOnEmpty, session.AuthorizationToken, callback));
        }
コード例 #20
0
        public IEnumerator GetContentByShareCode(string @namespace, string accessToken, string shareCode, ResultCallback <UGCContentResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get content by share code! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get content by share code! AccessToken parameter is null!");
            Assert.IsNotNull(shareCode, "Can't get content by share code! ShareCoded parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/contents/sharecodes/{shareCode}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("shareCode", shareCode)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <UGCContentResponse>();

            callback.Try(result);
        }
コード例 #21
0
 /// <summary>
 /// Retrieve all active latest policies based on a namespace.
 /// The country will be read from user token.
 /// </summary>
 /// <param name="namespace">Filter the responded policy by namespace</param>
 /// <param name="agreementPolicyType">Filter the responded policy by policy type. Choose the AgreementPolicyType.EMPTY if you want to be responded with all policy type.</param>
 /// <param name="defaultOnEmpty">Specify with true if you want to be responded with default country-specific policy if your requested country is not exist.</param>
 /// <param name="callback">Returns a Result that contains an array of public policy via callback when completed</param>
 public void GetLegalPolicies(string namespace_, AgreementPolicyType agreementPolicyType, bool defaultOnEmpty, ResultCallback <PublicPolicy[]> callback)
 {
     string[] tags = new string[1];
     this.GetLegalPolicies(namespace_, agreementPolicyType, tags, defaultOnEmpty, callback);
 }
コード例 #22
0
 public ThrowBangResponseHandler(Player requested, Player causedBy, ResultCallback callback = null)
     : base(RequestType.ThrowBang, requested, causedBy)
 {
     this.callback = callback;
 }
コード例 #23
0
 /// <summary>
 /// Retrieve all active latest policies based on game namespace.
 /// The country will be read from user token.
 /// </summary>
 /// <param name="agreementPolicyType">Filter the responded policy by policy type. Choose the AgreementPolicyType.EMPTY if you want to be responded with all policy type.</param>
 /// <param name="tags">Filter the responded policy by tags.</param>
 /// <param name="defaultOnEmpty">Specify with true if you want to be responded with default country-specific policy if your requested country is not exist.</param>
 /// <param name="callback">Returns a Result that contains an array of public policy via callback when completed</param>
 public void GetLegalPolicies(AgreementPolicyType agreementPolicyType, string[] tags, bool defaultOnEmpty, ResultCallback <PublicPolicy[]> callback)
 {
     this.GetLegalPolicies(@namespace, agreementPolicyType, tags, defaultOnEmpty, callback);
 }
コード例 #24
0
 /// <summary>
 /// Send list of incoming friends request.
 /// </summary>
 /// <param name="callback">Result of the function with an array of user ID.</param>
 public void ListIncomingFriends(ResultCallback <ListIncomingFriends> callback)
 {
     this.SendRequest(MessageType.listIncomingFriendsRequest, callback);
 }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RegisteredResultCallback"/> class.
 /// </summary>
 /// <param name="filter">
 /// The filter.
 /// </param>
 /// <param name="callback">
 /// The callback.
 /// </param>
 internal RegisteredResultCallback(ResultFilter filter, ResultCallback callback)
 {
     this.Filter = filter;
     this.Callback = callback;
 }
コード例 #26
0
 /// <summary>
 /// Send load friends list request.
 /// </summary>
 /// <param name="callback">Result of the function with an array of user ID.</param>
 public void LoadFriendsList(ResultCallback <FriendList> callback)
 {
     this.SendRequest(MessageType.listOfFriendsRequest, callback);
 }
コード例 #27
0
        public IEnumerator GetContentPreview(string @namespace, string userId, string accessToken, string contentId, ResultCallback <UGCPreview> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get content! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get content! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get content! AccessToken parameter is null!");
            Assert.IsNotNull(contentId, "Can't get content! contentId parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/contents/{contentId}/preview")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("contentId", contentId)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <UGCPreview>();

            callback.Try(result);
        }
コード例 #28
0
        public void UpdateGameProfileAttribute(string profileId, GameProfileAttribute attribute, ResultCallback <GameProfile> callback)
        {
            if (!this.user.IsLoggedIn)
            {
                callback.Try(Result <GameProfile> .CreateError(ErrorCode.IsNotLoggedIn, "User is not logged in"));
                return;
            }

            this.taskDispatcher.Start(
                Task.Retry(
                    cb => this.api.UpdateGameProfileAtrribute(this.user.Namespace, this.user.UserId,
                                                              this.user.AccessToken, profileId, attribute, result => cb(result)),
                    result => this.coroutineRunner.Run(() => callback((Result <GameProfile>)result)),
                    this.user));
        }
コード例 #29
0
        /// <summary>
        /// Send the HTTP request tot he API endpoint using the passed parameters.
        /// @param serviceUrl Path component of the event destination
        /// @param params Parameters of the API request
        /// </summary>
        /// TODO
        private bool sendHTTPRequest(string 			serviceUrl, 
		                              WWWForm 			param, 
		                              ResultCallback 	resultCallback)
        {
            WebPlayerDebugManager.addOutput("HTTP call initialized", 1);
            // skip requests if there's no base URL
            if (_serviceBaseUrl.Length == 0)
            {
                WebPlayerDebugManager.addOutput("No base URL. HTTP call skipped", 3);
                Log.GameTimes("No base URL. HTTP call skipped");
                return false;
            }

            // skip requests if the session token is set to -1 (offline mode)
            if ((_sessionToken == "-1") && (_protocol != "file://"))
            {
                WebPlayerDebugManager.addOutput("Session token is -1 " +
                                                "(offline). HTTP call skipped", 3);
                return false;
            }

            string url = _protocol + _serviceBaseUrl + serviceUrl;
            //WebPlayerDebugManager.addOutput ("DBModule Request-URL: " + url+"?"+System.Text.Encoding.Default.GetString(param.data), 4);
            Log.GameTimes("DBModule Request-URL: " + url+"?"+System.Text.Encoding.Default.GetString(param.data));
            //http://takomat-bb-dev.stage.endertech.net/api.php/event/game/save?gameData=abc&sessionToken=gfd6tba4d52h9f6n0mdeu8pl36%7c7bacab5a

            StartCoroutine(request(url, param, resultCallback));

            //always true, Error Message in coroutine
            return true;
        }
コード例 #30
0
        /// <summary>
        /// Retrieve all active latest policies based on a namespace and country.
        /// The country will be read from user token.
        /// </summary>
        /// <param name="defaultOnEmpty">Specify with true if you want to be responded with default country-specific policy if your requested country is not exist.</param>
        /// <param name="agreementPolicyType">Filter the responded policy by policy type. Choose the AgreementPolicyType.EMPTY if you want to be responded with all policy type.</param>
        /// <param name="callback">Returns a Result that contains an array of public policy via callback when completed</param>
        public void GetLegalPoliciesByCountry(string countryCode, AgreementPolicyType agreementPolicyType, bool defaultOnEmpty, ResultCallback <PublicPolicy[]> callback)
        {
            string[] tags = new string[1];

            this.GetLegalPoliciesByCountry(countryCode, agreementPolicyType, tags, defaultOnEmpty, callback);
        }
コード例 #31
0
        public IEnumerator GetContentPreview(string @namespace, string userId, string accessToken, string contentId, ResultCallback <byte[]> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get content! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get content! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get content! AccessToken parameter is null!");
            Assert.IsNotNull(contentId, "Can't get content! contentId parameter is null!");

            yield return(GetContentPreview(@namespace, userId, accessToken, contentId, result =>
            {
                if (result.IsError)
                {
                    callback.TryError(result.Error);
                    return;
                }
                byte[] bytes = System.Convert.FromBase64String(result.Value.preview);
                callback.TryOk(bytes);
            }));
        }
コード例 #32
0
 /// <summary>
 /// Login as an application (client) with client credentials
 /// </summary>
 public void LoginWithClientCredentials(ResultCallback callback)
 {
     Report.GetFunctionLog(this.GetType().Name);
     this.coroutineRunner.Run(this.session.LoginWithClientCredentials(callback));
 }
コード例 #33
0
 /// <summary>
 /// Get party information (leader, members, invitation token)
 /// </summary>
 /// <param name="callback">Returns a Result that contains PartyInfo via callback when completed.</param>
 public void GetPartyInfo(ResultCallback <PartyInfo> callback)
 {
     this.SendRequest(MessageType.partyInfoRequest, callback);
 }
コード例 #34
0
        /// <summary>
        /// 
        /// </summary>
        private IEnumerator request(string 		url, 
		                             WWWForm 		param,
		                             ResultCallback resultCallback)
        {
            WebPlayerDebugManager.addOutput("request initialized.", 4);
            WWW service = new WWW(url, param);
            yield return service;

            //To make sure the data is available
            yield return new WaitForSeconds (0.5f);
            if (!string.IsNullOrEmpty (service.error))
            {
                WebPlayerDebugManager.addOutput("Error loading Data.", 4);
                onHTTPServiceFault(service);
                yield break;
            }
            else
            {
                WebPlayerDebugManager.addOutput("Data will be loaded.", 4);
                onHTTPServiceResult(service);
                resultCallback(service);
                yield break;
            }
        }
コード例 #35
0
 /// <summary>
 /// Create a party and become a party leader for the party.
 /// </summary>
 /// <param name="callback">Returns a Result that contain PartyInfo via callback when completed.</param>
 public void CreateParty(ResultCallback <PartyInfo> callback)
 {
     this.SendRequest(MessageType.partyCreateRequest, callback);
 }
コード例 #36
0
ファイル: Reactor.cs プロジェクト: gregorypilar/interlace
        public void AddResult(IAsyncResult result, ResultCallback callback, int integerState, object state)
        {
            ReactorSlot slot = new ReactorSlot();
            slot.Result = result;
            slot.Callback = callback;
            slot.State = state;
            slot.IsPermanent = false;

            slot.Handle = slot.Result.AsyncWaitHandle;

            if (_slotsInUse) throw new InvalidOperationException("Cross-thread use of a reactor detected.");

            _slots.Add(slot);
        }
コード例 #37
0
 /// <summary>
 /// Leave a party a current logged in user is in.
 /// </summary>
 /// <param name="callback">Returns a Result via callback when completed</param>
 public void LeaveParty(ResultCallback callback)
 {
     this.SendRequest(MessageType.partyLeaveRequest, callback);
 }
コード例 #38
0
ファイル: Reactor.cs プロジェクト: gregorypilar/interlace
 public void AddResult(IAsyncResult result, ResultCallback callback)
 {
     AddResult(result, callback, 0, null);
 }
コード例 #39
0
 /// <summary>
 /// Invite other user by userId. Only party leader (creator) can invite other user.
 /// </summary>
 /// <param name="userId">User Id of a person to be invited to </param>
 /// <param name="callback">Returns a Result via callback when completed</param>
 public void InviteToParty(string userId, ResultCallback callback)
 {
     this.SendRequest(MessageType.partyInviteRequest, new PartyInviteRequest {
         friendID = userId
     }, callback);
 }
コード例 #40
0
ファイル: Reactor.cs プロジェクト: gregorypilar/interlace
 public void AddHandle(WaitHandle handle, ResultCallback callback)
 {
     AddHandle(handle, callback, 0, null);
 }
コード例 #41
0
 /// <summary>
 /// Kick a member out of our party. Only a party leader can kick a party member.
 /// </summary>
 /// <param name="userId">User Id of the user to be kicked out of party</param>
 /// <param name="callback">Returns a Result via callback when completed.</param>
 public void KickPartyMember(string userId, ResultCallback callback)
 {
     this.SendRequest(MessageType.partyKickRequest, new PartyKickRequest {
         memberID = userId
     }, callback);
 }
コード例 #42
0
ファイル: ResultHandler.cs プロジェクト: Lavan/DdpNet
 /// <summary>
 /// Registers a callback. This will be called when the result of a function is found that matches the filter
 /// </summary>
 /// <param name="filter">
 /// The filter to determine the matching result
 /// </param>
 /// <param name="callback">
 /// The function to call when the result is received
 /// </param>
 public void RegisterResultCallback(ResultFilter filter, ResultCallback callback)
 {
     if (!this.callbacks.TryAdd(new RegisteredResultCallback(filter, callback), 0))
     {
         throw new InvalidOperationException("Could not register callback");
     }
 }
コード例 #43
0
 /// <summary>
 /// Send chat to other party members
 /// </summary>
 /// <param name="chatMessage">Message to send to party</param>
 /// <param name="callback">Returns a Result via callback when completed</param>
 public void SendPartyChat(string chatMessage, ResultCallback callback)
 {
     this.SendRequest(MessageType.partyChatRequest, new PartyChatRequest {
         payload = chatMessage
     }, callback);
 }
コード例 #44
0
        public void T05_DenyHostKey() {
            ProtocolServiceTestPlugin.Instance.Reset();
            ProtocolServiceTestPlugin.Instance.AcceptsHostKey = false;

            ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter();
            ssh.Method = SSHProtocol.SSH2;
            ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account");
            ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_password");
            ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));
            tcp.Destination = GetSSHConnectableHost();
            Assert.AreEqual(22, tcp.Port);

            ResultCallback client = new ResultCallback();
            IInterruptable t = _protocolService.AsyncSSHConnect(client, ssh);
            client.AssertFail();

            ProtocolServiceTestPlugin.Instance.AssertFail();
            ProtocolServiceTestPlugin.Instance.AcceptsHostKey = true;
        }
コード例 #45
0
 /// <summary>
 /// Get a list of friends status (availability, activity, last seen at)
 /// </summary>
 /// <param name="callback"></param>
 public void ListFriendsStatus(ResultCallback <FriendsStatus> callback)
 {
     this.SendRequest(MessageType.friendsStatusRequest, callback);
 }
コード例 #46
0
 public void StartExecute(string statement, ResultCallback callback)
 {
     var result = Execute(statement);
     callback(result);
 }
コード例 #47
0
 /// <summary>
 ///  Ask lobby to send all pending notification to user. Listen to OnNotification.
 /// </summary>
 /// <param name="callback">Returns a Result via callback when completed.</param>
 public void PullAsyncNotifications(ResultCallback callback)
 {
     Report.GetFunctionLog(this.GetType().Name);
     SendRequest(MessageType.offlineNotificationRequest, callback);
 }