-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Hi, @muka
Thank you for the efforts of doing this project.
I'm working on a simple open source project. I'm a total newbie in go, but I managed to do an audio call from a webpage where I implemented the PeerJS client.
The issue is that even the call appears as answered in go, the peers are not connected. Do I miss something?
Thanks!
2024/07/11 12:08:13 My peer ID: f81b8d75-3ee0-4a22-ab46-eea667aeb499
2024/07/11 12:08:17 Received call
2024/07/11 12:08:17 Call answered successfully
main.go
package main
import (
peer "github.com/muka/peerjs-go"
"github.com/pion/webrtc/v3"
"log"
)
func main() {
options := peer.NewOptions() // Add any specific options if needed
// Create a new peer with these options
myPeer, err := peer.NewPeer("f81b8d75-3ee0-4a22-ab46-eea667aeb499", options)
if err != nil {
log.Fatalf("Failed to create peer: %v", err)
}
log.Printf("My peer ID: %s\n", myPeer.ID)
defer myPeer.Close()
myPeer.On("call", func(raw interface{}) {
log.Println("Received call")
call, ok := raw.(*peer.MediaConnection)
if !ok {
log.Println("Error: Received object is not a MediaConnection")
return
}
audioTrack, err := webrtc.NewTrackLocalStaticRTP(webrtc.RTPCodecCapability{MimeType: "audio/opus"}, "audio", "pion")
if err != nil {
panic(err)
}
// Answer the call with the local audio track and the specified options
call.Answer(audioTrack, nil)
log.Println("Call answered successfully")
})
myPeer.On("stream", func(stream interface{}) {
log.Println("Received remote stream")
})
// Prevent the main thread from exiting
select {}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels