public void HelloWorldWithConnectionString() { var connectionString = TestEnvironment.ConnectionString; var serviceClient = new WebPubSubServiceClient(connectionString, "some_hub"); serviceClient.SendToAll("Hello World!"); }
public void HelloWorld() { var connectionString = TestEnvironment.ConnectionString; #region Snippet:WebPubSubHelloWorld var serviceClient = new WebPubSubServiceClient(connectionString, "some_hub"); serviceClient.SendToAll("Hello World!"); #endregion }
public void HelloWorld() { var endpoint = TestEnvironment.Endpoint; var key = TestEnvironment.Key; #region Snippet:WebPubSubHelloWorld var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key)); serviceClient.SendToAll("Hello World!"); #endregion }
public void BinaryMessage() { var connectionString = TestEnvironment.ConnectionString; #region Snippet:WebPubSubSendBinary var serviceClient = new WebPubSubServiceClient(connectionString, "some_hub"); Stream stream = BinaryData.FromString("Hello World!").ToStream(); serviceClient.SendToAll(RequestContent.Create(stream), ContentType.ApplicationOctetStream); #endregion }
public void BinaryMessage() { var endpoint = TestEnvironment.Endpoint; var key = TestEnvironment.Key; #region Snippet:WebPubSubSendBinary var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key)); Stream stream = BinaryData.FromString("Hello World!").ToStream(); serviceClient.SendToAll(RequestContent.Create(stream), ContentType.ApplicationOctetStream); #endregion }
static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: publisher <endpoint> <key> <hub>"); return; } var endpoint = args[0]; var key = args[1]; var hub = args[2]; // Either generate the token or fetch it from server or fetch a temp one from the portal var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), hub, new Azure.AzureKeyCredential(key)); serviceClient.SendToAll(new string(Enumerable.Repeat('c', 2038).ToArray())); }
public void JsonMessage() { var connectionString = TestEnvironment.ConnectionString; #region Snippet:WebPubSubSendJson var serviceClient = new WebPubSubServiceClient(connectionString, "some_hub"); serviceClient.SendToAll(RequestContent.Create( new { Foo = "Hello World!", Bar = 42 }), ContentType.ApplicationJson); #endregion }
static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: publisher <connectionString> <hub> <message>"); return; } var connectionString = args[0]; var hub = args[1]; var message = args[2]; // Either generate the token or fetch it from server or fetch a temp one from the portal var serviceClient = new WebPubSubServiceClient(connectionString, hub); serviceClient.SendToAll(message); }
public void JsonMessage() { var endpoint = TestEnvironment.Endpoint; var key = TestEnvironment.Key; #region Snippet:WebPubSubSendJson var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key)); serviceClient.SendToAll(RequestContent.Create( new { Foo = "Hello World!", Bar = 42 }), ContentType.ApplicationJson); #endregion }
public void ReverseProxyEndpointRedirection() { var mockResponse = new MockResponse(202); var transport = new MockTransport(mockResponse); var wpsEndpoint = "https://wps.contoso.com/"; var apimEndpoint = "https://apim.contoso.com/"; var credentail = new AzureKeyCredential("abcdabcdabcdabcdabcdabcdabcdabcd"); var options = new WebPubSubServiceClientOptions(); options.Transport = transport; options.ReverseProxyEndpoint = new Uri(apimEndpoint); var client = new WebPubSubServiceClient(new Uri(wpsEndpoint), "test_hub", credentail, options); var response = client.SendToAll("Hello World!"); Assert.AreEqual(202, response.Status); var requestUri = transport.SingleRequest.Uri.ToUri(); Assert.AreEqual(new Uri(apimEndpoint).Host, requestUri.Host); }