【发布时间】:2021-02-22 08:42:39
【问题描述】:
所以,我正在为我的 React Native 应用程序使用 Django REST 框架构建一个 API。现在我想实现一个聊天功能,我想利用 Django Channels 通过 TCP 连接构建一个实时聊天功能。现在我读到我无法使用 Django Channels 构建实时 API。这是否意味着,我不能在我的服务器上使用 Django Channels 和在我的 React Native APP 中使用 this?:
var ws = new WebSocket('ws://host.com/path');
ws.onopen = () => {
// connection opened
ws.send('something'); // send a message
};
ws.onmessage = (e) => {
// a message was received
console.log(e.data);
};
ws.onerror = (e) => {
// an error occurred
console.log(e.message);
};
ws.onclose = (e) => {
// connection closed
console.log(e.code, e.reason);
};
我确实理解它,就像另一个版本的 HTTP(S) 连接或某种 :)
【问题讨论】:
标签: django react-native real-time django-channels