monic Active Member Licensed User Longtime User Oct 31, 2015 #1 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/ Code: Copy <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> I got these from the frames in the demo provided: Code: Copy {"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"} 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? Last edited: Oct 31, 2015
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/ Code: Copy <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> I got these from the frames in the demo provided: Code: Copy {"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"} 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?
Erel B4X founder Staff member Licensed User Longtime User Nov 1, 2015 #2 B4J WebSockets client is not relevant unless you are implementing a B4J client app. You need to follow the examples from this page: https://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content Upvote 0
B4J WebSockets client is not relevant unless you are implementing a B4J client app. You need to follow the examples from this page: https://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content
monic Active Member Licensed User Longtime User Nov 1, 2015 #3 Hi, I had already installed the B4J client app and server and they work successfully, I just wanted to find a pointer to do away with the textbox and button used in the demo page /push/index.html and just use jquery to send to the client. I've looked at the B4J and the B4A app and i cant find where the textbox and button are binding to the script as when I change the textbox name it displays null as expected? Last edited: Nov 1, 2015 Upvote 0
Hi, I had already installed the B4J client app and server and they work successfully, I just wanted to find a pointer to do away with the textbox and button used in the demo page /push/index.html and just use jquery to send to the client. I've looked at the B4J and the B4A app and i cant find where the textbox and button are binding to the script as when I change the textbox name it displays null as expected?
Erel B4X founder Staff member Licensed User Longtime User Nov 2, 2015 #4 I think that you need to go over PushBrowser module (btnSend_Click specifically). Upvote 0