Hi Geesara,

Yes for normal websockets implementations you can pass as URL parameters,
but in jaggery WebSocketHostObject implementation there was no way to get
query string in the server end. We might need to include a js function like
getQueryString similar like in RequestHostObject [2].

[1]
https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.web/src/main/java/org/jaggeryjs/hostobjects/web/WebSocketHostObject.java

[2]
https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.web/src/main/java/org/jaggeryjs/hostobjects/web/RequestHostObject.java#L222

Regards,

On Wed, Aug 24, 2016 at 7:47 PM, Geesara Prathap <[email protected]> wrote:

> Hi Dilini,
>
>
> Is it possible for a Websocket client to send some parameters (as path
> params or as query params) to a Websocket Server at the time of creating
> the connection?
>
> Yes, you can send n number of query params, this reference
> implementation[1-2] will help you to figure it out how this is done. There
> are some compatibility issues with difference browsers as well as  browser
> versions. So referenced implementation addressed that kind of issues as
> well.
>
>
> 1. https://github.com/wso2/carbon-device-mgt-plugins/blob/
> master/components/iot-plugins/raspberrypi-plugin/org.wso2.
> carbon.device.mgt.iot.raspberrypi.ui/src/main/resour
> ces/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.
> raspberrypi.realtime.analytics-view/analytics-view.js#L30
> 2. https://github.com/wso2/carbon-device-mgt-plugins/blob/
> master/components/iot-plugins/raspberrypi-plugin/org.wso2.
> carbon.device.mgt.iot.raspberrypi.ui/src/main/resour
> ces/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.
> raspberrypi.realtime.analytics-view/public/js/device-stats.js
>
> Thanks,
> Geesara
>
> On Wed, Aug 24, 2016 at 7:13 PM, Dilini Muthumala <[email protected]> wrote:
>
>> Hi,
>>
>> Is it possible for a Websocket client to send some parameters (as path
>> params or as query params) to a Websocket Server at the time of creating
>> the connection?
>>
>> Right now, the Websocket client which I'm writing is sending parameters
>> after connecting to the Webocket server, in a message, as below (line no
>> 16):
>>
>>
>>    1. <script>
>>    2. var url = 'ws://localhost:9763/sample/ws/server.jag';
>>    3. function start() {
>>    4. ws = new WebSocket(url);
>>    5. ws.onopen = function() {
>>    6. //
>>    7. };
>>    8. //event handler for the message event in the case of text frames
>>    9. ws.onmessage = function(event) {
>>    10. //
>>    11. };
>>    12. ws.onclose = function() {
>>    13. //
>>    14. };
>>    15. ws.onopen();
>>    16. ws.send("parameter1,parameter2");
>>    17. }
>>    18. </script>
>>
>>
>> Is there any better way for a Websocket client to send parameters to a
>> server?
>>
>> Thanks,
>> Dilini
>>
>> --
>> *Dilini Muthumala*
>> Senior Software Engineer,
>> WSO2 Inc.
>>
>> *E-mail :* [email protected]
>> *Mobile: *+94 713-400-029
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Geesara Prathap Kulathunga
> Software Engineer
> WSO2 Inc; http://wso2.com
> Mobile : +940772684174
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 

*Tharik Kanaka*

WSO2, Inc | lean . enterprise . middleware

Email: [email protected] | Web: www.wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to