Sha256: 1faff215803af5185d1ecfd1a055b541454e72dd8055e11d3819d4e4126d5ce4
Contents?: true
Size: 1.47 KB
Versions: 7
Compression:
Stored size: 1.47 KB
Contents
#encoding: utf-8 #!/usr/bin/env ruby require 'rubygems' require 'yaml' require 'cgi' require 'digest/sha2' require 'uri-handler' require 'net/http' ########################################################################### #### #### This script is only for demo purpose, you can write this script #### with any language you like(python, perl, shell etc) #### ########################################################################### ############################################################ ## Configuration Setup ############################################################ env = ENV['SINATRA_ENV'] || "development" config = YAML.load_file("#{Dir.pwd}/ass.yml") $port = config['port'] || 4567 $apps = config['apps'] || [] ############################################################ ## Using curl command to send push notification message ############################################################ @message = "This is an push notification message sent by ASS" # CGI::escape("This is an push notification message sent by ASS".to_uri) #@pid = Digest::SHA2.hexdigest("#{Time.now.to_i}") @pid = "#{Time.now.to_i}" ## get api $apps.each { |app| sleep 1 # system "curl http://localhost:#{$port}/v1/apps/#{app}/push/#{@message}/#{@pid}" } ## post api begin url = URI.parse("http://localhost:#{$port}/v1/apps/#{app}/push") post_args1 = { :alert => "#{@message}", :pid => "#{@pid}" } puts url Net::HTTP.post_form(url, post_args1) rescue =>err puts "#{err.class} ##{err}" end
Version data entries
7 entries across 7 versions & 1 rubygems
Version | Path |
---|---|
ass-0.0.25 | cron |
ass-0.0.24 | cron |
ass-0.0.21 | cron |
ass-0.0.20 | cron |
ass-0.0.19 | cron |
ass-0.0.18 | cron |
ass-0.0.17 | cron |