我正在使用以下技术:
Django Channels 2.1.2,ReactJS + reconnecting-websocket软件包
对于consumers.py
Location
对于routinig.py
while (cursor.moveToNext()) {
Location savedLocation = new Location();
savedLocation.setId(cursor.getInt(cursor.getColumnIndex(SLTable.COLUMN_ID)));
savedLocation.setTitle(cursor.getString(cursor.getColumnIndex(SLTable.COLUMN_TITLE)));
savedLocation.setLat(cursor.getDouble(cursor.getColumnIndex(SLTable.COLUMN_LAT)));
savedLocation.setLng(cursor.getDouble(cursor.getColumnIndex(SLTable.COLUMN_LNG)));
savedLocations.add(savedLocation);
}
对于ReactJS,我使用的是与套接字连接
class ChatConsumer(AsyncConsumer):
async def websocket_connect(self, event):
me = self.scope['user']
print(str(self.scope['user']))
但是Django没有选择范围内的任何用户?
对于React,我将用户和令牌存储在cookie中。
我认为这是ReactJS的错误,但是有人可以帮帮我吗?谢谢!