Пример #1
0
        public IEnumerator PendingSubscriptionsWork()
        {
            /*
             * Sending a message into the channel just after subscription
             * should be received by the client even though the client starts
             * handling the subscription only after the message is already sent.
             */

            // SETUP: establish the SSE connection so that the server
            // will send us the message even though we don't handle the
            // subscription yet. Without an existing connection the message
            // would be buffered on the server.

            CreateClient("completely-different-channel", false);
            yield return(WaitForClientToSettle());

            client = null;

            // now the proper test:

            CreateClient(ChannelParameterOne, true);
            yield return(WaitForClientToSettle());

            yield return(WaitForMessages(1));

            Assert.AreEqual(1, client.receivedMessages.Count);
            Assert.IsInstanceOf <MyMessage>(client.receivedMessages[0]);
            Assert.AreEqual(
                "Message after subscribing",
                ((MyMessage)client.receivedMessages[0]).foo
                );

            yield return(null);
        }
        private void CreateClient()
        {
            var go = new GameObject("MyBroadcastingClient");

            go.SetActive(false);
            client = go.AddComponent <MyBroadcastingClient>();
            client.channelParameter            = "foo";
            client.sendMessageAfterSubscribing = false;
            go.SetActive(true);
        }