Code Monkey home page Code Monkey logo

jquery-websocket's People

Contributors

googlecodeexporter avatar

Watchers

 avatar

jquery-websocket's Issues

WebSocket undefined on Firefox

But it would work on Firefox if you add these lines:

function isset(variable)
{
  return typeof variable !== "undefined"
}

if (! isset(WebSocket))
  WebSocket = MozWebSocket;

I hope you will do :)

Original issue reported on code.google.com by [email protected] on 27 Feb 2012 at 2:52

Starting two websockets on the same page causes mixup of sockets - fix attached.

What steps will reproduce the problem?
1. Create a web page that opens two WebSockets to a defined Server. 
2. Implement a simple ping-pong message protocol, where both sockets expect a 
pong message on their own socket after they have sent a message.
3. Let both websockets send a ping message.

The expected output is that each socket receives a pong.  Instead both pongs 
message events are handled by one client socket message handler, the one that 
was created last.

This was tested with latest Chrome and Firefox browsers using the HTML5 
WebSocket class. I am using version 0.0.1 of jquery-websocket.

Analyzing the issue we found that the jquery-websocket-0.0.1 script is faulty 
as described below:

After initialisation of the local variable 'ws', 'ws._settings' is set to the 
merge result of the jquery static 'websocketSettings' and input parameter 's'. 
but the extend function modifies the first argument and so the static variable 
gets poisoned each time a new websocket is created. This lead to other strange 
symptoms as well, when we tried to reinstanciate the broken socket. 

We wrote a fix for this issue, please update.

Original issue reported on code.google.com by [email protected] on 14 Aug 2012 at 2:20

Attachments:

Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 (Line 39)

What steps will reproduce the problem?

Running the example


What is the expected output? What do you see instead?

See the example.


What version of the product are you using? On what operating system?

v0.0.1 in Chromium v5.0.308.0 on MacOS


Please provide any additional information below.

I get the error text and code in Chromium Developer Tools.

Original issue reported on code.google.com by [email protected] on 31 Jan 2010 at 12:11

send message before the connexion

What steps will reproduce the problem?
1. Create a WebSocket through your API
2. Send a message before the "open" or "onopen" was triggered 

What is the expected output? What do you see instead?

I expect that the message is not sent but kept in a cache. When the connection 
is etablished, the message is sent.

Or maybe the send function returns me "false", or the send function throws an 
error, or I expect I could choose different behavior through your WebSocket 
options.
As to me, the best behavior would be : the send function waits for the 
websocket to connect and if the websocket do not connect until a fixed delay (5 
sec?), an error is thrown.


Instead, I see this error:
"Uncaught Error: INVALID_STATE_ERR: DOM Exception 11"
return this._send($.toJSON(m)); // jquery.websocket-0.0.1.js:39
$.extend.websocket.ws.send 


What version of the product are you using? On what operating system?

Windows XP + Chrome 17.0.963.56 m
jquery-1.7.1.min.js
jquery.websocket-0.0.1.js
jquery.json-2.3.min.js

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 27 Feb 2012 at 3:46

Event.data is undefined

Event.data returns undefined.  To get data from the message, you have to access 
event.originalEvent.data.  Is this a bug?

Original issue reported on code.google.com by jonahbron.d on 27 Nov 2010 at 12:46

The onopen is never fired.

What steps will reproduce the problem?
I simply do the following command on a ws server:

var ws = $.websocket("ws://127.0.0.1:29999/echo", {
        open: function()
        {
        alert("THIS SHOULD BE DISPLAYED ON OPEN");
        },

        close: function(){  },

        events: {
                message: function(e) { alert(e); $('#content').append(e.data + '<br>') }
        }
});

What is the expected output? What do you see instead?
I expected to see the message "THIS SHOULD BE DISPLAYED ON OPEN" to be displayed

What version of the product are you using? On what operating system?
jQuery Web Sockets Plugin v0.0.1
Firefox 4 or Webkit / Safari 5.0

Please provide any additional information below.
I just suspect the onopen function not to be bound
The following code works like a charm:

        ws = new WebSocket("ws://localhost:29999/websocket");
        ws.onmessage = function(evt) { $("#msg").append("<p>"+evt.data+"</p>"); };
        ws.onclose = function() { debug("socket closed"); };
        ws.onopen = function() {
          debug("connected...");
          ws.send("{\"message\":\"Yo\"}");
        };




Original issue reported on code.google.com by [email protected] on 22 Jul 2010 at 1:07

updated code for fix bind problem and catch the exception

I update the code for fix bind problem and catch the exception.
Below is updated the code.
/*
 * jQuery Web Sockets Plugin v0.0.1
 * http://code.google.com/p/jquery-websocket/
 *
 * This document is licensed as free software under the terms of the
 * MIT License: http://www.opensource.org/licenses/mit-license.php
 * 
 * Copyright (c) 2010 by shootaroo (Shotaro Tsubouchi).
 */
(function($){
$.extend({
    websocketSettings: {
        open: function(){},
        close: function(){},
        message: function(){},
        options: {},
        events: {}
    },
    websocket: function(url, s) {
        var ws = WebSocket ? new WebSocket( url ) : {
            send: function(m){ return false },
            close: function(){}
        };
        ws._settings = $.extend($.websocketSettings, s);
        $(ws)
            .bind('open', $.websocketSettings.open)
            .bind('close', $.websocketSettings.close)
            .bind('message', $.websocketSettings.message)
            .bind('message', function(e){
                var m = $.evalJSON(e.originalEvent.data);
                var h = $.websocketSettings.events[m.type];
                if (h) h.call(this, m);
            });
        ws._send = ws.send;
        ws.send = function(type, data) {
            var m = {command: type};
            m = $.extend(true, m, $.extend(true, {}, $.websocketSettings.options, m));
            if (data) m['data'] = data;
            try{ 
                this._send($.toJSON(m));
                } 
            catch(ex)
            { 
                alert(ex);
                return false;   
            }
            return true;
        }
        $(window).unload(function(){ ws.close(); ws = null });
        return ws;
    }
});
})(jQuery);

Original issue reported on code.google.com by [email protected] on 2 Apr 2011 at 12:42

bug fix in jquery-websocket

What steps will reproduce the problem?
1.
<script>
...
ws = $.websocket("ws://somedomain.com:8088", {
                open: function() {
                    alert('open');
                },
                close: function() {
                    alert('close');
                },
                events: {
                    say: function(e) {
                        alert(e.data.name);
                        alert(e.data.text);
                    }
                }
            });

...
</script>

binding not work

2. because:
<script>
ws._settings = $.extend($.websocketSettings, s);
</script>

is AFTER binding

3. solution:
need remove it BEFORE binding

<script>
(function($){
$.extend({
        websocketSettings: {
                open: function(){},
                close: function(){},
                message: function(){},
                options: {},
                events: {}
        },
        websocket: function(url, s) {
                var ws = WebSocket ? new WebSocket( url ) : {
                        send: function(m){ return false },
                        close: function(){}
                };

                /* extend before binding */
                ws._settings = $.extend($.websocketSettings, s);
                $(ws)
                        .bind('open', $.websocketSettings.open)
                        .bind('close', $.websocketSettings.close)
                        .bind('message', $.websocketSettings.message)
                        .bind('message', function(e){
                                var m = $.evalJSON(e.originalEvent.data);
                                var h = $.websocketSettings.events[m.type];
                                if (h) h.call(this, m);
                        });
                ws._send = ws.send;
                ws.send = function(type, data) {

                        var m = {type: type};
                        m = $.extend(true, m, $.extend(true, {}, $.websocketSettings.options, m));
                        if (data)
                            m['data'] = data;
                        return this._send($.toJSON(m));
                }
                $(window).unload(function(){ ws.close(); ws = null });
                return ws;
        }
});
})(jQuery);
</script>

/* patch from fish9370 */

Original issue reported on code.google.com by [email protected] on 1 Aug 2013 at 7:38

Forked to github

Seeing as there's been no maintenance on this for a couple of years and I 
needed a fix, I forked this at https://github.com/dchelimsky/jquery-websocket.

Please feel free to submit issues and/or pull requests there, or just fork it 
if you want to take ownership of it.

Cheers,
David

Original issue reported on code.google.com by [email protected] on 20 Sep 2012 at 8:50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.