Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
sfu
Commits
27a2e455
Commit
27a2e455
authored
Dec 02, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement /subgroups.
parent
43047fc0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
group/group.go
group/group.go
+24
-0
rtpconn/webclient.go
rtpconn/webclient.go
+21
-0
static/sfu.js
static/sfu.js
+8
-0
No files found.
group/group.go
View file @
27a2e455
...
...
@@ -259,6 +259,30 @@ func GetNames() []string {
return
names
}
type
SubGroup
struct
{
Name
string
Clients
int
}
func
GetSubGroups
(
parent
string
)
[]
SubGroup
{
prefix
:=
parent
+
"/"
subgroups
:=
make
([]
SubGroup
,
0
)
Range
(
func
(
g
*
Group
)
bool
{
if
strings
.
HasPrefix
(
g
.
name
,
prefix
)
{
g
.
mu
.
Lock
()
count
:=
len
(
g
.
clients
)
g
.
mu
.
Unlock
()
if
count
>
0
{
subgroups
=
append
(
subgroups
,
SubGroup
{
g
.
name
,
count
})
}
}
return
true
})
return
subgroups
}
func
Get
(
name
string
)
*
Group
{
groups
.
mu
.
Lock
()
defer
groups
.
mu
.
Unlock
()
...
...
rtpconn/webclient.go
View file @
27a2e455
...
...
@@ -7,6 +7,7 @@ import (
"os"
"sync"
"time"
"fmt"
"github.com/gorilla/websocket"
"github.com/pion/webrtc/v3"
...
...
@@ -1218,6 +1219,26 @@ func handleClientMessage(c *webClient, m clientMessage) error {
group
.
DelClient
(
disk
)
}
}
case
"subgroups"
:
if
!
c
.
permissions
.
Op
{
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
s
:=
""
for
_
,
sg
:=
range
group
.
GetSubGroups
(
g
.
Name
())
{
plural
:=
""
if
sg
.
Clients
>
1
{
plural
=
"s"
}
s
=
s
+
fmt
.
Sprintf
(
"%v (%v client%v)"
,
sg
.
Name
,
sg
.
Clients
,
plural
)
}
c
.
write
(
clientMessage
{
Type
:
"chat"
,
Dest
:
c
.
id
,
Username
:
"Server"
,
Time
:
group
.
ToJSTime
(
time
.
Now
()),
Value
:
&
s
,
})
default
:
return
group
.
ProtocolError
(
"unknown group action"
)
}
...
...
static/sfu.js
View file @
27a2e455
...
...
@@ -1759,6 +1759,14 @@ commands.unrecord = {
}
};
commands
.
subgroups
=
{
predicate
:
operatorPredicate
,
description
:
'
list subgroups
'
,
f
:
(
c
,
r
)
=>
{
serverConnection
.
groupAction
(
getUsername
(),
'
subgroups
'
);
}
};
/**
* parseCommand splits a string into two space-separated parts. The first
* part may be quoted and may include backslash escapes.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment