Android Tutorial how to write a web client for AsyncStreams libary ? i have a js web socket codes here.

hears

Active Member
Licensed User
these JS code can access socket from web, i have try, it is work with b4a android tcp socket. how to write a JS code work with AsyncStreams ?

this project base on flash and Jsocket .

JavaScript:
<html>
<head>
<title>first jquery</title>

<script type="text/javascript" src="/js/jquery.tools.min.js"></script>
<script type="text/javascript" src="/js/jsocket.js"></script>
<script type="text/javascript">
   
    
    $(function(){
       
      
   
        $("button").click(function(){
          
            alert("connect...");
           
     

JSocket.init('/swf/JSocket.swf', function () {
           socket = new JSocket({
               connectHandler: connectHandler,
               dataHandler:    dataHandler,
               closeHandler:   closeHandler,
               errorHandler:   errorHandler
           });
           //here is you IP ADDRESS and PORT
           socket.connect("192.168.0.60", 21341);
        });
        function connectHandler() {
            socket.writeFlush("GET / HTTP/1.0\x0D\x0A");
            socket.write("Host:192.168.0.60"  + "\x0D\x0A\x0D\x0A");
            socket.flush();
        }
        function dataHandler(data) {
            alert(2);
            socket.writeFlush("GET / HTTP/1.0\x0D\x0A");
            //socket.close();
        }
        function closeHandler() {
            alert('lost connection')
        }
        function errorHandler(errorstr) {
            alert(errorstr);
        }


});
    })


</script>
</head>
<body>
    <button id="button">ClickMe</button>
</body>
</html>
 

Attachments

hears

Active Member
Licensed User
put this html files to your website folder. this web js will work.this socket work in local machine who opened web page, no need severside node.js support.
 
Top