Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixing Pubnub.history #2

Merged
merged 2 commits into from

2 participants

@BourgerieQuentin

Hi,
these commits should fix issue described in

http://lists.owasp.org/pipermail/opa/2011-November/000397.html

Best, Quentin.

@tsloughter tsloughter merged commit 0f93c4d into from
@tsloughter
Owner

This is great! Thanks, Quentin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 8 deletions.
  1. +6 −7 src/examples/pubnub_chat.opa
  2. +4 −1 src/plugin/pubnub.js
View
13 src/examples/pubnub_chat.opa
@@ -26,16 +26,15 @@ broadcast(author, msg) =
do PubNub.publish("chat", record_json)
Dom.clear_value(#entry)
-add_history(x: string) =
- match Json.deserialize(x) with
- | {some={List=history}} ->
- do List.iter(user_update_2, history)
- void
- | _ -> void
+add_history(history) =
+ LowLevelArray.iter(
+ elt -> user_update_2(Json.deserialize(elt) ? {String = elt})
+ , history
+ )
launch(author) =
init_client() =
- //do PubNub.history("chat", 20, (h -> add_history(h)))
+ do PubNub.history("chat", 20, (h -> add_history(h)))
PubNub.subscribe("chat", (x -> user_update(x)))
send_message() =
broadcast(author, Dom.get_value(#entry))
View
5 src/plugin/pubnub.js
@@ -1,4 +1,6 @@
// This is an Javascript file, containing opa preprocessing directives
+##extern-type llarray('a)
+//' Declare llarray as an external type
##register publish : string, string -> void
##args(c, m)
@@ -29,7 +31,8 @@
return js_void;
}
-##register history : string, int, (string -> void) -> void
+// Callback history doesn't take a string as argument but a low level javascript array
+##register history : string, int, (llarray(string) -> void) -> void
##args(channel, limit, callback)
{
PUBNUB.history({
Something went wrong with that request. Please try again.