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); }
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); }
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(); }
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); } }
protected Subscription Subscribe(Subscription subscription, out HttpStatusCode code ) { string ignore; return Subscribe(subscription, out code, out ignore); }
protected Subscription Subscribe(Subscription subscription ) { HttpStatusCode ignore; return Subscribe(subscription, out ignore); }
public Subscription SubscribeGcm(string registrationId, Subscription sub, out HttpStatusCode code) { string ignore; return SubscribeGcm (registrationId, sub, out code, out ignore); }