Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
Paul-Christian Volkmer
ARSnova Backend
Commits
5391c08a
Commit
5391c08a
authored
10 years ago
by
Daniel Gerhardt
Browse files
Options
Downloads
Patches
Plain Diff
Improve active user count handling
parent
1445b6e9
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+9
-6
9 additions, 6 deletions
...ain/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
with
9 additions
and
6 deletions
src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+
9
−
6
View file @
5391c08a
...
@@ -56,8 +56,6 @@ public class ARSnovaSocketIOServer {
...
@@ -56,8 +56,6 @@ public class ARSnovaSocketIOServer {
private
final
Configuration
config
;
private
final
Configuration
config
;
private
SocketIOServer
server
;
private
SocketIOServer
server
;
private
int
lastActiveUserCount
=
0
;
public
ARSnovaSocketIOServer
()
{
public
ARSnovaSocketIOServer
()
{
config
=
new
Configuration
();
config
=
new
Configuration
();
}
}
...
@@ -112,6 +110,15 @@ public class ARSnovaSocketIOServer {
...
@@ -112,6 +110,15 @@ public class ARSnovaSocketIOServer {
server
.
addEventListener
(
"setSession"
,
Session
.
class
,
new
DataListener
<
Session
>()
{
server
.
addEventListener
(
"setSession"
,
Session
.
class
,
new
DataListener
<
Session
>()
{
@Override
@Override
public
void
onData
(
SocketIOClient
client
,
Session
session
,
AckRequest
ackSender
)
{
public
void
onData
(
SocketIOClient
client
,
Session
session
,
AckRequest
ackSender
)
{
User
u
=
userService
.
getUser2SocketId
(
client
.
getSessionId
());
String
oldSessionKey
=
userService
.
getSessionForUser
(
u
.
getUsername
());
if
(
session
.
getKeyword
()
==
oldSessionKey
)
{
return
;
}
if
(
null
!=
oldSessionKey
)
{
reportActiveUserCountForSession
(
oldSessionKey
);
}
if
(
null
!=
sessionService
.
joinSession
(
session
.
getKeyword
(),
client
.
getSessionId
()))
{
if
(
null
!=
sessionService
.
joinSession
(
session
.
getKeyword
(),
client
.
getSessionId
()))
{
/* active user count has to be sent to the client since the broadcast is
/* active user count has to be sent to the client since the broadcast is
* not always sent as long as the polling solution is active simultaneously */
* not always sent as long as the polling solution is active simultaneously */
...
@@ -282,10 +289,6 @@ public class ARSnovaSocketIOServer {
...
@@ -282,10 +289,6 @@ public class ARSnovaSocketIOServer {
public
void
reportActiveUserCountForSession
(
String
sessionKey
)
{
public
void
reportActiveUserCountForSession
(
String
sessionKey
)
{
/* This check is needed as long as the HTTP polling solution is active simultaneously. */
/* This check is needed as long as the HTTP polling solution is active simultaneously. */
int
count
=
userService
.
getUsersInSessionCount
(
sessionKey
);
int
count
=
userService
.
getUsersInSessionCount
(
sessionKey
);
if
(
count
==
lastActiveUserCount
)
{
return
;
}
lastActiveUserCount
=
count
;
broadcastInSession
(
sessionKey
,
"activeUserCountData"
,
count
);
broadcastInSession
(
sessionKey
,
"activeUserCountData"
,
count
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment