Esempio n. 1
0
        void _SendMessage(PusherRecipient recipient, Byte[] payload)
        {
            using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) {
                socket.SendTimeout    = 60000 * 10;              /* 10 minutes */
                socket.SendBufferSize = payload.Length;

                try {
                    socket.Connect(new IPEndPoint(IPAddress.Parse(recipient.Host), recipient.Port));
#if DEBUG
                    PSLogger.Log(PSLogLevel.Info, String.Format("Sending notification to {0}...", recipient.Host));
#endif
                    socket.Send(payload);
#if DEBUG
                    PSLogger.Log(PSLogLevel.Info, "Notification Sent!");
#endif
                } catch (Exception ex) {
                    // We don't fail the other recipients because we failed.
                    PSLogger.LogException(ex);
                } finally {
                    if (socket.Connected)
                    {
                        socket.Close();
                    }
                }
            }
        }
Esempio n. 2
0
        void IPusherService.Register(PusherRecipient recipient)
        {
            recipient.Guard("recipient parameter was null");
            Boolean bFound = false;

            _recipients.ForEach(item => {
                if (item.Host.Equals(recipient.Host))
                {
                    item.Port = recipient.Port;
                    return(bFound = true);
                }

                return(false);
            });

            if (!bFound)
            {
                _recipients.Add(recipient);
            }
        }
Esempio n. 3
0
        void _SendMessage(PusherRecipient recipient, Byte[] payload)
        {
            using (var socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) {
                socket.SendTimeout = 60000 * 10; /* 10 minutes */
                socket.SendBufferSize = payload.Length;

                try {
                    socket.Connect (new IPEndPoint (IPAddress.Parse (recipient.Host), recipient.Port));
            #if DEBUG
                    PSLogger.Log (PSLogLevel.Info, String.Format ("Sending notification to {0}...", recipient.Host));
            #endif
                    socket.Send (payload);
            #if DEBUG
                    PSLogger.Log (PSLogLevel.Info, "Notification Sent!");
            #endif
                } catch (Exception ex) {
                    // We don't fail the other recipients because we failed.
                    PSLogger.LogException (ex);
                } finally {
                    if (socket.Connected)
                        socket.Close ();
                }
            }
        }
Esempio n. 4
0
        void IPusherService.Register(PusherRecipient recipient)
        {
            recipient.Guard ("recipient parameter was null");
            Boolean bFound = false;

            _recipients.ForEach (item => {
                if (item.Host.Equals (recipient.Host)) {
                    item.Port = recipient.Port;
                    return bFound = true;
                }

                return false;
            });

            if (!bFound) _recipients.Add (recipient);
        }