aaronk Well-Known Member Licensed User Longtime User May 26, 2015 #1 Hi, Just wondering what the trick is to run the web socket RunFunction function? I have a function on my HTML page like: HTML: <script> jQuery(document).ready(function() { test(); }); function test(){ alert("testing"); } </script> When I run my HTML code it will alert 'testing' since it's calling that function on page load, which is fine while I am testing it. In my B4J app I am trying to call this function using a web socket like: Code: Sub btnCalc_Click (Params As Map) ws.RunFunction("test", Null) End Sub The problem I have is when I run the app it comes up with the error: Code: Parsing code. 0.05 Compiling code. Error Error compiling program. Error description: Too many parameters. Occurred on line: 24 ws.RunFunction("test", Null) Word: _c From what I understand there is too many parameters in the RunFunction function part in my code. I tried doing: Code: Sub btnCalc_Click (Params As Map) ws.RunFunction("test") End Sub Now when I run the app it says: Code: Parsing code. 0.03 Compiling code. Error Error compiling program. Error description: Missing parameter. Occurred on line: 24 ws.RunFunction("test") Word: ) How can I trigger the JavaScript Function from a web Socket, is this the correct way in doing it ?
Hi, Just wondering what the trick is to run the web socket RunFunction function? I have a function on my HTML page like: HTML: <script> jQuery(document).ready(function() { test(); }); function test(){ alert("testing"); } </script> When I run my HTML code it will alert 'testing' since it's calling that function on page load, which is fine while I am testing it. In my B4J app I am trying to call this function using a web socket like: Code: Sub btnCalc_Click (Params As Map) ws.RunFunction("test", Null) End Sub The problem I have is when I run the app it comes up with the error: Code: Parsing code. 0.05 Compiling code. Error Error compiling program. Error description: Too many parameters. Occurred on line: 24 ws.RunFunction("test", Null) Word: _c From what I understand there is too many parameters in the RunFunction function part in my code. I tried doing: Code: Sub btnCalc_Click (Params As Map) ws.RunFunction("test") End Sub Now when I run the app it says: Code: Parsing code. 0.03 Compiling code. Error Error compiling program. Error description: Missing parameter. Occurred on line: 24 ws.RunFunction("test") Word: ) How can I trigger the JavaScript Function from a web Socket, is this the correct way in doing it ?
B billzhan Active Member Licensed User Longtime User May 26, 2015 #2 ws.RunFunction("test",Array As Object(Null)) Upvote 0
aaronk Well-Known Member Licensed User Longtime User May 27, 2015 #3 billzhan said: ws.RunFunction("test",Array As Object(Null)) Click to expand... Still get the same error. Code: Parsing code. 0.14 Compiling code. Error Error compiling program. Error description: Too many parameters. Occurred on line: 24 ws.RunFunction("test",Array As Object(Null)) Word: array (Running this with B4J version 2.50) Upvote 0
billzhan said: ws.RunFunction("test",Array As Object(Null)) Click to expand... Still get the same error. Code: Parsing code. 0.14 Compiling code. Error Error compiling program. Error description: Too many parameters. Occurred on line: 24 ws.RunFunction("test",Array As Object(Null)) Word: array (Running this with B4J version 2.50)
B billzhan Active Member Licensed User Longtime User May 27, 2015 #4 I made simple test based on the webapp hello world demo. (b4j 2.5 &2.8) Code: ws.RunFunction("test", Null) 'working ws.RunFunction("test",Array As Object(Null)) 'working Something else may cause this error Attachments WebAppHelloWorld mod runfunction.zip WebAppHelloWorld mod runfunction.zip 56.9 KB · Views: 538 Upvote 0
I made simple test based on the webapp hello world demo. (b4j 2.5 &2.8) Code: ws.RunFunction("test", Null) 'working ws.RunFunction("test",Array As Object(Null)) 'working Something else may cause this error
Daestrum Expert Licensed User Longtime User May 27, 2015 #5 Are you including the b4j_ws.js file in your page, and then on doc.ready calling b4j_connect("??") ? Upvote 0
aaronk Well-Known Member Licensed User Longtime User May 27, 2015 #6 billzhan said: I made simple test based on the webapp hello world demo. (b4j 2.5 &2.8) Code: ws.RunFunction("test", Null) 'working ws.RunFunction("test",Array As Object(Null)) 'working Something else may cause this error Click to expand... When I run your example it seems to work. I then copied your 'HelloWorld' module code into my project and it then comes up with the same error saying there isToo many parameters. Daestrum said: Are you including the b4j_ws.js file in your page, and then on doc.ready calling b4j_connect("??") ? Click to expand... Yes I have that in my www folder and am calling it. HTML: $( document ).ready(function() { b4j_connect("/ws"); }); The problem is that it won't compile the B4J app. There must be something else in my project that is causing this error and will need to now look through my other modules to see what might be the cause. At least I now know that it should work, and will now look into it and find out what the cause might be. Upvote 0
billzhan said: I made simple test based on the webapp hello world demo. (b4j 2.5 &2.8) Code: ws.RunFunction("test", Null) 'working ws.RunFunction("test",Array As Object(Null)) 'working Something else may cause this error Click to expand... When I run your example it seems to work. I then copied your 'HelloWorld' module code into my project and it then comes up with the same error saying there isToo many parameters. Daestrum said: Are you including the b4j_ws.js file in your page, and then on doc.ready calling b4j_connect("??") ? Click to expand... Yes I have that in my www folder and am calling it. HTML: $( document ).ready(function() { b4j_connect("/ws"); }); The problem is that it won't compile the B4J app. There must be something else in my project that is causing this error and will need to now look through my other modules to see what might be the cause. At least I now know that it should work, and will now look into it and find out what the cause might be.
aaronk Well-Known Member Licensed User Longtime User May 27, 2015 #7 Worked it out.. In my Main Module I had the code: Code: Sub AppStart (Args() As String) srvr.Initialize("srvr") srvr.AddWebSocket("/ws", "WebSocket") srvr.Port = 51042 srvr.Start StartMessageLoop End Sub As you will see the Module it's going to use is 'WebSocket' Since in that module it's calling the WebSocket (Private ws As WebSocket) you can't have the class module called 'WebSocket'. Soon as I changed the Class Module from 'WebSocket' to something else such as 'WebSock' and then change the code in the Main module to: Code: Sub AppStart (Args() As String) srvr.Initialize("srvr") srvr.AddWebSocket("/ws", "WebSock") srvr.Port = 51042 srvr.Start StartMessageLoop End Sub Everything worked as it should. Something so simple to fix but always the last thing to check. Thanks for everyone's help. Upvote 0
Worked it out.. In my Main Module I had the code: Code: Sub AppStart (Args() As String) srvr.Initialize("srvr") srvr.AddWebSocket("/ws", "WebSocket") srvr.Port = 51042 srvr.Start StartMessageLoop End Sub As you will see the Module it's going to use is 'WebSocket' Since in that module it's calling the WebSocket (Private ws As WebSocket) you can't have the class module called 'WebSocket'. Soon as I changed the Class Module from 'WebSocket' to something else such as 'WebSock' and then change the code in the Main module to: Code: Sub AppStart (Args() As String) srvr.Initialize("srvr") srvr.AddWebSocket("/ws", "WebSock") srvr.Port = 51042 srvr.Start StartMessageLoop End Sub Everything worked as it should. Something so simple to fix but always the last thing to check. Thanks for everyone's help.