mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
⭐ feat(maitred): Update maitred - hookup to the API (#198)
## Description We are attempting to hookup maitred to the API Maitred duties will be: - [ ] Hookup to the API - [ ] Wait for signal (from the API) to start Steam - [ ] Stop signal to stop the gaming session, clean up Steam... and maybe do the backup ## Summary by CodeRabbit - **New Features** - Introduced Docker-based deployment configurations for both the main and relay applications. - Added new API endpoints enabling real-time machine messaging and enhanced IoT operations. - Expanded database schema and actor types to support improved machine tracking. - **Improvements** - Enhanced real-time communication and relay management with streamlined room handling. - Upgraded dependencies, logging, and error handling for greater stability and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: DatCaptainHorse <DatCaptainHorse@users.noreply.github.com> Co-authored-by: Kristian Ollikainen <14197772+DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
@@ -1,30 +1,38 @@
|
||||
package relay
|
||||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/google/uuid"
|
||||
"github.com/oklog/ulid/v2"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"log/slog"
|
||||
"math/rand"
|
||||
"relay/internal/common"
|
||||
"relay/internal/connections"
|
||||
)
|
||||
|
||||
type Participant struct {
|
||||
ID uuid.UUID //< Internal IDs are useful to keeping unique internal track and not have conflicts later
|
||||
ID ulid.ULID //< Internal IDs are useful to keeping unique internal track and not have conflicts later
|
||||
Name string
|
||||
WebSocket *SafeWebSocket
|
||||
WebSocket *connections.SafeWebSocket
|
||||
PeerConnection *webrtc.PeerConnection
|
||||
DataChannel *NestriDataChannel
|
||||
DataChannel *connections.NestriDataChannel
|
||||
}
|
||||
|
||||
func NewParticipant(ws *SafeWebSocket) *Participant {
|
||||
func NewParticipant(ws *connections.SafeWebSocket) *Participant {
|
||||
id, err := common.NewULID()
|
||||
if err != nil {
|
||||
slog.Error("Failed to create ULID for Participant", "err", err)
|
||||
return nil
|
||||
}
|
||||
return &Participant{
|
||||
ID: uuid.New(),
|
||||
ID: id,
|
||||
Name: createRandomName(),
|
||||
WebSocket: ws,
|
||||
}
|
||||
}
|
||||
|
||||
func (vw *Participant) addTrack(trackLocal *webrtc.TrackLocal) error {
|
||||
rtpSender, err := vw.PeerConnection.AddTrack(*trackLocal)
|
||||
func (p *Participant) addTrack(trackLocal *webrtc.TrackLocalStaticRTP) error {
|
||||
rtpSender, err := p.PeerConnection.AddTrack(trackLocal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -41,22 +49,22 @@ func (vw *Participant) addTrack(trackLocal *webrtc.TrackLocal) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vw *Participant) signalOffer() error {
|
||||
if vw.PeerConnection == nil {
|
||||
return fmt.Errorf("peer connection is nil for participant: '%s' - cannot signal offer", vw.ID)
|
||||
func (p *Participant) signalOffer() error {
|
||||
if p.PeerConnection == nil {
|
||||
return fmt.Errorf("peer connection is nil for participant: '%s' - cannot signal offer", p.ID)
|
||||
}
|
||||
|
||||
offer, err := vw.PeerConnection.CreateOffer(nil)
|
||||
offer, err := p.PeerConnection.CreateOffer(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = vw.PeerConnection.SetLocalDescription(offer)
|
||||
err = p.PeerConnection.SetLocalDescription(offer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return vw.WebSocket.SendSDPMessageWS(offer)
|
||||
return p.WebSocket.SendSDPMessageWS(offer)
|
||||
}
|
||||
|
||||
var namesFirst = []string{"Happy", "Sad", "Angry", "Calm", "Excited", "Bored", "Confused", "Confident", "Curious", "Depressed", "Disappointed", "Embarrassed", "Energetic", "Fearful", "Frustrated", "Glad", "Guilty", "Hopeful", "Impatient", "Jealous", "Lonely", "Motivated", "Nervous", "Optimistic", "Pessimistic", "Proud", "Relaxed", "Shy", "Stressed", "Surprised", "Tired", "Worried"}
|
||||
|
||||
Reference in New Issue
Block a user