Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KSZK
Schönherz Mátrix
games
Aggregator Backend
Commits
981f7d0f
Commit
981f7d0f
authored
Sep 29, 2021
by
Miklós Tóth
🤷
Browse files
Improve join error msg handling
parent
1f6e3322
Pipeline
#8844
passed with stages
in 1 minute and 19 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
static/main.js
View file @
981f7d0f
...
...
@@ -2,7 +2,7 @@ let joinAttempts = 0
function
loginOrRegister
(
force
){
if
(
joinAttempts
>
5
)
{
throw
"
failed to join
"
throw
lastError
||
"
failed to join
"
}
joinAttempts
++
...
...
@@ -115,6 +115,7 @@ function handleResponse(action, response){
let
intervalId
;
let
sock
;
let
lastError
;
function
createSocket
()
{
if
(
sock
)
{
...
...
@@ -145,15 +146,16 @@ function createSocket() {
if
(
data
.
code
<
300
)
{
handleResponse
(
data
.
cmd
,
data
.
msg
);
}
else
{
if
(
data
.
code
!==
200
&&
data
.
cmd
===
"
join
"
)
{
// if registration was unsuccessful, don't stick with if after reload
try
{
sock
.
send
(
JSON
.
stringify
(
loginOrRegister
(
true
)));
}
catch
(
e
)
{
alert
(
e
)
if
(
data
.
code
!==
200
)
{
lastError
=
data
.
msg
;
if
(
data
.
cmd
===
"
join
"
)
{
// if registration was unsuccessful, don't stick with if after reload
try
{
sock
.
send
(
JSON
.
stringify
(
loginOrRegister
(
true
)));
}
catch
(
e
)
{
changeTeamName
(
e
)
}
}
}
else
{
alert
([
data
.
code
,
data
.
msg
]);
}
}
};
...
...
web/socket.go
View file @
981f7d0f
...
...
@@ -97,7 +97,11 @@ func socketHandler(session sockjs.Session) {
func
joinTeam
(
joinTeamId
string
,
session
sockjs
.
Session
,
teamId
*
string
,
userId
string
)
{
name
,
e
:=
db
.
GetTeam
(
session
.
Context
(),
joinTeamId
)
weFdUp
:=
e
!=
redis
.
Nil
weFdUp
:=
true
if
e
==
redis
.
Nil
{
weFdUp
=
false
e
=
errors
.
New
(
"invalid team id"
)
}
if
handleError
(
session
,
e
,
weFdUp
,
"join"
)
{
return
}
...
...
Write
Preview
Supports
Markdown
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