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?
1 Answer
Reset to default 6You 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
评论列表(0条)