static BinaryResourceAccessor() { FetchHandlers = new DictionaryTS <eBinaryResourceLocationType, Func <BinaryResourceDescriptor, byte[]> >(); FetchHandlers.Add(eBinaryResourceLocationType.Http, HttpFetchHandler); FetchHandlers.Add(eBinaryResourceLocationType.RedisDB, RedisDBFetchHandler); }
static BinaryResourceAccessor() { FetchHandlers = new DictionaryTS<eBinaryResourceLocationType, Func<BinaryResourceDescriptor, byte[]>>(); FetchHandlers.Add(eBinaryResourceLocationType.Http, HttpFetchHandler); FetchHandlers.Add(eBinaryResourceLocationType.RedisDB, RedisDBFetchHandler); }
/// <summary> /// Constructor /// </summary> /// <param name="commLayer">Communication layer to use (TCP)</param> /// <param name="settings">Broker settings</param> public MqttBroker(IMqttCommunicationLayer commLayer, MqttSettings settings) { // MQTT broker settings this.settings = settings; // MQTT communication layer this.commLayer = commLayer; this.commLayer.ClientConnected += commLayer_ClientConnected; // create managers (publisher, subscriber, session and UAC) this.subscriberManager = new MqttSubscriberManager(); this.sessionManager = new MqttSessionManager(); this.publisherManager = new MqttPublisherManager(this.subscriberManager, this.sessionManager); this.uacManager = new MqttUacManager(); this.PreClients = new HashSetTS <MqttClient>(); this.Clients = new DictionaryTS <string, MqttClient>(); }
/// <summary> /// Get resource based on given descriptor /// </summary> /// <param name="descriptor"></param> /// <returns></returns> public static byte[] GetResource(BinaryResourceDescriptor descriptor) { byte[] resource = null; try { if (FetchHandlers.ContainsKey(descriptor.LocationType)) { resource = FetchHandlers[descriptor.LocationType](descriptor); } else { DebugEx.TraceError("No handler for resource descriptor of type: " + descriptor.LocationType.ToString()); } } catch (Exception ex) { DebugEx.Assert(ex, "Error getting resource from specified resource descriptor"); } return(resource); }
/// <summary> /// Stop broker /// </summary> public void Stop() { running = false; this.commLayer.Stop(); this.publisherManager.Stop(); // close connection with all clients, in transit ones.. foreach (var client in this.PreClients) { client.Close(); } PreClients.Clear(); PreClients = null; //and "real" ones foreach (var client in this.Clients.Values) { client.Close(); } Clients.Clear(); Clients = null; }
/// <summary> /// Stop broker /// </summary> public void Stop() { running = false; this.commLayer.Stop(); this.publisherManager.Stop(); // close connection with all clients, in transit ones.. foreach (var client in this.PreClients) client.Close(); PreClients.Clear(); PreClients = null; //and "real" ones foreach (var client in this.Clients.Values) client.Close(); Clients.Clear(); Clients = null; }
/// <summary> /// Constructor /// </summary> /// <param name="commLayer">Communication layer to use (TCP)</param> /// <param name="settings">Broker settings</param> public MqttBroker(IMqttCommunicationLayer commLayer, MqttSettings settings) { // MQTT broker settings this.settings = settings; // MQTT communication layer this.commLayer = commLayer; this.commLayer.ClientConnected += commLayer_ClientConnected; // create managers (publisher, subscriber, session and UAC) this.subscriberManager = new MqttSubscriberManager(); this.sessionManager = new MqttSessionManager(); this.publisherManager = new MqttPublisherManager(this.subscriberManager, this.sessionManager); this.uacManager = new MqttUacManager(); this.PreClients = new HashSetTS<MqttClient>(); this.Clients = new DictionaryTS<string, MqttClient>(); }