diff --git a/ServiceBusJS/Scripts/servicebusjssdk-1.2.js b/ServiceBusJS/Scripts/servicebusjssdk-1.2.js index 5bff876..0c3d0e6 100644 --- a/ServiceBusJS/Scripts/servicebusjssdk-1.2.js +++ b/ServiceBusJS/Scripts/servicebusjssdk-1.2.js @@ -172,6 +172,8 @@ function QueueClient(config) { /// 'sasKey': "**cBg=", /// 'sasKeyName': the name of the key for SAS "device_send_listen", /// 'timeOut': Defines the timeout in seconds in communication with service bus endpoint., + /// 'serviceBusForWindowsServer': Defines if client should connect to local ASB instance, + /// 'serviceBusForWindowsServerDomain': Defines domain of local ASB instance, /// var m_EntityName = "Please provide the queue name. For example 'customer/orders'"; @@ -183,6 +185,10 @@ function QueueClient(config) { var m_SasKeyName = "provide the SAS key name."; + var m_ServiceBusForWindowsServer = false; + + var m_ServiceBusForWindowsServerDomain = null; + m_ServiceNamespace = config.namespace; if (config.name != null) @@ -193,6 +199,10 @@ function QueueClient(config) { m_SasKeyName = config.sasKeyName; if (config.timeOut != null) m_Timeout = config.timeOut; + if (config.serviceBusForWindowsServer != null) + m_ServiceBusForWindowsServer = config.serviceBusForWindowsServer; + if (config.serviceBusForWindowsServerDomain != null) + m_ServiceBusForWindowsServerDomain = config.serviceBusForWindowsServerDomain; if (config.contentType == null) m_ContentType = "application/json"; @@ -203,9 +213,16 @@ function QueueClient(config) { this.brokeredMessage = msg; } + var createBaseUri = function (entityPath) { + if (m_ServiceBusForWindowsServer) { + return m_ServiceBusForWindowsServerDomain + "/" + m_ServiceNamespace + "/" + entityPath; + } else { + return m_ServiceNamespace + ".servicebus.windows.net/" + entityPath; + } + }; var getUri = function (entityName, head) { - var entityUri = "https://" + m_ServiceNamespace + ".servicebus.windows.net/" + entityName; + var entityUri = "https://" + createBaseUri(entityName); var uri; if (head == null) uri = entityUri + "/messages/?timeout=" + m_Timeout; @@ -218,7 +235,7 @@ function QueueClient(config) { // Creates shared access signature token. var getToken = function (entityPath) { - var uri = "http://" + m_ServiceNamespace + ".servicebus.windows.net/" + entityPath; + var uri = "http://" + createBaseUri(entityPath); var endocedResourceUri = encodeURIComponent(uri);