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
43047fc0
Commit
43047fc0
authored
Dec 02, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow empty values in clientMessage.
parent
4a4973fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
rtpconn/webclient.go
rtpconn/webclient.go
+28
-12
No files found.
rtpconn/webclient.go
View file @
43047fc0
...
@@ -26,12 +26,13 @@ func errorToWSCloseMessage(id string, err error) (*clientMessage, []byte) {
...
@@ -26,12 +26,13 @@ func errorToWSCloseMessage(id string, err error) (*clientMessage, []byte) {
code
=
websocket
.
CloseNormalClosure
code
=
websocket
.
CloseNormalClosure
case
group
.
ProtocolError
:
case
group
.
ProtocolError
:
code
=
websocket
.
CloseProtocolError
code
=
websocket
.
CloseProtocolError
s
:=
e
.
Error
()
m
=
&
clientMessage
{
m
=
&
clientMessage
{
Type
:
"usermessage"
,
Type
:
"usermessage"
,
Kind
:
"error"
,
Kind
:
"error"
,
Dest
:
id
,
Dest
:
id
,
Priviledged
:
true
,
Priviledged
:
true
,
Value
:
e
.
Error
()
,
Value
:
&
s
,
}
}
text
=
e
.
Error
()
text
=
e
.
Error
()
case
group
.
UserError
,
group
.
KickError
:
case
group
.
UserError
,
group
.
KickError
:
...
@@ -169,7 +170,7 @@ type clientMessage struct {
...
@@ -169,7 +170,7 @@ type clientMessage struct {
Priviledged
bool
`json:"priviledged,omitempty"`
Priviledged
bool
`json:"priviledged,omitempty"`
Permissions
*
group
.
ClientPermissions
`json:"permissions,omitempty"`
Permissions
*
group
.
ClientPermissions
`json:"permissions,omitempty"`
Group
string
`json:"group,omitempty"`
Group
string
`json:"group,omitempty"`
Value
string
`json:"value,omitempty"`
Value
*
string
`json:"value,omitempty"`
Time
int64
`json:"time,omitempty"`
Time
int64
`json:"time,omitempty"`
Offer
*
webrtc
.
SessionDescription
`json:"offer,omitempty"`
Offer
*
webrtc
.
SessionDescription
`json:"offer,omitempty"`
Answer
*
webrtc
.
SessionDescription
`json:"answer,omitempty"`
Answer
*
webrtc
.
SessionDescription
`json:"answer,omitempty"`
...
@@ -809,10 +810,11 @@ func clientLoop(c *webClient, ws *websocket.Conn) error {
...
@@ -809,10 +810,11 @@ func clientLoop(c *webClient, ws *websocket.Conn) error {
}
}
}
}
case
addLabelAction
:
case
addLabelAction
:
label
:=
a
.
label
c
.
write
(
clientMessage
{
c
.
write
(
clientMessage
{
Type
:
"label"
,
Type
:
"label"
,
Id
:
a
.
id
,
Id
:
a
.
id
,
Value
:
a
.
label
,
Value
:
&
label
,
})
})
case
pushConnsAction
:
case
pushConnsAction
:
for
_
,
u
:=
range
c
.
up
{
for
_
,
u
:=
range
c
.
up
{
...
@@ -1021,12 +1023,13 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1021,12 +1023,13 @@ func handleClientMessage(c *webClient, m clientMessage) error {
)
)
}
else
if
err
==
group
.
ErrNotAuthorised
{
}
else
if
err
==
group
.
ErrNotAuthorised
{
time
.
Sleep
(
200
*
time
.
Millisecond
)
time
.
Sleep
(
200
*
time
.
Millisecond
)
s
:=
"not authorised"
return
c
.
write
(
clientMessage
{
return
c
.
write
(
clientMessage
{
Type
:
"joined"
,
Type
:
"joined"
,
Kind
:
"fail"
,
Kind
:
"fail"
,
Group
:
m
.
Group
,
Group
:
m
.
Group
,
Permissions
:
&
group
.
ClientPermissions
{},
Permissions
:
&
group
.
ClientPermissions
{},
Value
:
"not authorised"
,
Value
:
&
s
,
})
})
}
}
return
err
return
err
...
@@ -1116,10 +1119,14 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1116,10 +1119,14 @@ func handleClientMessage(c *webClient, m clientMessage) error {
}
}
tm
:=
group
.
ToJSTime
(
time
.
Now
())
tm
:=
group
.
ToJSTime
(
time
.
Now
())
if
m
.
Type
==
"chat"
{
if
m
.
Type
==
"chat"
{
if
m
.
Value
==
nil
{
return
group
.
ProtocolError
(
"missing value"
)
}
if
m
.
Dest
==
""
{
if
m
.
Dest
==
""
{
g
.
AddToChatHistory
(
g
.
AddToChatHistory
(
m
.
Id
,
m
.
Username
,
tm
,
m
.
Kind
,
m
.
Value
,
m
.
Id
,
m
.
Username
,
tm
,
m
.
Kind
,
*
m
.
Value
,
)
)
}
}
}
}
...
@@ -1178,7 +1185,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1178,7 +1185,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
if
!
c
.
permissions
.
Op
{
if
!
c
.
permissions
.
Op
{
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
}
g
.
SetLocked
(
m
.
Kind
==
"lock"
,
m
.
Value
)
message
:=
""
if
m
.
Value
!=
nil
{
message
=
*
m
.
Value
}
g
.
SetLocked
(
m
.
Kind
==
"lock"
,
message
)
case
"record"
:
case
"record"
:
if
!
c
.
permissions
.
Record
{
if
!
c
.
permissions
.
Record
{
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
...
@@ -1234,7 +1245,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1234,7 +1245,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
if
!
c
.
permissions
.
Op
{
if
!
c
.
permissions
.
Op
{
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
}
err
:=
kickClient
(
g
,
m
.
Id
,
m
.
Username
,
m
.
Dest
,
m
.
Value
)
message
:=
""
if
m
.
Value
!=
nil
{
message
=
*
m
.
Value
}
err
:=
kickClient
(
g
,
m
.
Id
,
m
.
Username
,
m
.
Dest
,
message
)
if
err
!=
nil
{
if
err
!=
nil
{
return
c
.
error
(
err
)
return
c
.
error
(
err
)
}
}
...
@@ -1344,12 +1359,13 @@ func (c *webClient) close(data []byte) error {
...
@@ -1344,12 +1359,13 @@ func (c *webClient) close(data []byte) error {
func
errorMessage
(
id
string
,
err
error
)
*
clientMessage
{
func
errorMessage
(
id
string
,
err
error
)
*
clientMessage
{
switch
e
:=
err
.
(
type
)
{
switch
e
:=
err
.
(
type
)
{
case
group
.
UserError
:
case
group
.
UserError
:
message
:=
e
.
Error
()
return
&
clientMessage
{
return
&
clientMessage
{
Type
:
"usermessage"
,
Type
:
"usermessage"
,
Kind
:
"error"
,
Kind
:
"error"
,
Dest
:
id
,
Dest
:
id
,
Priviledged
:
true
,
Priviledged
:
true
,
Value
:
e
.
Error
()
,
Value
:
&
message
,
}
}
case
group
.
KickError
:
case
group
.
KickError
:
message
:=
e
.
Message
message
:=
e
.
Message
...
@@ -1363,7 +1379,7 @@ func errorMessage(id string, err error) *clientMessage {
...
@@ -1363,7 +1379,7 @@ func errorMessage(id string, err error) *clientMessage {
Username
:
e
.
Username
,
Username
:
e
.
Username
,
Dest
:
id
,
Dest
:
id
,
Priviledged
:
true
,
Priviledged
:
true
,
Value
:
message
,
Value
:
&
message
,
}
}
default
:
default
:
return
nil
return
nil
...
...
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