Example #1
0
        public void GetBacklog(ChatBuffer buf)
        {
            var bid = Connections[buf.ParentConnection].Buffers.FirstOrDefault(x => x.Value == buf).Key;
            var request = SendRequest("https://www.irccloud.com" + "/chat/backlog?cid="+buf.ParentConnection+"&bid="+bid+"&num="+50, "GET", "", new List<string> { "Accept-Encoding: gzip" });
            _backlogProcessing = true;
            var dStream = request.GetResponseStream();
            byte[] bytes;
            using (var memstream = new MemoryStream())
            {
                Debug.Assert(dStream != null, "dStream != null");
                dStream.CopyTo(memstream);
                bytes = memstream.ToArray();
            }

            var data = Ionic.Zlib.GZipStream.UncompressString(bytes);
            var output = data.Split(new[] { ",\n", "\n", "\n]",", \n", "[\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            foreach (var msg in output)
            {
                socket_MessageReceived(this, new MessageReceivedEventArgs(msg));
            }
        }
Example #2
0
 public void RemoveChannel(int bid, ChatBuffer buf)
 {
     Buffers.Remove(bid);
     _dispatcher.Invoke((new Action(() => ObsBuffers.Remove(buf))));
     SortChannels();
 }
Example #3
0
        public void AddChannel(int bid,ChatBuffer buf)
        {
            Buffers[bid] = buf;
            _dispatcher.Invoke((() => ObsBuffers.Add(buf)));

            SortChannels();
        }
Example #4
0
        private void MakeBuffer(Dictionary<string, dynamic> dict)
        {
            int cid = (int)dict["cid"];
            Connection con = Connections[cid];
            ChatBuffer buffer;
            if (dict["buffer_type"] == "channel")
            {
                buffer = new ChannelBuffer(_dispatcher,cid) { ConnectionId = (int)dict["cid"], Bufferid = (int)dict["bid"], BufferType = dict["buffer_type"], Name = dict["name"], Deferred = dict["deferred"], TimeOut = dict["timeout"], Archived = dict["archived"], MinEid = dict["min_eid"], Created = (int)dict["created"], LastSeenEid = dict["last_seen_eid"] };
            }
            else
            {
                buffer = new ChatBuffer(_dispatcher,cid) { ConnectionId = (int)dict["cid"], Bufferid = (int)dict["bid"], BufferType = dict["buffer_type"], Name = dict["name"], Deferred = dict["deferred"], TimeOut = dict["timeout"], Archived = dict["archived"], MinEid = dict["min_eid"], Created = (int)dict["created"], LastSeenEid = dict["last_seen_eid"] };
            }
            con.AddChannel((int)dict["bid"], buffer);

            Console.WriteLine("Added new buffer " + buffer.Name + " to #" + con.ConnectionId);
        }