当前位置: 首页>>代码示例>>C#>>正文


C# OperationRequest.ToString方法代码示例

本文整理汇总了C#中OperationRequest.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# OperationRequest.ToString方法的具体用法?C# OperationRequest.ToString怎么用?C# OperationRequest.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OperationRequest的用法示例。


在下文中一共展示了OperationRequest.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleAuthenticate

        public OperationResponse HandleAuthenticate(OperationRequest operationRequest, SendParameters sendParameters)
        {
            // validate operation request
            var authenticateRequest = new AuthenticateRequest(this.Protocol, operationRequest);
            if (authenticateRequest.IsValid == false)
            {
                return OperationHandlerBase.HandleInvalidOperation(authenticateRequest, log);
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat(
                    "HandleAuthenticateRequest:appId={0};version={1};region={2};type={3};userId={4}",
                    authenticateRequest.ApplicationId,
                    authenticateRequest.ApplicationVersion,
                    authenticateRequest.Region,
                    authenticateRequest.ClientAuthenticationType,
                    authenticateRequest.UserId);
            }

            if (authenticateRequest.ClientAuthenticationType == 255 || !string.IsNullOrEmpty(authenticateRequest.Token))
            {
                var response = this.HandleAuthenticateTokenRequest(authenticateRequest);

                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("HandleAuthenticateRequest - Token Authentication done. Result: {0}; msg={1}", response.ReturnCode, response.DebugMessage);
                }

                if (response.ReturnCode == 0)
                {
                    this.SetCurrentOperationHandler(OperationHandlerDefault.Instance);
                    this.OnAuthSuccess(authenticateRequest);
                }

                return response;
            }

            // if authentication data is used it must be either a byte array or a string value
            if (authenticateRequest.ClientAuthenticationData != null)
            {
                var dataType = authenticateRequest.ClientAuthenticationData.GetType();
                if (dataType != typeof(byte[]) && dataType != typeof(string))
                {
                    if (log.IsDebugEnabled)
                    {
                        log.DebugFormat("HandleAuthenticateRequest - invalid type for auth data (datatype = {0}), request: {1}", dataType, operationRequest.ToString());
                    }

                    return new OperationResponse
                    {
                        OperationCode = operationRequest.OperationCode,
                        ReturnCode = (short)ErrorCode.OperationInvalid,
                        DebugMessage = ErrorMessages.InvalidTypeForAuthData
                    };
                }
            }

            var app = (MasterApplication)ApplicationBase.Instance;

            // check if custom client authentication is required
            if (app.CustomAuthHandler.IsClientAuthenticationEnabled)
            {
                if (app.TokenCreator == null)
                {
                    log.WarnFormat("No custom authentication supported: AuthTokenKey not specified in config.");

                    var response = new OperationResponse(authenticateRequest.OperationRequest.OperationCode)
                    {
                        ReturnCode = (short)ErrorCode.InvalidAuthentication,
                        DebugMessage = ErrorMessages.AuthTokenTypeNotSupported
                    };

                    return response;
                }

                this.SetCurrentOperationHandler(OperationHandlerAuthenticating.Instance);

                var authSettings = new AuthSettings
                                   {
                                       IsAnonymousAccessAllowed = app.CustomAuthHandler.IsAnonymousAccessAllowed,
                                   };

                app.CustomAuthHandler.AuthenticateClient(this, authenticateRequest, authSettings, new SendParameters(), authSettings);
                return null;
            }

            // TBD: centralizing setting of userid
            this.UserId = authenticateRequest.UserId;

            // apply application to the peer
            this.SetCurrentOperationHandler(OperationHandlerDefault.Instance);

            this.OnAuthSuccess(authenticateRequest);

            // publish operation response
            return new OperationResponse(operationRequest.OperationCode);
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:98,代码来源:MasterClientPeer.cs


注:本文中的OperationRequest.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。