File tree Expand file tree Collapse file tree 4 files changed +23
-4
lines changed Expand file tree Collapse file tree 4 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
1
package lksdk
2
2
3
3
import (
4
+ "time"
5
+
6
+ "github.com/livekit/protocol/utils/guid"
4
7
"google.golang.org/protobuf/proto"
5
8
6
9
"github.com/livekit/protocol/livekit"
@@ -15,7 +18,8 @@ type DataPacket interface {
15
18
// Compile-time assertion for all supported data packet types.
16
19
var (
17
20
_ DataPacket = (* UserDataPacket )(nil )
18
- _ DataPacket = (* livekit .SipDTMF )(nil ) // implemented in the protocol package
21
+ _ DataPacket = (* livekit .SipDTMF )(nil ) // implemented in the protocol package
22
+ _ DataPacket = (* livekit .ChatMessage )(nil ) // implemented in the protocol package
19
23
)
20
24
21
25
// UserData is a custom user data that can be sent via WebRTC.
@@ -43,6 +47,18 @@ func (p *UserDataPacket) ToProto() *livekit.DataPacket {
43
47
}}
44
48
}
45
49
50
+ // ChatMessage creates a chat message that can be sent via WebRTC.
51
+ func ChatMessage (ts time.Time , text string ) * livekit.ChatMessage {
52
+ if ts .IsZero () {
53
+ ts = time .Now ()
54
+ }
55
+ return & livekit.ChatMessage {
56
+ Id : guid .New ("MSG_" ),
57
+ Timestamp : ts .UnixMilli (),
58
+ Message : text ,
59
+ }
60
+ }
61
+
46
62
// receiving
47
63
48
64
type DataReceiveParams struct {
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import (
30
30
"github.com/livekit/protocol/livekit"
31
31
protoLogger "github.com/livekit/protocol/logger"
32
32
protosignalling "github.com/livekit/protocol/signalling"
33
+
33
34
"github.com/livekit/server-sdk-go/v2/signalling"
34
35
)
35
36
@@ -598,6 +599,8 @@ func (e *RTCEngine) handleDataPacket(msg webrtc.DataChannelMessage) {
598
599
})
599
600
case * livekit.DataPacket_SipDtmf :
600
601
e .engineHandler .OnDataPacket (identity , msg .SipDtmf )
602
+ case * livekit.DataPacket_ChatMessage :
603
+ e .engineHandler .OnDataPacket (identity , msg .ChatMessage )
601
604
case * livekit.DataPacket_Transcription :
602
605
e .engineHandler .OnTranscription (msg .Transcription )
603
606
case * livekit.DataPacket_RpcRequest :
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ require (
10
10
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731
11
11
github.com/livekit/media-sdk v0.0.0-20250518151703-b07af88637c5
12
12
github.com/livekit/mediatransportutil v0.0.0-20250519131108-fb90f5acfded
13
- github.com/livekit/protocol v1.39.4-0.20250725083335-7313a8195a4b
13
+ github.com/livekit/protocol v1.39.4-0.20250729125216-1a9149204316
14
14
github.com/magefile/mage v1.15.0
15
15
github.com/pion/dtls/v3 v3.0.6
16
16
github.com/pion/interceptor v0.1.40
Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ github.com/livekit/media-sdk v0.0.0-20250518151703-b07af88637c5 h1:aFCwt/rticj5L
99
99
github.com/livekit/media-sdk v0.0.0-20250518151703-b07af88637c5 /go.mod h1:7ssWiG+U4xnbvLih9WiZbhQP6zIKMjgXdUtIE1bm/E8 =
100
100
github.com/livekit/mediatransportutil v0.0.0-20250519131108-fb90f5acfded h1:ylZPdnlX1RW9Z15SD4mp87vT2D2shsk0hpLJwSPcq3g =
101
101
github.com/livekit/mediatransportutil v0.0.0-20250519131108-fb90f5acfded /go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A =
102
- github.com/livekit/protocol v1.39.4-0.20250725083335-7313a8195a4b h1:uxvoeGd0vmGDIL0JyLLV9h2o97tpt3rR9s4ikuLVz/g =
103
- github.com/livekit/protocol v1.39.4-0.20250725083335-7313a8195a4b /go.mod h1:YlgUxAegtU8jZ0tVXoIV/4fHeHqqLvS+6JnPKDbpFPU =
102
+ github.com/livekit/protocol v1.39.4-0.20250729125216-1a9149204316 h1:eVP2NW+wdzPfzk2qDy1vXLGOnok5stxMR3zg5ZfT150 =
103
+ github.com/livekit/protocol v1.39.4-0.20250729125216-1a9149204316 /go.mod h1:YlgUxAegtU8jZ0tVXoIV/4fHeHqqLvS+6JnPKDbpFPU =
104
104
github.com/livekit/psrpc v0.6.1-0.20250724161801-262a822e7cd7 h1:x50axcjXwfwnII7sMhJPyZ6f5LpPapZtsp75KJX8nIQ =
105
105
github.com/livekit/psrpc v0.6.1-0.20250724161801-262a822e7cd7 /go.mod h1:kmD+AZPkWu0MaXIMv57jhNlbiSZZ/Jx4bzlxBDVmJes =
106
106
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg =
You can’t perform that action at this time.
0 commit comments