1
0
-1

I am trying to populate the HTML widget with some simple code which utilises web sockets (wss:) to talk to another app on the local machine. 

I've a simple html file which runs correctly in Chrome, connects to the app and passes me messages. 

Within the HTML widget, the same file with the WS code in the body, Nothing seems to work. If I comment it out, then I can trigger a simple JS function to pass a message through the widget triggers. 

I THINK I've found information on the cef browser which indicates it can't handle web-sockets, but it's dated 2015. Am I right, and I just can't do this (the other APP's API is solely web socket based)? 

Is there something else in Uniface which can access web sockets? 

Has anyone written a DLL or similar which would let me have this functionality? 



    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      The following WebSocket echo test seems to work with the HTML widget:

      https://www.websocket.org/echo.html

      When I test this with 9.7.05 then I get the expected result.

      I hope this helps

      Kind regards,
      Daniel

      1. Iain Sharp

        Then it must be something more esoteric in the code. 

        <html>
        <body>
        <p> Loaded the damn page</p>
        <script language="javascript">
        
        
        
        Testmessage = function(message) {
        alert(message);
          window.unifaceTriggers('errorin',message);
        
        }
        
        
        let socket = new WebSocket("wss://cpclientapi.softphone.com:9002/counterpath/socketapi/v1");
        
        socket.onopen = function(e) {
          socket.send('GET/status\nUser-Agent: ProfIT\nContent-Type: application/xml\nContent-Length: 71\n<?xml version="1.0" encoding="utf-8" ?><status><type>phone</type></status>');
        };
        
        socket.onmessage = function(event) {
          window.unifaceTriggers('messagein',`[message] Data received from server: ${event.data}`);
        };
        
        socket.onclose = function(event) {
          if (event.wasClean) {
            window.unifacetriggers('messagein',`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
          } else {
            // e.g. server process killed or network down
            // event.code is usually 1006 in this case
            window.unifaceTriggers('errorin','[close] Connection died');
          }
        };
        
        socket.onerror = function(error) {
          this.unifaceTriggers('errorin',`[error] ${error.message}`);
        };
        
        
        
        
        </script>
        
        <P><a href="javascript:Testmessage('01142012200')">Click for a message</a></p>
        
        
        </body>
        </html>


        If I comment out the code from let... to just before the end of the script, then clicking gives a message, and a button on the form can use $widgetoperation("JS:Testmessage") to send a message via the javascript.  As is, it displays the body of the page but nothing happens when I click the hyperlink and/or the button on the form. 

        I presume this means the javascript is broken, but it parses okay in chrome itself (except that window.unifacetriggers doesn't exist...)

      2. Iain Sharp

        Forgot to mention that a load of that page into the same widget on my test form DOES show successful in 9.7.05. 

      3. Daniel Iseli

        Have you checked with the CEF DevTools (Ctrl+Shift+I) if there are any warnings or errors shown in the console?

      4. Iain Sharp

        Okay, I've taken the example from that web-page and recoded the URL etc and I can now use the functionality I wanted. Not sure what the problem was with my original javascript though. 

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi Iain

      What abozt libcurl:

      https://curl.haxx.se/libcurl/

      This DLL seem to have all low level "web" tools

      And if I'm right, UnifAc einternal using libcurl ...

      Ingo


        CommentAdd your comment...