// pull old messages from channel and send to the client public void prepopulate_channel(string[] message) { // build prepopulate object prepopulate p = new prepopulate(message); if (protocol.pubsub != null) { // attempt to pull the channel from pubsub PubSub_Channel c = protocol.pubsub.GetChannel(p.channel_name_or_uri); // make sure channel exists and has historical data if (c != null && c.historical) { // build events list based on count List<PubSub_Event> events = c.GetEvents(p.count); // itterate over events and send to client for (int i = 0; i < events.Count; i++) // send the events to the client protocol.SocketSend(new _event(p.channel_name_or_uri, events[i]).ToString()); } } }
public void prepopulate() { // documentation example 1 string input = "[12,\"\\/rss\\/news\\/latest\",50]"; string[] message = JSONDecoders.DecodeJSONArray(input); Assert.AreEqual(message[0], "12"); prepopulate p = new prepopulate(message); Assert.AreEqual(p.channel_name_or_uri, "/rss/news/latest"); Assert.AreEqual(p.count, 50); // documentation example 2 input = "[12,\"\\/rss\\/news\\/latest\",50,41267360]"; message = JSONDecoders.DecodeJSONArray(input); Assert.AreEqual(message[0], "12"); p = new prepopulate(message); Assert.AreEqual(p.channel_name_or_uri, "/rss/news/latest"); Assert.AreEqual(p.count, 50); Assert.AreEqual(p.timestamp, 41267360); }