我想在用户通过flask-login登录后确认用户在flasks-socketio但是我从服务器上收到一条消息,说明用户没有登录或没有登录,虽然我通过flask-log登录在,所以如何克服这个?
def disconnect():
print ("Your Not Authenticated")
@socketio.on("my home", namespace="/home")
def on_my_home(username):
if current_user.is_authenticated:
users[username] = request.sid
print ("Your Was Authenticated")
else:
disconnect()
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var socket = io.connect("http://127.0.0.1:5000/home");
socket.on("connect", function() {
var username = "{{ current_user.username }}";
socket.emit("my home", username);
});
});
</script>