Пример #1
0
 /// <summary>
 /// Authenticate the WAMP session to server.
 /// </summary>
 /// <param name="proxy">The proxy.</param>
 /// <param name="formatter">The formatter.</param>
 /// <param name="authKey">The key of the authentication credentials, something like a user or
 /// application name.</param>
 /// <param name="authExtra">Any extra authentication information.</param>
 /// <param name="authSecret">The secret of the authentication credentials, something like the user
 /// password or application secret key.</param>
 /// <returns>The WampCraPermissions.</returns>
 static WampCraPermissions Authenticate(IWampCraProcedures proxy, IWampFormatter<JToken> formatter, string authKey, IDictionary<string, string> authExtra, string authSecret)
 {
     string challenge = proxy.AuthReq(authKey, authExtra);
     if (string.IsNullOrEmpty(authKey))
     {
         return proxy.Auth(null);
     }
     WampCraChallenge info = formatter.Deserialize<WampCraChallenge>(JObject.Parse(challenge));
     string sig = WampCraHelpers.AuthSignature(challenge, authSecret, info.authextra);
     return proxy.Auth(sig);
 }
 public void Error <TResult>(IWampFormatter <TResult> formatter, TResult details, string error)
 {
     mCaller.CallError(mRequestId, details, error);
 }
 public void Result <TResult>(IWampFormatter <TResult> formatter, ResultDetails details, TResult[] arguments)
 {
     mCaller.Result(mRequestId, details, arguments.Cast <object>().ToArray());
 }
Пример #4
0
 private static IDictionary <string, object> DeserializeDictionary <TMessage>(TMessage details, IWampFormatter <TMessage> formatter)
 {
     return(formatter.Deserialize <IDictionary <string, object> >(details));
 }
Пример #5
0
 public void Event <TMessage>(IWampFormatter <TMessage> formatter, long publicationId, EventDetails details)
 {
     Console.WriteLine("received response with no arguments");
     _callback(null);
 }
 public IWampCancellableInvocation Invoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter,
                                                     InvocationDetails details)
 {
     return(InvokePattern
                (operation => operation.Invoke(caller, formatter, details)));
 }
        protected override IWampCancellableInvocation InnerInvoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
        {
            CancellationTokenSourceInvocation result = null;
            CancellationToken token = CancellationToken.None;

            if (SupportsCancellation)
            {
                CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
                result = new CancellationTokenSourceInvocation(cancellationTokenSource);
                token  = cancellationTokenSource.Token;
            }

            Task task =
                InnerInvokeAsync(caller,
                                 formatter,
                                 details,
                                 arguments,
                                 argumentsKeywords,
                                 token);

            return(result);
        }
Пример #8
0
 public void Error <TMessage>(IWampFormatter <TMessage> formatter, TMessage details, string error, TMessage[] arguments,
                              TMessage argumentsKeywords)
 {
     ErrorUri = error;
 }
Пример #9
0
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments)
 {
     throw new NotImplementedException();
 }
Пример #10
0
 public IWampCancellableInvocation Invoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter,
                                                     InvocationDetails details,
                                                     TMessage[] arguments)
 {
     CancellableInvocation = new MyCancellableInvocation();
     return(CancellableInvocation);
 }
Пример #11
0
 public UnsubscribeRequest(IWampFormatter <TMessage> formatter, long subscriptionId) : base(formatter)
 {
     SubscriptionId = subscriptionId;
 }
Пример #12
0
 public SubscribeRequest(IWampFormatter <TMessage> formatter, IWampRawTopicClientSubscriber subscriber, SubscribeOptions options, string topicUri) :
     base(subscriber, options, topicUri)
 {
     mPendingRequest = new WampPendingRequest <TMessage, IAsyncDisposable>(formatter);
 }
        protected override object[] GetMethodParameters <TMessage>(IWampRawRpcOperationRouterCallback caller, CancellationToken cancellationToken, IWampFormatter <TMessage> formatter, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
        {
            IEnumerable <object> parameters = UnpackParameters(formatter, arguments, argumentsKeywords);

            CallerProgress progress = new CallerProgress(caller, this);

            parameters = parameters.Concat(progress);

            if (SupportsCancellation)
            {
                parameters = parameters.Concat(cancellationToken);
            }

            object[] result = parameters.ToArray();

            return(result);
        }
Пример #14
0
 public IWampCancellableInvocation Invoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails details, TMessage[] arguments)
 {
     return(InnerInvoke(caller, formatter, details, arguments, null));
 }
 public void Setup()
 {
     mFormatter = new JsonFormatter();
 }
Пример #16
0
 protected abstract IWampCancellableInvocation InnerInvoke <TMessage>
     (IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords);
Пример #17
0
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments,
                               IDictionary <string, TMessage> argumentsKeywords)
 {
     throw new NotImplementedException();
 }
 protected abstract Task <object> InvokeAsync <TMessage>
     (IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords, CancellationToken cancellationToken);
Пример #19
0
 public void Error <TMessage>(IWampFormatter <TMessage> formatter, TMessage details, string error)
 {
     throw new NotImplementedException();
 }
        protected override IWampCancellableInvocation InnerInvoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails options, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
        {
            CancellationTokenSourceInvocation result = null;

            try
            {
                CancellationToken token = CancellationToken.None;

                if (SupportsCancellation)
                {
                    CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
                    result = new CancellationTokenSourceInvocation(cancellationTokenSource);
                    token  = cancellationTokenSource.Token;
                }

                Task <object> task =
                    InvokeAsync(caller,
                                formatter,
                                options,
                                arguments,
                                argumentsKeywords,
                                token);

                task.ContinueWith(x => TaskCallback(x, caller));
            }
            catch (WampException ex)
            {
                mLogger.ErrorFormat(ex, "An error occured while calling {0}", this.Procedure);
                IWampErrorCallback callback = new WampRpcErrorCallback(caller);
                callback.Error(ex);
            }

            return(result);
        }
Пример #21
0
 public void Error <TMessage>(IWampFormatter <TMessage> formatter, TMessage details, string error, TMessage[] arguments,
                              TMessage argumentsKeywords)
 {
     throw new NotImplementedException();
 }
 public IWampCancellableInvocation Invoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter,
                                                     InvocationDetails details,
                                                     TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
 {
     return(InvokePattern
                (operation => operation.Invoke(caller, formatter, details, arguments, argumentsKeywords)));
 }
Пример #23
0
 public IWampCancellableInvocation Invoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails details)
 {
     this.Details = details;
     return(null);
 }
Пример #24
0
 public void Event <TMessage>(IWampFormatter <TMessage> formatter, long publicationId, EventDetails details, TMessage[] arguments)
 {
     _callback(arguments);
 }
Пример #25
0
 public IWampCancellableInvocation Invoke <TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter <TMessage> formatter, InvocationDetails details,
                                                     TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
 {
     this.Details = details;
     return(null);
 }
 public void Result <TResult>(IWampFormatter <TResult> formatter, ResultDetails details)
 {
     mCaller.Result(mRequestId, details);
 }
Пример #27
0
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details)
 {
 }
 public void Result <TResult>(IWampFormatter <TResult> formatter, ResultDetails details, TResult[] arguments, IDictionary <string, TResult> argumentsKeywords)
 {
     mCaller.Result(mRequestId, details, arguments.Cast <object>().ToArray(), argumentsKeywords.ToDictionary(x => x.Key, x => (object)x.Value));
 }
Пример #29
0
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments)
 {
 }
 public void Error <TResult>(IWampFormatter <TResult> formatter, TResult details, string error, TResult[] arguments)
 {
     mCaller.CallError(mRequestId, details, error, arguments.Cast <object>().ToArray());
 }
Пример #31
0
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments,
                               IDictionary <string, TMessage> argumentsKeywords)
 {
 }
Пример #32
0
 public void Error <TMessage>(IWampFormatter <TMessage> formatter, TMessage details, string error)
 {
     ErrorUri = error;
 }
Пример #33
0
 public void Setup()
 {
     mFormatter = new JsonFormatter();
     mMessageFormatter = new JsonWampMessageFormatter();
 }