Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
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
nexedi
galene
Commits
037f002a
Commit
037f002a
authored
May 18, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the requested field of client requests into a dictionary.
parent
b265aacd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
13 deletions
+55
-13
client.go
client.go
+51
-9
group.go
group.go
+1
-1
static/sfu.js
static/sfu.js
+3
-3
No files found.
client.go
View file @
037f002a
...
...
@@ -91,6 +91,53 @@ func isWSNormalError(err error) bool {
websocket
.
CloseGoingAway
)
}
type
rateMap
map
[
string
]
uint32
func
(
v
*
rateMap
)
UnmarshalJSON
(
b
[]
byte
)
error
{
var
m
map
[
string
]
interface
{}
err
:=
json
.
Unmarshal
(
b
,
&
m
)
if
err
!=
nil
{
return
err
}
n
:=
make
(
map
[
string
]
uint32
,
len
(
m
))
for
k
,
w
:=
range
m
{
switch
w
:=
w
.
(
type
)
{
case
bool
:
if
w
{
n
[
k
]
=
^
uint32
(
0
)
}
else
{
n
[
k
]
=
0
}
case
float64
:
if
w
<
0
||
w
>=
float64
(
^
uint32
(
0
))
{
return
errors
.
New
(
"overflow"
)
}
n
[
k
]
=
uint32
(
w
)
default
:
return
errors
.
New
(
"unexpected type in JSON map"
)
}
}
*
v
=
n
return
nil
}
func
(
v
rateMap
)
MarshalJSON
()
([]
byte
,
error
)
{
m
:=
make
(
map
[
string
]
interface
{},
len
(
v
))
for
k
,
w
:=
range
v
{
switch
w
{
case
0
:
m
[
k
]
=
false
case
^
uint32
(
0
)
:
m
[
k
]
=
true
default
:
m
[
k
]
=
w
}
}
return
json
.
Marshal
(
m
)
}
type
clientMessage
struct
{
Type
string
`json:"type"`
Id
string
`json:"id,omitempty"`
...
...
@@ -105,7 +152,7 @@ type clientMessage struct {
Candidate
*
webrtc
.
ICECandidateInit
`json:"candidate,omitempty"`
Labels
map
[
string
]
string
`json:"labels,omitempty"`
Del
bool
`json:"del,omitempty"`
Request
[]
string
`json:"request,omitempty"`
Request
rateMap
`json:"request,omitempty"`
}
type
closeMessage
struct
{
...
...
@@ -927,7 +974,7 @@ func gotICE(c *client, candidate *webrtc.ICECandidateInit, id string) error {
return
pc
.
AddICECandidate
(
*
candidate
)
}
func
(
c
*
client
)
setRequested
(
requested
[]
string
)
error
{
func
(
c
*
client
)
setRequested
(
requested
map
[
string
]
uint32
)
error
{
if
c
.
down
!=
nil
{
for
id
:=
range
c
.
down
{
c
.
write
(
clientMessage
{
...
...
@@ -951,12 +998,7 @@ func (c *client) setRequested(requested []string) error {
}
func
(
c
*
client
)
isRequested
(
label
string
)
bool
{
for
_
,
r
:=
range
c
.
requested
{
if
label
==
r
{
return
true
}
}
return
false
return
c
.
requested
[
label
]
!=
0
}
func
addDownConnTracks
(
c
*
client
,
remote
*
upConnection
,
tracks
[]
*
upTrack
)
(
*
downConnection
,
error
)
{
...
...
@@ -1002,7 +1044,7 @@ func clientLoop(c *client, conn *websocket.Conn) error {
go
clientReader
(
conn
,
read
,
c
.
done
)
defer
func
()
{
c
.
setRequested
(
[]
string
{})
c
.
setRequested
(
map
[
string
]
uint32
{})
if
c
.
up
!=
nil
{
for
id
:=
range
c
.
up
{
delUpConn
(
c
,
id
)
...
...
group.go
View file @
037f002a
...
...
@@ -171,7 +171,7 @@ type client struct {
id
string
username
string
permissions
userPermission
requested
[]
string
requested
map
[
string
]
uint32
done
chan
struct
{}
writeCh
chan
interface
{}
writerDone
chan
struct
{}
...
...
static/sfu.js
View file @
037f002a
...
...
@@ -563,13 +563,13 @@ function sendRequest(value) {
let
request
=
[];
switch
(
value
)
{
case
'
audio
'
:
request
=
[
'
audio
'
]
;
request
=
{
audio
:
true
}
;
break
;
case
'
screenshare
'
:
request
=
[
'
audio
'
,
'
screenshare
'
]
;
request
=
{
audio
:
true
,
screenshare
:
true
}
;
break
;
case
'
everything
'
:
request
=
[
'
audio
'
,
'
screenshare
'
,
'
video
'
]
;
request
=
{
audio
:
true
,
screenshare
:
true
,
video
:
true
}
;
break
;
default
:
console
.
error
(
`Uknown value
${
value
}
in sendRequest`
);
...
...
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