Created
September 26, 2014 19:20
-
-
Save ToeJamson/3da24bcef47212cf6bdf to your computer and use it in GitHub Desktop.
Data Streams over WebSockets and HTTP Long Polling Protocols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"time": "2:07:04pm", | |
"price": "510.83", | |
"delta": "69.02", | |
"perc": "13.51", | |
"vol": 2930 | |
} | |
{ | |
"time": "2:07:06pm", | |
"price": "512.29", | |
"delta": "70.48", | |
"perc": "13.76", | |
"vol": 5120 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install pubnub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pubnub' | |
my_logger = Logger.new(STDOUT) | |
pubnub = Pubnub.new( | |
subscribe_key: "demo", | |
error_callback: lambda { |msg| | |
puts "Error callback says: #{msg.inspect}" | |
}, | |
logger: my_logger | |
) | |
options = { | |
channel: "hello_world", | |
http_sync: true | |
} | |
pubnub.subscribe(options) { |data| puts data.msg } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install pubnub==3.5.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pubnub | |
pubnub = Pubnub(subscribe_key="demo", ssl_on=False) | |
def pn_received(message): | |
print(message) | |
return True | |
pubnub.subscribe_sync(channel='hello_world', callback=pn_received) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdn.pubnub.com/pubnub.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(){ | |
var pubnub = PUBNUB.init({ | |
publish_key : 'demo', | |
error: function(e) { | |
console.log(e); | |
} | |
}); | |
// The message you want to sent can be anything | |
// Examples include strings, numbers, arrays, or JavaScript Objects, etc. | |
// JavaScript Objects are automatically converted to JSON strings by the SDK | |
pubnub.publish({ | |
channel : "hello_world", | |
message : "Hi, from JavaScript" | |
}); | |
})(); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install pubnub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pubnub' | |
my_logger = Logger.new(STDOUT) | |
pubnub = Pubnub.new( | |
publish_key: "demo", | |
error_callback: lambda { |msg| | |
puts "Error callback says: #{msg.inspect}" | |
}, | |
logger: my_logger | |
) | |
options = { | |
message: "Hi, from Ruby", | |
channel: "hello_world", | |
http_sync: true | |
} | |
pubnub.publish(options) do |envelope| | |
puts envelope.inspect | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install pubnub==3.5.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pubnub | |
pubnub = Pubnub(publish_key="demo", ssl_on=False) | |
def pn_error(message): | |
print ("ERROR: " + str(message)) | |
print pubnub.publish(channel='hello_world', message='Hi, from Python', error=pn_error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdn.pubnub.com/pubnub.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(){ | |
var pubnub = PUBNUB.init({ | |
subscribe_key : 'demo', | |
error: function(e) { | |
console.log(e); | |
} | |
}); | |
// Messages received on the specified channel will be sent to the message callback function | |
// JSON strings are automatically converted to JavaScript Objects by the SDK | |
pubnub.subscribe({ | |
channel : "hello_world", | |
message : function(msg) { | |
console.log(msg); | |
} | |
}); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment