Hi all, I have downloaded the websocket project and have embedded into a test app for android, but I just need a pointer with the client/server side script (
B4J WebSockets client library)
I want to modify the sample script to just use jquery to inject data to the websocket connection instead of using the button that was provided in the demo.
https://www.b4x.com/android/forum/threads/custom-websocket-based-push-framework.40272/
I got these from the frames in the demo provided:
I wish to send something like the above json using what i think is correct from the b4j_ws.js script which are raiseEvent and ws.send is this the correct way?
B4J WebSockets client library)
I want to modify the sample script to just use jquery to inject data to the websocket connection instead of using the button that was provided in the demo.
https://www.b4x.com/android/forum/threads/custom-websocket-based-push-framework.40272/
B4X:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="b4j_ws.js"></script>
<script>
$( document ).ready(function() {
b4j_connect("/push/ws");});
</script>
<script>
b4j_raiseEvent("btnsend", {result: theResult}) //the event name should be lower cased
b4j_ws.send(JSON.stringify({"type":"data","data":"wwww"}));
</script>
B4X:
{"type":"event","event":"btnsend_click","params":{"which":1,"target":"btnsend","pageX":31,"pageY":19,"metaKey":false}}
{"id":"#txt","method":"val","etype":"runmethodWithResult"}
{"type":"data","data":"SOMETHING COOL"}
Last edited: