Browse Source

Merge pull request #192 from longsleep/room-types

Room types
pull/194/head
Simon Eisenmann 10 years ago
parent
commit
e9f617b26f
  1. 72
      doc/CHANNELING-API.txt
  2. 27
      src/app/spreed-webrtc-server/channelling.go
  3. 28
      src/app/spreed-webrtc-server/channelling_api.go
  4. 20
      src/app/spreed-webrtc-server/channelling_api_test.go
  5. 46
      src/app/spreed-webrtc-server/room_manager.go
  6. 18
      src/app/spreed-webrtc-server/room_manager_test.go
  7. 24
      src/app/spreed-webrtc-server/roomworker.go
  8. 6
      src/app/spreed-webrtc-server/roomworker_test.go
  9. 5
      src/app/spreed-webrtc-server/session.go
  10. 2
      static/js/app.js
  11. 3
      static/js/mediastream/api.js

72
doc/CHANNELING-API.txt

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
Spreed WebRTC Channeling API v1.3.0
Spreed WebRTC Channeling API v1.4.0
=================================================
(c)2014 struktur AG
(c)2015 struktur AG
The server provides a Websocket connection end point as channeling API to
share peer information for peer to peer connectivity.
@ -117,6 +117,7 @@ Special purpose documents for channling @@ -117,6 +117,7 @@ Special purpose documents for channling
"Suserid": "",
"Token": "some-very-long-string",
"Version": "server-version-number",
"ApiVersion": 1.4,
"Turn": {
"username": "turn-username",
"password": "turn-password",
@ -136,21 +137,26 @@ Special purpose documents for channling @@ -136,21 +137,26 @@ Special purpose documents for channling
Keys:
Type : Self (string)
Id : Public Session id for this connection (string).
Sid : Secure (non public) id for this session (string).
Userid : User id if this session belongs to an authenticated user. Else empty.
Suserid : Secure (non public) user id if session has an user id. Else empty.
Token : Security token (string), to restablish connection with the same
session. Pass the value as URL query parameter t, to the websocket URL.
Version : Server version number. Use this to detect server upgrades.
Turn : Mapping (interface{}) to contain TURN server details, like
urls, password and username. See
http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
and TURN REST API section in
https://code.google.com/p/rfc5766-turn-server/wiki/turnserver
for details.
Stun : Array with STUN server URLs.
Type : Self (string)
Id : Public Session id for this connection (string).
Sid : Secure (non public) id for this session (string).
Userid : User id if this session belongs to an authenticated user.
Else empty.
Suserid : Secure (non public) user id if session has an user id.
Else empty.
Token : Security token (string), to restablish connection with the
same session. Pass the value as URL query parameter t, to
the websocket URL.
Version : Server version number. Use this to detect server upgrades.
ApiVersion : Server channeling API base version. Use this version to select
client side compatibility with the connected server.
Turn : Mapping (interface{}) to contain TURN server details, like
urls, password and username. See
http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
and TURN REST API section in
https://code.google.com/p/rfc5766-turn-server/wiki/turnserver
for details.
Stun : Array with STUN server URLs.
You can also send an empty Self document to the server to make the server
transmit a fresh Self document (eg. to refresh when ttl was reached). Please
@ -162,9 +168,10 @@ Special purpose documents for channling @@ -162,9 +168,10 @@ Special purpose documents for channling
{
Type: "Hello",
Hello: {
Version: "1.0.0",
Ua: "Test client 1.0",
Id: "",
"Version": "1.0.0",
"Ua": "Test client 1.0",
"Name": "",
"Type": "",
"Credentials": {...}
}
}
@ -179,7 +186,10 @@ Special purpose documents for channling @@ -179,7 +186,10 @@ Special purpose documents for channling
Version : Channel protocol version (string).
Ua : User agent description (string).
Id : Room id. The default Room has the empty string Id ("") (string).
Name : Room name. The default Room has the empty string name ("") (string).
Type : Room type. Use empty string to let the server select the
default type.
Id : Same as 'Name' (kept for compatibility).
Credentials : An optional RoomCredentials document containing room
authentication information. See the Room document for
information on how such credentials should be handled after
@ -218,10 +228,10 @@ Special purpose documents for channling @@ -218,10 +228,10 @@ Special purpose documents for channling
Keys under Welcome:
Room: Contains the current state of the room, see the description of
the Room document for more details.
Users: Contains the user list for the room, see the description of
the Users document for more details.
Room : Contains the current state of the room, see the description of
the Room document for more details.
Users : Contains the user list for the room, see the description of
the Users document for more details.
RoomCredentials
@ -241,7 +251,7 @@ Special purpose documents for channling @@ -241,7 +251,7 @@ Special purpose documents for channling
Room
{
"Type": "Room",
"Type": "room-type",
"Name": "room-name-here"
"Credentials": {...}
}
@ -256,8 +266,10 @@ Special purpose documents for channling @@ -256,8 +266,10 @@ Special purpose documents for channling
Keys under Room:
Name : The human readable ID of the room, currently must be globally
unique.
Type : The room type. This field should only be send to alter
the room type. It will always contain the type of the room
when returned by the server.
Name : The human readable name of the room.
Credentials : Optional authentication information for the room, see the
documentation of the RoomCredentials document for more
details. This field shall only be present when sending or
@ -423,8 +435,8 @@ Additional types for session listing and notifications @@ -423,8 +435,8 @@ Additional types for session listing and notifications
}
'buddyPicture' can be in next formats:
1. Base64 encoded string of an image.
'buddyPicture' can be in next formats:
1. Base64 encoded string of an image.
Example: data:image/jpeg;base64,/9j/4...
2. url subpath to query REST API. Please refer to REST API for more information
Example: img:8nG33oDk8Yv8fvK6IphL/6vjI2NLigcET/picture.jpg

27
src/app/spreed-webrtc-server/channelling.go

@ -42,7 +42,9 @@ type DataRoomCredentials struct { @@ -42,7 +42,9 @@ type DataRoomCredentials struct {
type DataHello struct {
Version string
Ua string
Id string
Id string // Compatibility with old clients.
Name string // Room name.
Type string // Room type.
Credentials *DataRoomCredentials
}
@ -53,8 +55,8 @@ type DataWelcome struct { @@ -53,8 +55,8 @@ type DataWelcome struct {
}
type DataRoom struct {
Type string
Name string
Type string // Room type.
Name string // Room name.
Credentials *DataRoomCredentials
}
@ -77,15 +79,16 @@ type DataAnswer struct { @@ -77,15 +79,16 @@ type DataAnswer struct {
}
type DataSelf struct {
Type string
Id string
Sid string
Userid string
Suserid string
Token string
Version string
Turn *DataTurn
Stun []string
Type string
Id string
Sid string
Userid string
Suserid string
Token string
Version string // Server version.
ApiVersion float64 // Server channelling API version.
Turn *DataTurn
Stun []string
}
type DataTurn struct {

28
src/app/spreed-webrtc-server/channelling_api.go

@ -28,6 +28,7 @@ import ( @@ -28,6 +28,7 @@ import (
const (
maxConferenceSize = 100
apiVersion = 1.4 // Keep this in sync with CHANNELING-API docs.Hand
)
type ChannellingAPI interface {
@ -171,15 +172,16 @@ func (api *channellingAPI) HandleSelf(session *Session) (*DataSelf, error) { @@ -171,15 +172,16 @@ func (api *channellingAPI) HandleSelf(session *Session) (*DataSelf, error) {
log.Println("Created new session token", len(token), token)
self := &DataSelf{
Type: "Self",
Id: session.Id,
Sid: session.Sid,
Userid: session.Userid(),
Suserid: api.EncodeSessionUserID(session),
Token: token,
Version: api.Version,
Turn: api.CreateTurnData(session),
Stun: api.StunURIs,
Type: "Self",
Id: session.Id,
Sid: session.Sid,
Userid: session.Userid(),
Suserid: api.EncodeSessionUserID(session),
Token: token,
Version: api.Version,
ApiVersion: apiVersion,
Turn: api.CreateTurnData(session),
Stun: api.StunURIs,
}
return self, nil
@ -189,7 +191,13 @@ func (api *channellingAPI) HandleHello(session *Session, hello *DataHello, sende @@ -189,7 +191,13 @@ func (api *channellingAPI) HandleHello(session *Session, hello *DataHello, sende
// TODO(longsleep): Filter room id and user agent.
session.Update(&SessionUpdate{Types: []string{"Ua"}, Ua: hello.Ua})
room, err := session.JoinRoom(hello.Id, hello.Credentials, sender)
// Compatibily for old clients.
roomName := hello.Name
if roomName == "" {
roomName = hello.Id
}
room, err := session.JoinRoom(roomName, hello.Type, hello.Credentials, sender)
if err != nil {
return nil, err
}

20
src/app/spreed-webrtc-server/channelling_api_test.go

@ -23,6 +23,7 @@ package main @@ -23,6 +23,7 @@ package main
import (
"errors"
"fmt"
"testing"
)
@ -48,9 +49,9 @@ func (fake *fakeRoomManager) RoomUsers(session *Session) []*DataSession { @@ -48,9 +49,9 @@ func (fake *fakeRoomManager) RoomUsers(session *Session) []*DataSession {
return fake.roomUsers
}
func (fake *fakeRoomManager) JoinRoom(id string, _ *DataRoomCredentials, session *Session, sessionAuthenticated bool, _ Sender) (*DataRoom, error) {
func (fake *fakeRoomManager) JoinRoom(id, roomName, roomType string, _ *DataRoomCredentials, session *Session, sessionAuthenticated bool, _ Sender) (*DataRoom, error) {
fake.joinedID = id
return &DataRoom{Name: id}, fake.joinError
return &DataRoom{Name: roomName, Type: roomType}, fake.joinError
}
func (fake *fakeRoomManager) LeaveRoom(roomID, sessionID string) {
@ -65,6 +66,13 @@ func (fake *fakeRoomManager) UpdateRoom(_ *Session, _ *DataRoom) (*DataRoom, err @@ -65,6 +66,13 @@ func (fake *fakeRoomManager) UpdateRoom(_ *Session, _ *DataRoom) (*DataRoom, err
return fake.updatedRoom, fake.updateError
}
func (fake *fakeRoomManager) MakeRoomID(roomName, roomType string) string {
if roomType == "" {
roomType = "Room"
}
return fmt.Sprintf("%s:%s", roomType, roomName)
}
func NewTestChannellingAPI() (ChannellingAPI, *fakeClient, *Session, *fakeRoomManager) {
client, roomManager := &fakeClient{}, &fakeRoomManager{}
session := &Session{
@ -77,10 +85,10 @@ func NewTestChannellingAPI() (ChannellingAPI, *fakeClient, *Session, *fakeRoomMa @@ -77,10 +85,10 @@ func NewTestChannellingAPI() (ChannellingAPI, *fakeClient, *Session, *fakeRoomMa
}
func Test_ChannellingAPI_OnIncoming_HelloMessage_JoinsTheSelectedRoom(t *testing.T) {
roomID, ua := "foobar", "unit tests"
roomID, roomName, ua := "Room:foobar", "foobar", "unit tests"
api, client, session, roomManager := NewTestChannellingAPI()
api.OnIncoming(client, session, &DataIncoming{Type: "Hello", Hello: &DataHello{Id: roomID, Ua: ua}})
api.OnIncoming(client, session, &DataIncoming{Type: "Hello", Hello: &DataHello{Id: roomName, Ua: ua}})
if roomManager.joinedID != roomID {
t.Errorf("Expected to have joined room %v, but got %v", roomID, roomManager.joinedID)
@ -101,10 +109,10 @@ func Test_ChannellingAPI_OnIncoming_HelloMessage_JoinsTheSelectedRoom(t *testing @@ -101,10 +109,10 @@ func Test_ChannellingAPI_OnIncoming_HelloMessage_JoinsTheSelectedRoom(t *testing
}
func Test_ChannellingAPI_OnIncoming_HelloMessage_LeavesAnyPreviouslyJoinedRooms(t *testing.T) {
roomID := "foobar"
roomID, roomName := "Room:foobar", "foobar"
api, client, session, roomManager := NewTestChannellingAPI()
api.OnIncoming(client, session, &DataIncoming{Type: "Hello", Hello: &DataHello{Id: roomID}})
api.OnIncoming(client, session, &DataIncoming{Type: "Hello", Hello: &DataHello{Id: roomName}})
api.OnIncoming(client, session, &DataIncoming{Type: "Hello", Hello: &DataHello{Id: "baz"}})
if roomManager.leftID != roomID {

46
src/app/spreed-webrtc-server/room_manager.go

@ -22,15 +22,17 @@ @@ -22,15 +22,17 @@
package main
import (
"fmt"
"log"
"sync"
)
type RoomStatusManager interface {
RoomUsers(*Session) []*DataSession
JoinRoom(roomID string, credentials *DataRoomCredentials, session *Session, sessionAuthenticated bool, sender Sender) (*DataRoom, error)
JoinRoom(roomID, roomName, roomType string, credentials *DataRoomCredentials, session *Session, sessionAuthenticated bool, sender Sender) (*DataRoom, error)
LeaveRoom(roomID, sessionID string)
UpdateRoom(*Session, *DataRoom) (*DataRoom, error)
MakeRoomID(roomName, roomType string) string
}
type Broadcaster interface {
@ -51,16 +53,25 @@ type roomManager struct { @@ -51,16 +53,25 @@ type roomManager struct {
sync.RWMutex
*Config
OutgoingEncoder
roomTable map[string]RoomWorker
roomTable map[string]RoomWorker
globalRoomID string
defaultRoomID string
roomTypeDefault string
}
func NewRoomManager(config *Config, encoder OutgoingEncoder) RoomManager {
return &roomManager{
rm := &roomManager{
sync.RWMutex{},
config,
encoder,
make(map[string]RoomWorker),
"",
"",
"Room",
}
rm.globalRoomID = rm.MakeRoomID(config.globalRoomID, "")
rm.defaultRoomID = rm.MakeRoomID("", "")
return rm
}
func (rooms *roomManager) RoomUsers(session *Session) []*DataSession {
@ -71,12 +82,12 @@ func (rooms *roomManager) RoomUsers(session *Session) []*DataSession { @@ -71,12 +82,12 @@ func (rooms *roomManager) RoomUsers(session *Session) []*DataSession {
return []*DataSession{}
}
func (rooms *roomManager) JoinRoom(roomID string, credentials *DataRoomCredentials, session *Session, sessionAuthenticated bool, sender Sender) (*DataRoom, error) {
if roomID == "" && !rooms.DefaultRoomEnabled {
func (rooms *roomManager) JoinRoom(roomID, roomName, roomType string, credentials *DataRoomCredentials, session *Session, sessionAuthenticated bool, sender Sender) (*DataRoom, error) {
if roomID == rooms.defaultRoomID && !rooms.DefaultRoomEnabled {
return nil, NewDataError("default_room_disabled", "The default room is not enabled")
}
roomWorker, err := rooms.GetOrCreate(roomID, credentials, sessionAuthenticated)
roomWorker, err := rooms.GetOrCreate(roomID, roomName, roomType, credentials, sessionAuthenticated)
if err != nil {
return nil, err
}
@ -91,14 +102,18 @@ func (rooms *roomManager) LeaveRoom(roomID, sessionID string) { @@ -91,14 +102,18 @@ func (rooms *roomManager) LeaveRoom(roomID, sessionID string) {
}
func (rooms *roomManager) UpdateRoom(session *Session, room *DataRoom) (*DataRoom, error) {
if !session.Hello || session.Roomid != room.Name {
var roomID string
if room != nil {
roomID = rooms.MakeRoomID(room.Name, room.Type)
}
if !session.Hello || session.Roomid != roomID {
return nil, NewDataError("not_in_room", "Cannot update other rooms")
}
// XXX(lcooper): We'll process and send documents without this field
// correctly, however clients cannot not handle it currently.
room.Type = "Room"
if roomWorker, ok := rooms.Get(session.Roomid); ok {
return room, roomWorker.Update(room)
} else {
// Set default room type if not found.
room.Type = rooms.roomTypeDefault
}
// TODO(lcooper): We should almost certainly return an error in this case.
return room, nil
@ -145,7 +160,7 @@ func (rooms *roomManager) Get(roomID string) (room RoomWorker, ok bool) { @@ -145,7 +160,7 @@ func (rooms *roomManager) Get(roomID string) (room RoomWorker, ok bool) {
return
}
func (rooms *roomManager) GetOrCreate(roomID string, credentials *DataRoomCredentials, sessionAuthenticated bool) (RoomWorker, error) {
func (rooms *roomManager) GetOrCreate(roomID, roomName, roomType string, credentials *DataRoomCredentials, sessionAuthenticated bool) (RoomWorker, error) {
if rooms.AuthorizeRoomJoin && rooms.UsersEnabled && !sessionAuthenticated {
return nil, NewDataError("room_join_requires_account", "Room join requires a user account")
}
@ -167,7 +182,7 @@ func (rooms *roomManager) GetOrCreate(roomID string, credentials *DataRoomCreden @@ -167,7 +182,7 @@ func (rooms *roomManager) GetOrCreate(roomID string, credentials *DataRoomCreden
return nil, NewDataError("room_join_requires_account", "Room creation requires a user account")
}
room := NewRoomWorker(rooms, roomID, credentials)
room := NewRoomWorker(rooms, roomID, roomName, roomType, credentials)
rooms.roomTable[roomID] = room
rooms.Unlock()
go func() {
@ -196,3 +211,10 @@ func (rooms *roomManager) GlobalUsers() []*roomUser { @@ -196,3 +211,10 @@ func (rooms *roomManager) GlobalUsers() []*roomUser {
rooms.RUnlock()
return make([]*roomUser, 0)
}
func (rooms *roomManager) MakeRoomID(roomName, roomType string) string {
if roomType == "" {
roomType = rooms.roomTypeDefault
}
return fmt.Sprintf("%s:%s", roomType, roomName)
}

18
src/app/spreed-webrtc-server/room_manager_test.go

@ -36,16 +36,16 @@ func Test_RoomManager_JoinRoom_ReturnsAnErrorForUnauthenticatedSessionsWhenCreat @@ -36,16 +36,16 @@ func Test_RoomManager_JoinRoom_ReturnsAnErrorForUnauthenticatedSessionsWhenCreat
config.AuthorizeRoomCreation = true
unauthenticatedSession := &Session{}
_, err := roomManager.JoinRoom("foo", nil, unauthenticatedSession, false, nil)
_, err := roomManager.JoinRoom("Room:foo", "foo", "Room", nil, unauthenticatedSession, false, nil)
assertDataError(t, err, "room_join_requires_account")
authenticatedSession := &Session{userid: "9870457"}
_, err = roomManager.JoinRoom("foo", nil, authenticatedSession, true, nil)
_, err = roomManager.JoinRoom("Room:foo", "foo", "Room", nil, authenticatedSession, true, nil)
if err != nil {
t.Fatalf("Unexpected error %v joining room while authenticated", err)
}
_, err = roomManager.JoinRoom("foo", nil, unauthenticatedSession, false, nil)
_, err = roomManager.JoinRoom("Room:foo", "foo", "Room", nil, unauthenticatedSession, false, nil)
if err != nil {
t.Fatalf("Unexpected error %v joining room while unauthenticated", err)
}
@ -57,16 +57,16 @@ func Test_RoomManager_JoinRoom_ReturnsAnErrorForUnauthenticatedSessionsWhenJoinR @@ -57,16 +57,16 @@ func Test_RoomManager_JoinRoom_ReturnsAnErrorForUnauthenticatedSessionsWhenJoinR
config.AuthorizeRoomJoin = true
unauthenticatedSession := &Session{}
_, err := roomManager.JoinRoom("foo", nil, unauthenticatedSession, false, nil)
_, err := roomManager.JoinRoom("Room:foo", "foo", "Room", nil, unauthenticatedSession, false, nil)
assertDataError(t, err, "room_join_requires_account")
authenticatedSession := &Session{userid: "9870457"}
_, err = roomManager.JoinRoom("foo", nil, authenticatedSession, true, nil)
_, err = roomManager.JoinRoom("Room:foo", "foo", "Room", nil, authenticatedSession, true, nil)
if err != nil {
t.Fatalf("Unexpected error %v joining room while authenticated", err)
}
_, err = roomManager.JoinRoom("foo", nil, unauthenticatedSession, false, nil)
_, err = roomManager.JoinRoom("Room:foo", "foo", "Room", nil, unauthenticatedSession, false, nil)
assertDataError(t, err, "room_join_requires_account")
}
@ -79,15 +79,15 @@ func Test_RoomManager_UpdateRoom_ReturnsAnErrorIfNoRoomHasBeenJoined(t *testing. @@ -79,15 +79,15 @@ func Test_RoomManager_UpdateRoom_ReturnsAnErrorIfNoRoomHasBeenJoined(t *testing.
func Test_RoomManager_UpdateRoom_ReturnsAnErrorIfUpdatingAnUnjoinedRoom(t *testing.T) {
roomManager, _ := NewTestRoomManager()
session := &Session{Hello: true, Roomid: "foo"}
session := &Session{Hello: true, Roomid: "Room:foo"}
_, err := roomManager.UpdateRoom(session, &DataRoom{Name: "bar"})
assertDataError(t, err, "not_in_room")
}
func Test_RoomManager_UpdateRoom_ReturnsACorrectlyTypedDocument(t *testing.T) {
roomManager, _ := NewTestRoomManager()
session := &Session{Hello: true, Roomid: "foo"}
room, err := roomManager.UpdateRoom(session, &DataRoom{Name: session.Roomid})
session := &Session{Hello: true, Roomid: "Room:foo"}
room, err := roomManager.UpdateRoom(session, &DataRoom{Name: "foo"})
if err != nil {
t.Fatalf("Unexpected error %v updating room", err)
}

24
src/app/spreed-webrtc-server/roomworker.go

@ -56,7 +56,9 @@ type roomWorker struct { @@ -56,7 +56,9 @@ type roomWorker struct {
mutex sync.RWMutex
// Metadata.
Id string
id string
Name string
Type string
credentials *DataRoomCredentials
}
@ -65,13 +67,15 @@ type roomUser struct { @@ -65,13 +67,15 @@ type roomUser struct {
Sender
}
func NewRoomWorker(manager *roomManager, id string, credentials *DataRoomCredentials) RoomWorker {
func NewRoomWorker(manager *roomManager, roomID, roomName, roomType string, credentials *DataRoomCredentials) RoomWorker {
log.Printf("Creating worker for room '%s'\n", id)
log.Printf("Creating worker for room '%s'\n", roomID)
r := &roomWorker{
manager: manager,
Id: id,
id: roomID,
Name: roomName,
Type: roomType,
workers: make(chan func(), roomMaxWorkers),
expired: make(chan bool),
users: make(map[string]*roomUser),
@ -107,7 +111,7 @@ L: @@ -107,7 +111,7 @@ L:
if len(r.users) == 0 {
// Cleanup room when it is empty.
r.mutex.RUnlock()
log.Printf("Room worker not in use - cleaning up '%s'\n", r.Id)
log.Printf("Room worker not in use - cleaning up '%s'\n", r.id)
break L
} else {
r.mutex.RUnlock()
@ -149,7 +153,7 @@ func (r *roomWorker) Run(f func()) bool { @@ -149,7 +153,7 @@ func (r *roomWorker) Run(f func()) bool {
case r.workers <- f:
return true
default:
log.Printf("Room worker channel full or closed '%s'\n", r.Id)
log.Printf("Room worker channel full or closed '%s'\n", r.id)
return false
}
@ -159,6 +163,10 @@ func (r *roomWorker) Update(room *DataRoom) error { @@ -159,6 +163,10 @@ func (r *roomWorker) Update(room *DataRoom) error {
fault := make(chan error, 1)
worker := func() {
r.mutex.Lock()
// Enforce room type and name.
room.Type = r.Type
room.Name = r.Name
// Update credentials.
if room.Credentials != nil {
if len(room.Credentials.PIN) > 0 {
r.credentials = room.Credentials
@ -184,7 +192,7 @@ func (r *roomWorker) GetUsers() []*DataSession { @@ -184,7 +192,7 @@ func (r *roomWorker) GetUsers() []*DataSession {
session.Type = "Online"
sl = append(sl, session)
if len(sl) > maxUsersLength {
log.Println("Limiting users response length in channel", r.Id)
log.Println("Limiting users response length in channel", r.id)
return false
}
}
@ -264,7 +272,7 @@ func (r *roomWorker) Join(credentials *DataRoomCredentials, session *Session, se @@ -264,7 +272,7 @@ func (r *roomWorker) Join(credentials *DataRoomCredentials, session *Session, se
r.users[session.Id] = &roomUser{session, sender}
// NOTE(lcooper): Needs to be a copy, else we risk races with
// a subsequent modification of room properties.
result := joinResult{&DataRoom{Name: r.Id}, nil}
result := joinResult{&DataRoom{Name: r.Name, Type: r.Type}, nil}
r.mutex.Unlock()
results <- result
}

6
src/app/spreed-webrtc-server/roomworker_test.go

@ -26,18 +26,20 @@ import ( @@ -26,18 +26,20 @@ import (
)
const (
testRoomID string = "Room:a-room-name"
testRoomName string = "a-room-name"
testRoomType string = "Room"
)
func NewTestRoomWorker() RoomWorker {
worker := NewRoomWorker(&roomManager{Config: &Config{}}, testRoomName, nil)
worker := NewRoomWorker(&roomManager{Config: &Config{}}, testRoomID, testRoomName, testRoomType, nil)
go worker.Start()
return worker
}
func NewTestRoomWorkerWithPIN(t *testing.T) (RoomWorker, string) {
pin := "asdf"
worker := NewRoomWorker(&roomManager{Config: &Config{}}, testRoomName, &DataRoomCredentials{PIN: pin})
worker := NewRoomWorker(&roomManager{Config: &Config{}}, testRoomID, testRoomName, testRoomType, &DataRoomCredentials{PIN: pin})
go worker.Start()
return worker, pin
}

5
src/app/spreed-webrtc-server/session.go

@ -116,7 +116,8 @@ func (s *Session) RemoveSubscriber(id string) { @@ -116,7 +116,8 @@ func (s *Session) RemoveSubscriber(id string) {
s.mutex.Unlock()
}
func (s *Session) JoinRoom(roomID string, credentials *DataRoomCredentials, sender Sender) (*DataRoom, error) {
func (s *Session) JoinRoom(roomName, roomType string, credentials *DataRoomCredentials, sender Sender) (*DataRoom, error) {
roomID := s.RoomStatusManager.MakeRoomID(roomName, roomType)
s.mutex.Lock()
defer s.mutex.Unlock()
@ -133,7 +134,7 @@ func (s *Session) JoinRoom(roomID string, credentials *DataRoomCredentials, send @@ -133,7 +134,7 @@ func (s *Session) JoinRoom(roomID string, credentials *DataRoomCredentials, send
})
}
room, err := s.RoomStatusManager.JoinRoom(roomID, credentials, s, s.authenticated(), sender)
room, err := s.RoomStatusManager.JoinRoom(roomID, roomName, roomType, credentials, s, s.authenticated(), sender)
if err == nil {
s.Hello = true
s.Roomid = roomID

2
static/js/app.js

@ -208,7 +208,7 @@ define([ @@ -208,7 +208,7 @@ define([
};
// Our API version as float. This value is incremented on
// Our client side API version as float. This value is incremented on
// breaking changes to plugins can check on it.
var apiversion = 1.1;

3
static/js/mediastream/api.js

@ -236,7 +236,8 @@ define(['jquery', 'underscore', 'ua-parser'], function($, _, uaparser) { @@ -236,7 +236,8 @@ define(['jquery', 'underscore', 'ua-parser'], function($, _, uaparser) {
var data = {
Version: this.version,
Ua: this.userAgent,
Id: name
Name: name,
Type: "" // Selects the default room type.
};
if (pin) {

Loading…
Cancel
Save