Represents a subscription to a hub method.
Ejemplo n.º 1
0
		public Subscription SubscribeGcm(string registrationId, Subscription sub, out HttpStatusCode code, out string message)
        {
            sub.ChannelType = ChannelType.Android;
            sub.ChannelTarget = registrationId;

            return Subscribe(sub, out code, out message);
        }
Ejemplo n.º 2
0
        protected Subscription Subscribe(Subscription subscription, out HttpStatusCode code, out string message )
        {
            if (subscription.ChannelType == ChannelType.SignalR)
                throw new Exception("SignalR should not be subscribed this way");

            subscription.AppId = Token.AppId;
            subscription.OwnerId = Token.UserId;

            return Create(subscription, out code, out message);
        }
Ejemplo n.º 3
0
 public Chat( string username)
 {
     InitializeComponent();
     SendButton.Focusable = false;
     sub = MainWindow.myHub.Subscribe("addMessage");
     sub.Received += args =>
         {
             string message=args[0].ToString();
             SendMessage(message);
         };
     this.userName = username;
     MainWindow.myHub.Invoke("Join", username);
     GetUsers();
 }
Ejemplo n.º 4
0
        private void CreateSubscription(string eventName, Delegate callback, Delegate wherePredicate = null)
        {
            Hubs.Subscription subscription = _hubProxy.Subscribe(eventName);

            Type[] genericArguments = callback.GetType().GetGenericArguments();

            Action <IList <Newtonsoft.Json.Linq.JToken> > handler = args =>
            {
                if (genericArguments.Length == 0)
                {
                    callback.DynamicInvoke();
                }
                else
                {
                    object[] genericArgs = genericArguments
                                           .Select(t => _convertStub.MakeGenericMethod(t))
                                           .Select(
                        (convertMethod, i) =>
                        convertMethod.Invoke(null, new object[] { args[i], _hubProxy.JsonSerializer }))
                                           .ToArray();

                    if (wherePredicate != null)
                    {
                        if ((bool)wherePredicate.DynamicInvoke(genericArgs))
                        {
                            callback.DynamicInvoke(genericArgs);
                        }
                    }
                    else
                    {
                        callback.DynamicInvoke(genericArgs);
                    }
                }
            };

            subscription.Received += handler;

            if (!_subscriptions.ContainsKey(subscription))
            {
                _subscriptions.Add(subscription, handler);
            }
        }
Ejemplo n.º 5
0
		protected Subscription Subscribe(Subscription subscription, out HttpStatusCode code )
		{
			string ignore;
			return Subscribe(subscription, out code, out ignore);
		}
Ejemplo n.º 6
0
		protected Subscription Subscribe(Subscription subscription )
		{
			HttpStatusCode ignore;
			return Subscribe(subscription, out ignore);
		}
Ejemplo n.º 7
0
		public Subscription SubscribeGcm(string registrationId, Subscription sub, out HttpStatusCode code)
		{
			string ignore;
			return SubscribeGcm (registrationId, sub, out code, out ignore);
		}