Add method Addr to client.

This commit is contained in:
Juliusz Chroboczek
2024-04-30 18:17:00 +02:00
parent b7f9ef00b6
commit e7e8a9b555
4 changed files with 23 additions and 3 deletions
+8 -1
View File
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"log"
"net"
"os"
"sync"
"time"
@@ -58,6 +59,7 @@ func isWSNormalError(err error) bool {
type webClient struct {
group *group.Group
addr net.Addr
id string
username string
permissions []string
@@ -77,6 +79,10 @@ func (c *webClient) Group() *group.Group {
return c.group
}
func (c *webClient) Addr() net.Addr {
return c.addr
}
func (c *webClient) Id() string {
return c.id
}
@@ -818,7 +824,7 @@ func readMessage(conn *websocket.Conn, m *clientMessage) error {
const protocolVersion = "2"
func StartClient(conn *websocket.Conn) (err error) {
func StartClient(conn *websocket.Conn, addr net.Addr) (err error) {
var m clientMessage
err = readMessage(conn, &m)
@@ -849,6 +855,7 @@ func StartClient(conn *websocket.Conn) (err error) {
}
c := &webClient{
addr: addr,
id: m.Id,
actions: unbounded.New[any](),
done: make(chan struct{}),
+8 -2
View File
@@ -3,6 +3,7 @@ package rtpconn
import (
"context"
"errors"
"net"
"sync"
"github.com/jech/galene/conn"
@@ -12,6 +13,7 @@ import (
type WhipClient struct {
group *group.Group
addr net.Addr
id string
token string
username string
@@ -21,14 +23,18 @@ type WhipClient struct {
connection *rtpUpConnection
}
func NewWhipClient(g *group.Group, id string, token string) *WhipClient {
return &WhipClient{group: g, id: id, token: token}
func NewWhipClient(g *group.Group, id string, token string, addr net.Addr) *WhipClient {
return &WhipClient{group: g, id: id, token: token, addr: addr}
}
func (c *WhipClient) Group() *group.Group {
return c.group
}
func (c *WhipClient) Addr() net.Addr {
return c.addr
}
func (c *WhipClient) Id() string {
return c.id
}