本文整理汇总了C#中IHubIncomingInvokerContext类的典型用法代码示例。如果您正苦于以下问题:C# IHubIncomingInvokerContext类的具体用法?C# IHubIncomingInvokerContext怎么用?C# IHubIncomingInvokerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHubIncomingInvokerContext类属于命名空间,在下文中一共展示了IHubIncomingInvokerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnIncomingError
protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
{
Console.WriteLine(exceptionContext.Error);
//exceptionContext.Result = "Change the return value, nulls error";
base.OnIncomingError(exceptionContext, invokerContext);
}
示例2: OnBeforeIncoming
/// <summary>
/// 数据传到Hub之前进行数据解密
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
{
//_canCrypto = CanCrypto(context.Hub.Context);
//if (!_canCrypto)
//{
// return base.OnBeforeIncoming(context);
//}
//数据解密
string facePublicKey = context.Hub.Context.Headers.Get(HttpHeaderNames.OSharpClientPublicKey);
if (string.IsNullOrEmpty(facePublicKey))
{
return false;
}
_cryptor = new CommunicationCryptor(_ownPrivateKey, facePublicKey, _hashType);
if (context.Args.Count == 1)
{
string encrypt = (string)context.Args[0];
string json = _cryptor.DecryptAndVerifyData(encrypt);
IList<object> args = JsonConvert.DeserializeObject<IList<object>>(json);
context.Args.Clear();
IList<object> values = context.MethodDescriptor.Parameters.Zip(args, (desc, arg) => ResolveParameter(desc, arg)).ToList();
foreach (object arg in values)
{
context.Args.Add(arg);
}
}
return base.OnBeforeIncoming(context);
}
示例3: AuthorizeHubMethodInvocation
public override bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext, bool appliesToMethod)
{
if (string.IsNullOrWhiteSpace(AuthToken))
return false;
return hubIncomingInvokerContext.Hub.Context.Headers[AuthTokenProvider.AuthTokenKey] == AuthToken;
}
示例4: OnAfterIncoming
protected override object OnAfterIncoming(object result, IHubIncomingInvokerContext context)
{
var startedOn = (DateTime)context.StateTracker["ProfilingHubPipelineModule-Invocation-StartedOn"];
var invocation = new InvocationModel
{
ConnectionId = context.Hub.Context.ConnectionId,
Hub = context.MethodDescriptor.Hub.Name,
Method = context.MethodDescriptor.Name,
StartedOn = startedOn,
EndedOn = DateTime.Now,
Result = new InvocationResultModel
{
Value = result,
Type = context.MethodDescriptor.ReturnType
},
Arguments = context.Args.Count > 0 ? context.Args
.Select((t, i) => new InvocationArgumentModel
{
Value = t,
Name = context.MethodDescriptor.Parameters[i].Name,
Type = context.MethodDescriptor.Parameters[i].ParameterType
})
.ToList() : null
};
PluginSettings.StoreInvocation(invocation);
return base.OnAfterIncoming(result, context);
}
示例5: OnBeforeIncoming
protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
{
#if DEBUG
Debug.WriteLine("=> Invoking " + context.MethodDescriptor.Name + " on hub " + context.MethodDescriptor.Hub.Name);
#endif
return base.OnBeforeIncoming(context);
}
示例6: OnIncomingError
protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext context)
{
if (log.IsErrorEnabled)
{
log.ErrorFormat("Exception while invoking {0} on hub {1}: {2}", context.MethodDescriptor.Name, context.MethodDescriptor.Hub.Name, exceptionContext.Error.Message);
}
base.OnIncomingError(exceptionContext, context);
}
示例7: OnBeforeIncoming
protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
{
if (log.IsDebugEnabled)
{
log.DebugFormat(string.Format("Invoking {0} on hub {1}", context.MethodDescriptor.Name, context.MethodDescriptor.Hub.Name));
}
return base.OnBeforeIncoming(context);
}
示例8: OnBeforeIncoming
protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
{
if (Log.IsDebugEnabled)
{
Log.DebugFormat("=> Invoking " + context.MethodDescriptor.Name + " on hub " + context.MethodDescriptor.Hub.Name);
}
return base.OnBeforeIncoming(context);
}
示例9: OnIncomingError
protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
{
Debug.WriteLine("=> Exception " + exceptionContext.Error.Message);
if (exceptionContext.Error.InnerException != null)
{
Debug.WriteLine("=> Inner Exception " + exceptionContext.Error.InnerException.Message);
}
base.OnIncomingError(exceptionContext, invokerContext);
}
示例10: OnIncomingError
protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext)
{
ChatLog.Debug("=> Exception " + exceptionContext.Error.Message + " " + exceptionContext.Error.StackTrace);
if (exceptionContext.Error.InnerException != null)
{
ChatLog.Debug("=> Inner Exception " + exceptionContext.Error.InnerException.Message + " " + exceptionContext.Error.InnerException.StackTrace);
}
base.OnIncomingError(exceptionContext, invokerContext);
}
示例11: OnIncomingError
protected override void OnIncomingError(ExceptionContext ex, IHubIncomingInvokerContext context)
{
_slabLogger.Log(HubType.HubServerVerbose, "=> Exception " + ex.Error + " " + ex.Result);
if (ex.Error.InnerException != null)
{
_slabLogger.Log(HubType.HubServerVerbose, "=> Inner Exception " + ex.Error.InnerException.Message);
}
base.OnIncomingError(ex, context);
}
示例12: OnIncomingError
protected override void OnIncomingError(ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext) {
_logger.Error()
.Exception(exceptionContext.Error)
.MarkUnhandled("ErrorHandlingPipelineModule")
.Message("Unhandled: {0}", exceptionContext.Error.Message)
.Tag("SignalR")
.Write();
base.OnIncomingError(exceptionContext, invokerContext);
}
示例13: OnBeforeIncoming
protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
{
var id = HttpContext.Current.User.Identity.IsAuthenticated
? "fred"
: string.Empty;
context.Hub.Groups.Add(context.Hub.Context.ConnectionId, id);
return base.OnBeforeIncoming(context);
}
示例14: AuthorizeHubMethodInvocation
public override bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext, bool appliesToMethod)
{
var connectionId = hubIncomingInvokerContext.Hub.Context.ConnectionId;
var environment = hubIncomingInvokerContext.Hub.Context.Request.Environment;
var principal = hubIncomingInvokerContext.Hub.Context.Request.Environment["server.User"] as IPrincipal;
if (principal == null || !principal.Identity.IsAuthenticated) return false;
hubIncomingInvokerContext.Hub.Context = new HubCallerContext(new ServerRequest(environment), connectionId);
return true;
}
示例15: AuthorizeHubMethodInvocation
public bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext)
{
switch (Mode)
{
case AuthorizeMode.Both:
case AuthorizeMode.Incoming:
return UserAuthorized(hubIncomingInvokerContext.Hub.Context.User);
default:
Debug.Assert(Mode == AuthorizeMode.Outgoing); // Guard in case new values are added to the enum
return true;
}
}