Example #1
0
        private void Subscribe()
        {
            var subscribeMessage = new TopicTypeMessage {
                op    = "subscribe",
                topic = clientCountTopic,
                type  = new Int32().GetMessageType()
            };

            SendImmediate(JsonUtility.ToJson(subscribeMessage));
        }
Example #2
0
        async internal void Advertise(string topic, string type)
        {
            await connectionTask;
            var   advertiseMessage = new TopicTypeMessage {
                op    = "advertise",
                topic = topic,
                type  = type
            };

            Send(JsonUtility.ToJson(advertiseMessage));

            advertisedTopics.Add(topic);
        }
Example #3
0
        async internal void Subscribe <T>(string topic, string type, Callback callback) where T : Message
        {
            await connectionTask;
            var   subscribeMessage = new TopicTypeMessage {
                op    = "subscribe",
                topic = topic,
                type  = type
            };

            Send(JsonUtility.ToJson(subscribeMessage));
            if (!subscribedTypes.ContainsKey(topic))
            {
                subscribedTypes.Add(topic, typeof(DataMessage <T>));
            }
            if (!subscribers.ContainsKey(topic))
            {
                subscribers.Add(topic, callback);
            }
        }