[Opa] Json type in javascript plugin
Tristan Sloughter
tristan.sloughter at gmail.com
Tue Nov 8 18:37:45 EST 2011
Right, thats the possible solution I mentioned in my email, maybe I didn't
phrase it well enough.
But I see problems with that and interacting with other PubNub clients that
publish to the channel.
I think I'm going to play around with this more and I'll probably either
have a better question or a solution :)
Thanks!
Tristan
On Tue, Nov 8, 2011 at 5:20 PM, Matthieu Guffroy <mattgu74 at gmail.com> wrote:
> May be try the same thing but with the reverse function :
>
> Json.to_string : RPC.Json.json → string
>
> assuming your js bypass :
> ##register publish : string, string -> void
>
> opa code linked to the bypass :
> publish(channel : string, message : RPC.Json.json) = %%publish%%(channel,
> Json.to_string(message))
>
> It helps ?
> Matthieu
>
>
> 2011/11/8 Tristan Sloughter <tristan.sloughter at gmail.com>
>
>> Thanks that helps with the call back, but I realized I need to also be
>> able to pass in Json to the publish function since if I simply pass a
>> string it is probably the reason I'm getting {none} back from
>> Json.of_string in the subscribe callback -- I'm simply passing messages
>> back and forth to test :)
>>
>> So I pass in a string to publish and subscribe receives it, sends it to
>> the call back and does:
>>
>> Option.get(Json.of_string(x))
>>
>> which gives me {none} and I can only assume that is because I am passing
>> a string in publish instead of a Json object. Does that sound correct? The
>> publish definition is currently:
>>
>> ##register publish : string, string -> void
>>
>> Now I could in the publish javascript code create a Json object from the
>> string -- though it would be nice to be able to simply pass a RPC.Json.json
>> type and not have the javascript have to worry about it, but you seem to
>> have said I can't do that. But that seems like a poor final solution since
>> if another client is talking to the same channel it could pass a simple
>> string and crash the Opa client.
>>
>> But maybe thats just the way it has to be :)
>>
>> Let me know if anyone has any suggestions.
>>
>> Thanks,
>> Tristan
>>
>> On Tue, Nov 8, 2011 at 3:31 PM, Matthieu Guffroy <mattgu74 at gmail.com>wrote:
>>
>>> Hi !
>>>
>>> let your callback working with string in the bypass.
>>>
>>> And use this function in the opa code.
>>>
>>> Json.of_string : string → option<http://doc.opalang.org/api/stdlib.themes.bootstrap.core.core.opa.html#value_stdlib.themes.bootstrap.core.option>
>>> (RPC.Json.json<http://doc.opalang.org/api/stdlib.core.rpc.core.json.opa.html#type_stdlib.core.rpc.core.RPC.Json.json>
>>> )
>>>
>>> You could then have something like that :
>>>
>>> my_bypass(callback : (option(RPC.Json.json) -> void)) = %% bypass %%(
>>> (str -> callback(Json.of_string(str)) )
>>>
>>>
>>>
>>>
>>> 2011/11/8 Tristan Sloughter <tristan.sloughter at gmail.com>
>>>
>>>> The callback receives json and in the manual I found that there was a
>>>> type for json, RPC.Json.json, but if I try to use that in the javascript
>>>> plugin:
>>>>
>>>> ##register subscribe : string, (RPC.Json.json -> void) -> void
>>>>
>>>> Cannot resolve the reference to the type RPC.Json.json
>>>> Error
>>>> ##register: failing type resolution for key 'subscribe'
>>>>
>>>> Is there a way to include it or something in the .js file I define the
>>>> plugin in?
>>>>
>>>> Thanks,
>>>> Tristan
>>>>
>>>> _______________________________________________
>>>> Opa mailing list
>>>> Opa at lists.owasp.org
>>>> https://lists.owasp.org/mailman/listinfo/opa
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.owasp.org/pipermail/opa/attachments/20111108/f1e376f5/attachment.html
More information about the Opa
mailing list