Hi Matteo,

does your sample-code work? Is everything okay with your WebSocket-server? What 
kind of server with which WebSocket-Implementation are you using?

To make sure that we are talking about the same thing, I changed my code so 
test the WebSocket against a publicly WebSocket test-server 
("http://www.websocket.org/echo.html";).

Here is the code:
> /**
>  * @ignore(WebSocket)
>  */
> qx.Class.define("testwebsocket.WebSocket",
> {
>   extend : qx.core.Object,
> 
>   construct : function() 
>   {
>     this.base(arguments);
> 
>     this.socket = new WebSocket('ws://echo.websocket.org/');
> 
>     // register native event-listeners
>     this.socket.addEventListener("open", this.onSocketOpen , false);
>     this.socket.addEventListener("message", this.onSocketMessage , false);
>     this.socket.addEventListener("close", this.onSocketClose , false);
>     this.socket.addEventListener("error", this.onSocketError , false);
>   },
> 
>   members :
>   {
>     // holding the native WebSocket
>     socket : null,
> 
>     // event-handlers
>     onSocketOpen : function(e) {
>       console.log("Connection opened");
>     },
> 
>     onSocketMessage : function(e) {
>       console.log("Message received: " + e.data);
>     },
> 
>     onSocketClose : function(e) {
>       console.log("Connection closed");
>     },
> 
>     onSocketError : function(e) {
>       console.log("An error occured!");
>     },
> 
>     send : function(message)
>     {
>       this.socket.send(message);
>     }
>   }
> });

To test it, create an instance of this class and assign it to a global variable:

> ws = new testwebsocket.WebSocket();

Now start you application and open the developer-console of your browser. You 
should already see the log "Connection opened"). Then send a message to the 
server, just type ws.send("You message text") into the browser-console and the 
server will immediately echo it.

Best,
Andreas


Am 08.09.2013 um 11:30 schrieb matteomasina <[email protected]>:

> Andreas thank you a lot for your help I think I'm really near to the
> solution.
> 
> I've tried you code for test, but sorry not works.
> 
> I'm not so expert in extend object so my questions are :
> 
> - extending the websocket in the way you show me, how can I use the
> websocket method to estabilish the connection , send data and close
> connection ?
> 
> /ws.onopen = function()
>     {
>               alert("Connection open");
>        // Web Socket is connected, send data using send()
>        ws.send("INVIO MESSAGGIO");
>        alert("Message is sent...");
>     };
>     ws.onmessage = function (evt) 
>     { 
>        var received_msg = evt.data;
>        alert();
>        alert("Message is received..." + received_msg);
>     };
>     ws.onclose = function()
>     { 
>        // websocket is closed.
>        alert("Connection is closed..."); 
>     };/
> 
> sorry to disturb you again, but I need this help to continue the work. Or
> send me some link where I can understand how to extend object in qooxdoo.
> 
> Regards Matteo
> 
> 
> 
> --
> View this message in context: 
> http://qooxdoo.678.n2.nabble.com/how-to-use-or-integrate-socket-in-qooxdoo-tp7584526p7584570.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
> 
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to