python flask websocket sleep_flask上使用websocket

Flask-SocketIO Test

$(document).ready(function(){varsocket=io.connect('http://' +document.domain+ ':' +location.port+ '/test');

socket.on('my_response',function(msg) {

$('#log').append('

Received:' +msg.data+ '

');

});

$('form#emit').submit(function(event) {

socket.emit('my_event', {data: $('#emit_data').val()});return false;

});

$('form#broadcast').submit(function(event) {

socket.emit('my_broadcast_event', {data: $('#broadcast_data').val()});return false;

});

$('form#join').submit(function(event) {

socket.emit('join', {room: $('#join_room').val()});return false;

});

$('form#leave').submit(function(event) {

socket.emit('leave', {room: $('#leave_room').val()});return false;

});

$('form#send_room').submit(function(event) {

socket.emit('my_room_event', {room: $('#room_name').val(), data: $('#room_data').val()});return false;

});

$('form#close').submit(function(event) {

socket.emit('close_room', {room: $('#close_room').val()});return false;

});

$('form#disconnect').submit(function(event) {

socket.emit('disconnect_request');return false;

});

});

Flask-SocketIO Test

Async mode is: {{ async_mode }}

Average ping/pong latency: ms

Send:

Receive:

你可能感兴趣的:(python,flask,websocket,sleep)