Exemple #1
0
        internal void SendRoomScribble(Predicate <IClient> pred, string name, RoomScribble scribble)
        {
            byte[] buffer;
            if (scribble.Size <= 4000)
            {
                Server.SendAnnounce(pred, string.Format("\x000314--- From {0}", name));
                Server.SendPacket(pred, new ClientCustom(string.Empty, "cb0t_scribble_once", scribble.RawImage()));
            }
            else
            {
                scribble.Index = 0;

                int length = Math.Min((int)scribble.Received, 4000);
                buffer = scribble.Read();

                Server.SendAnnounce(pred, string.Format("\x000314--- From {0}", name));
                Server.SendPacket(pred, new ClientCustom(string.Empty, "cb0t_scribble_first", buffer));

                while (scribble.Remaining > 0)
                {
                    buffer = scribble.Read();

                    if (scribble.Remaining > 0)
                    {
                        Server.SendPacket(pred, new ClientCustom(string.Empty, "cb0t_scribble_chunk", buffer));
                    }
                    else
                    {
                        Server.SendPacket(pred, new ClientCustom(string.Empty, "cb0t_scribble_last", buffer));
                    }
                }
            }

            var ib0ts = Server.Users.Where(s => s.Socket.Isib0tSocket && pred(s));

            if (ib0ts.Count() > 0)
            {
                buffer = Zlib.Decompress(scribble.RawImage());

                int    height = RoomScribble.GetHeight(buffer);
                string base64 = Convert.ToBase64String(buffer);

                string[] chunks = new string[(int)Math.Round((double)(base64.Length / 1024), MidpointRounding.AwayFromZero)];

                for (int i = 0; i < chunks.Length; i++)
                {
                    chunks[i] = base64.Substring(i * 1024, 1024);
                }

                ib0ts.ForEach(s => s.SendPacket(new ScribbleHead(name, height, chunks.Length)));

                foreach (string chunk in chunks)
                {
                    ib0ts.ForEach(s => s.SendPacket(new ScribbleBlock(chunk)));
                }
            }
        }
Exemple #2
0
 //Used for Sending scribble objects from another client
 //
 private void OnRoomScribbleComplete(RoomScribble scribble)
 {
     AddMessage(new ChatScribble(Convert.ToBase64String(Zlib.Decompress(scribble.RawImage()))));
 }