steep-balloon-41261
07/21/2023, 4:07 PMpolite-kilobyte-67570
07/21/2023, 4:45 PMuseDataChannel hook that returns a `send`methodjolly-rocket-99624
07/21/2023, 4:56 PMjolly-rocket-99624
07/21/2023, 4:56 PMonMessage parameter, but don't know how to use itjolly-rocket-99624
07/21/2023, 5:04 PMjolly-rocket-99624
07/21/2023, 5:05 PMred-father-14173
07/21/2023, 5:05 PMuseDataChannel react hook that should manage all the logic from the client SDK, I'm encoding and decoding messages, but it seems that once I send one, the isSending is always true and other participants never get the message.
No error is ever logged or anything, is there a standard way of sending ephemeral messages to all participants? Is sending encoded emojis ok? Any help is appreciated.
Here's my code
const { message, send, isSending } = useDataChannel("reactions", (message) => {
console.warn(
`%cmessage ||${JSON.stringify(message, null, 2)}|| decoded ${decoder.decode(message?.payload)}`,
"🐦;background: lightblue; color: #444; padding: 3px; border-radius: 5px;"
);
});
[...]
const data = encoder.encode("👍");
send(data);polite-kilobyte-67570
07/21/2023, 5:07 PMjolly-rocket-99624
07/21/2023, 5:07 PMpolite-kilobyte-67570
07/21/2023, 5:08 PMjolly-rocket-99624
07/21/2023, 5:10 PM"livekit-client": "^1.9.6",red-father-14173
07/21/2023, 5:10 PM"livekit-client": "^1.11.3",
"@livekit/components-react": "^1.0.6",
"@livekit/components-styles": "^1.0.2"
Just as an addendum, I'm using the chat example from the livekit stream repo without any issuesjolly-rocket-99624
07/21/2023, 5:11 PMpolite-kilobyte-67570
07/21/2023, 5:31 PMReact.useEffect(() => {
send(new TextEncoder().encode('test'), { kind: DataPacket_Kind.RELIABLE });
}, []);red-father-14173
07/21/2023, 5:32 PMsend function is being called as the isSending is returning true afterred-father-14173
07/21/2023, 5:34 PMonMessage from useDataChannel hook runs for every participant, including the one that sent the message? Or just for every other participant?red-father-14173
07/21/2023, 5:41 PMisSending remained true at all times after joining the room;polite-kilobyte-67570
07/21/2023, 6:38 PMred-father-14173
07/21/2023, 7:08 PMpolite-kilobyte-67570
07/21/2023, 7:12 PMsetLogLevel('debug') from livekit-client directly. you should see DataReceived events in the console then.polite-kilobyte-67570
07/21/2023, 7:12 PMred-father-14173
07/21/2023, 7:13 PMred-father-14173
07/21/2023, 7:27 PMParticipantPermissions and couldn't find the defaults for canPublishData when canPublish is set to false.
The data is sent correctly once I set canPublish to true on all participants, but if set to false, they can no longer publish data.red-father-14173
07/21/2023, 7:28 PMisSending in the useDataChannel stays true even after sending the data.red-father-14173
07/21/2023, 8:04 PMcanPublishData is false by default (or I may just not be familiar with the whole codebase) https://github.com/livekit/server-sdk-js/blob/main/src/proto/livekit_models.ts#L1275
Unfortunately I don't control the server I'm using to test if data messages work with canPublish set to false and canPublishData set to true, will check with the responsible team.