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
7707775c
Commit
7707775c
authored
Sep 12, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement user-readable message for kick.
parent
5c97e739
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
13 deletions
+30
-13
group.go
group.go
+3
-1
static/protocol.js
static/protocol.js
+3
-1
static/sfu.js
static/sfu.js
+16
-7
webclient.go
webclient.go
+8
-4
No files found.
group.go
View file @
7707775c
...
...
@@ -64,7 +64,9 @@ type connectionFailedAction struct {
type
permissionsChangedAction
struct
{}
type
kickAction
struct
{}
type
kickAction
struct
{
message
string
}
var
groups
struct
{
mu
sync
.
Mutex
...
...
static/protocol.js
View file @
7707775c
...
...
@@ -437,12 +437,14 @@ ServerConnection.prototype.groupAction = function(kind) {
*
* @param {string} kind - One of "op", "unop", "kick", "present", "unpresent".
* @param {string} id
* @param {string} [message]
*/
ServerConnection
.
prototype
.
userAction
=
function
(
kind
,
id
)
{
ServerConnection
.
prototype
.
userAction
=
function
(
kind
,
id
,
message
)
{
this
.
send
({
type
:
'
useraction
'
,
kind
:
kind
,
id
:
id
,
value
:
message
,
});
}
...
...
static/sfu.js
View file @
7707775c
...
...
@@ -955,14 +955,14 @@ function handleInput() {
message
=
data
.
substring
(
1
);
me
=
false
;
}
else
{
let
space
,
cmd
,
rest
;
space
=
data
.
indexOf
(
'
'
);
let
cmd
,
rest
;
let
space
=
data
.
indexOf
(
'
'
);
if
(
space
<
0
)
{
cmd
=
data
;
rest
=
''
;
}
else
{
cmd
=
data
.
slice
(
0
,
space
);
rest
=
data
.
slice
(
space
+
1
)
.
trim
()
;
rest
=
data
.
slice
(
space
+
1
);
}
switch
(
cmd
)
{
...
...
@@ -1005,22 +1005,31 @@ function handleInput() {
displayError
(
"
You're not an operator
"
);
return
;
}
let
username
,
message
;
let
space
=
rest
.
indexOf
(
'
'
);
if
(
space
<
0
)
{
username
=
rest
;
message
=
null
;
}
else
{
username
=
rest
.
slice
(
0
,
space
);
message
=
rest
.
slice
(
space
+
1
).
trim
();
}
let
id
;
if
(
rest
in
users
)
{
if
(
username
in
users
)
{
id
=
rest
;
}
else
{
for
(
let
i
in
users
)
{
if
(
users
[
i
]
===
rest
)
{
if
(
users
[
i
]
===
username
)
{
id
=
i
;
break
;
}
}
}
if
(
!
id
)
{
displayError
(
'
Unknown user
'
+
rest
);
displayError
(
'
Unknown user
'
+
username
);
return
;
}
serverConnection
.
userAction
(
cmd
.
slice
(
1
),
id
)
serverConnection
.
userAction
(
cmd
.
slice
(
1
),
id
,
message
);
return
;
}
default
:
...
...
webclient.go
View file @
7707775c
...
...
@@ -870,7 +870,7 @@ func clientLoop(c *webClient, conn *websocket.Conn) error {
}
}
case
kickAction
:
return
userError
(
"you have been kicked"
)
return
userError
(
a
.
message
)
default
:
log
.
Printf
(
"unexpected action %T"
,
a
)
return
errors
.
New
(
"unexpected action"
)
...
...
@@ -943,7 +943,7 @@ func setPermissions(g *group, id string, perm string) error {
return
c
.
action
(
permissionsChangedAction
{})
}
func
kickClient
(
g
*
group
,
id
string
)
error
{
func
kickClient
(
g
*
group
,
id
string
,
message
string
)
error
{
g
.
mu
.
Lock
()
defer
g
.
mu
.
Unlock
()
...
...
@@ -957,7 +957,7 @@ func kickClient(g *group, id string) error {
return
userError
(
"this is not a real user"
)
}
return
c
.
action
(
kickAction
{})
return
c
.
action
(
kickAction
{
message
})
}
func
handleClientMessage
(
c
*
webClient
,
m
clientMessage
)
error
{
...
...
@@ -1094,7 +1094,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
if
!
c
.
permissions
.
Op
{
return
c
.
error
(
userError
(
"not authorised"
))
}
err
:=
kickClient
(
c
.
group
,
m
.
Id
)
message
:=
m
.
Value
if
message
==
""
{
message
=
"you have been kicked"
}
err
:=
kickClient
(
c
.
group
,
m
.
Id
,
message
)
if
err
!=
nil
{
return
c
.
error
(
err
)
}
...
...
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