javascript - Determine if a websocket send() is finished - Stack Overflow

Is there a way to get notified if a certain send() has finished? As i noticed the send() function is no

Is there a way to get notified if a certain send() has finished? As i noticed the send() function is not blocking and the code continuous. Is there a simple way to either make it blocking or getting somehow notified if the send is finished?

Is there a way to get notified if a certain send() has finished? As i noticed the send() function is not blocking and the code continuous. Is there a simple way to either make it blocking or getting somehow notified if the send is finished?

Share Improve this question asked Aug 12, 2013 at 14:08 dustin.bdustin.b 1,27514 silver badges34 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 6

You could rely on Socket.bufferedamount (never tried)

http://www.whatwg/specs/web-apps/current-work/multipage/network.html#dom-websocket-bufferedamount

var socket = new WebSocket('ws://game.example.:12010/updates');
socket.onopen = function () {
    setInterval(function() {
        if (socket.bufferedAmount == 0){
          // Im' not busy anymore - set a flag or something like that
        }
    }, 50);
};

Or implement an acknowledge answer from the server for every client message (tried, works fine)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744836259a4596278.html

相关推荐

  • javascript - Determine if a websocket send() is finished - Stack Overflow

    Is there a way to get notified if a certain send() has finished? As i noticed the send() function is no

    2天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信