Module: Wpns
Constant Summary collapse
- VERSION =
"0.0.2"
- BASEBATCH =
{ :tile => 1, :toast => 2, :raw => 3 }
- BATCHADDS =
{ :delay450 => 10, :delay900 => 20 }
- WP_TARGETS =
{ :toast => "toast", :tile => "token" }
Instance Method Summary collapse
-
#send_notification(uri, params, type = :raw, delay = nil) ⇒ Object
Send a WP7 notification to the given URI.
Instance Method Details
#send_notification(uri, params, type = :raw, delay = nil) ⇒ Object
Send a WP7 notification to the given URI.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wpns/notifications.rb', line 24 def send_notification(uri, params, type = :raw, delay = nil) msg = params, type notification_class = calculate_delay type, delay uri = URI.parse uri http = Net::HTTP.new uri.host, uri.port headers = { 'Content-Type' => 'text/html', 'Content-Length' => msg.bytesize.to_s, 'X-NotificationClass' => notification_class.to_s } headers['X-WindowsPhone-Target'] = WP_TARGETS[type] unless type == :raw http.post(uri.path, msg, headers) end |