Exemplo n.º 1
0
        void IPusherService.Push(PusherContent content)
        {
            content.Guard("recipient parameter was null");
            List <Byte[]> bits = new List <Byte[]> ();

            if (!String.IsNullOrEmpty(content.Text))
            {
                bits.Add(BitConverter.GetBytes((Int32)NotificationType.Text));
                bits.Add(BitConverter.GetBytes(content.Text.Length));
                bits.Add(Encoding.UTF8.GetBytes(content.Text));
                Parallel.ForEach(content.Recipients, recipient => _SendMessage(recipient, bits.Collapse()));
            }

            if (!content.Image.IsNullOrDefault() && content.Image.Length > 0)
            {
                bits.Add(BitConverter.GetBytes((Int32)NotificationType.Image));
                bits.Add(BitConverter.GetBytes(content.Image.Length));
                bits.Add(content.Image);
                Parallel.ForEach(content.Recipients, recipient => _SendMessage(recipient, bits.Collapse()));
            }
        }
Exemplo n.º 2
0
        void IPusherService.Push(PusherContent content)
        {
            content.Guard ("recipient parameter was null");
            List<Byte[]> bits = new List<Byte[]> ();

            if (!String.IsNullOrEmpty (content.Text)) {
                bits.Add (BitConverter.GetBytes ((Int32)NotificationType.Text));
                bits.Add (BitConverter.GetBytes (content.Text.Length));
                bits.Add (Encoding.UTF8.GetBytes (content.Text));
                Parallel.ForEach (content.Recipients, recipient => _SendMessage (recipient, bits.Collapse ()));
            }

            if (!content.Image.IsNullOrDefault () && content.Image.Length > 0) {
                bits.Add (BitConverter.GetBytes ((Int32)NotificationType.Image));
                bits.Add (BitConverter.GetBytes (content.Image.Length));
                bits.Add (content.Image);
                Parallel.ForEach (content.Recipients, recipient => _SendMessage (recipient, bits.Collapse ()));
            }
        }