Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 3
0
        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
        }
Ejemplo n.º 5
0
        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
        }
Ejemplo n.º 6
0
        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
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }