This commit is contained in:
Andy Hanson
2017-02-21 14:48:00 -08:00
parent d32795df38
commit 8070b91d39
2 changed files with 12 additions and 12 deletions
+7 -7
View File
@@ -47,7 +47,7 @@ channel.publish('greeting', 'Hello World!', function(err) {
} else {
console.log('publish succeeded');
}
})
});
// Publish several messages at once
channel.publish([{name: 'greeting', data: 'Hello World!'}], function() { });
@@ -64,7 +64,7 @@ channel.history(function(err, messagesPage) {
});
// Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history
channel.history({ start: Date.now()-10000, end: Date.now(), limit: 100, direction: 'forwards'}, function(err, messagesPage) {
channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards'}, function(err, messagesPage) {
console.log(messagesPage.items.length);
});
@@ -108,7 +108,7 @@ channel.presence.history(function(err, messagesPage) { // PaginatedResult
});
// Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history
channel.history({ start: Date.now()-10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {});
channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {});
// Symmetrical end-to-end encrypted payloads on a channel
@@ -117,7 +117,7 @@ channel.history({ start: Date.now()-10000, end: Date.now(), limit: 100, directio
// Generate a random 256-bit key for demonstration purposes (in
// practice you need to create one and distribute it to clients yourselves)
Ably.Realtime.Crypto.generateRandomKey(function(err, key) {
var channel = client.channels.get('channelName', { cipher: { key: key } });
var channel = client.channels.get('channelName', { cipher: { key } });
channel.subscribe(function(message) {
message.name; // 'name is not encrypted'
@@ -149,7 +149,7 @@ restChannel.publish('greeting', 'Hello World!', function(err) {
} else {
console.log('publish succeeded');
}
})
});
// Publish several messages at once
restChannel.publish([{name: 'greeting', data: 'Hello World!'}], function() {});
@@ -167,7 +167,7 @@ restChannel.history(function(err, messagesPage) {
});
// Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history
restChannel.history({ start: Date.now()-10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {});
restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {});
// Presence on a channel
@@ -192,7 +192,7 @@ restChannel.presence.history(function(err, messagesPage) { // PaginatedResult
});
// Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history
restChannel.history({ start: Date.now()-10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {});
restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {});
// Generate Token and Token Request
+5 -5
View File
@@ -108,14 +108,14 @@ amplify.request("ajaxExample2", function (data) {
// a second call will result in pulling from the cache
amplify.request("ajaxExample2", function (data) {
data.baz; // qux
})
});
// Set up and use a RESTful request utilizing Ajax
amplify.request.define("ajaxRESTFulExample", "ajax", {
url: "/myRestFulApi/{type}/{id}",
type: "GET"
})
});
// later in code
amplify.request("ajaxRESTFulExample",
@@ -132,9 +132,9 @@ amplify.request("ajaxRESTFulExample",
// POST data with Ajax
amplify.request.define("ajaxPostExample", "ajax", {
url: "/myRestFulApi",
type: "POST"
})
url: "/myRestFulApi",
type: "POST"
});
// later in code
amplify.request("ajaxPostExample",