/// <summary> /// Subscribe to a feed, getting the Subscription Id assigned to that feed /// </summary> /// <param name="Destination"> /// What destination to subscribe to /// </param> /// <returns> /// A unique Id for this subscription /// </returns> public string Subscribe(string Destination) { if (_Subscriptions.ContainsKey(Destination)) { return(_Subscriptions[Destination]); } Random RNG = new Random(_NumSubscriptions++); string Id; do { Id = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}", RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z')); } while (_Subscriptions.ContainsValue(Id)); StompSubscribeFrame Frame = new StompSubscribeFrame(Destination, Id); SendFrame(Frame); _Subscriptions[Destination] = Id; return(Id); }
/// <summary> /// Subscribe to a feed, getting the Subscription Id assigned to that feed /// </summary> /// <param name="Destination"> /// What destination to subscribe to /// </param> /// <returns> /// A unique Id for this subscription /// </returns> public string Subscribe(string Destination) { if (_Subscriptions.ContainsKey(Destination)) return _Subscriptions[Destination]; Random RNG = new Random(_NumSubscriptions++); string Id; do { Id = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}", RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z'), RNG.Next('a', 'Z')); } while (_Subscriptions.ContainsValue(Id)); StompSubscribeFrame Frame = new StompSubscribeFrame(Destination, Id); SendFrame(Frame); _Subscriptions[Destination] = Id; return Id; }