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
13725103
Commit
13725103
authored
12 years ago
by
Julian Hochstetter
Browse files
Options
Downloads
Patches
Plain Diff
Task #3851: send feedback to a list of users
parent
d29c3da0
Branches
Branches containing commit
Tags
Tags containing commit
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
+12
-16
12 additions, 16 deletions
...ain/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
with
12 additions
and
16 deletions
src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+
12
−
16
View file @
13725103
...
...
@@ -3,27 +3,24 @@ package de.thm.arsnova.socket;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
.Entry
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.commons.lang.NotImplementedException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Required
;
import
com.corundumstudio.socketio.AckCallback
;
import
com.corundumstudio.socketio.ClientOperations
;
import
com.corundumstudio.socketio.Configuration
;
import
com.corundumstudio.socketio.SocketIOClient
;
import
com.corundumstudio.socketio.SocketIOServer
;
import
com.corundumstudio.socketio.listener.ConnectListener
;
import
com.corundumstudio.socketio.listener.DataListener
;
import
com.corundumstudio.socketio.listener.DisconnectListener
;
import
com.corundumstudio.socketio.parser.Packet
;
import
de.thm.arsnova.entities.User
;
import
de.thm.arsnova.services.ISessionService
;
...
...
@@ -36,7 +33,7 @@ public class ARSnovaSocketIOServer {
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
final
Map
<
UUID
,
User
>
socketid2user
=
new
ConcurrentHashMap
<
UUID
,
User
>();
private
final
ConcurrentHash
Map
<
UUID
,
User
>
socketid2user
=
new
ConcurrentHashMap
<
UUID
,
User
>();
private
int
portNumber
;
private
boolean
useSSL
=
false
;
...
...
@@ -170,28 +167,27 @@ public class ARSnovaSocketIOServer {
}
public
void
reportDeletedFeedback
(
String
username
,
Set
<
String
>
arsSessions
)
{
UUID
connectionId
=
findConnectionIdForUser
(
username
);
if
(
connectionId
==
null
)
{
List
<
UUID
>
connectionId
s
=
findConnectionIdForUser
(
username
);
if
(
connectionId
s
.
isEmpty
()
)
{
return
;
}
for
(
SocketIOClient
client
:
server
.
getAllClients
())
{
// Find the client whose feedback has been deleted and send a message.
if
(
c
lient
.
getSess
ionId
()
.
co
mpareTo
(
connectionId
)
==
0
)
{
if
(
c
onnect
ionId
s
.
co
ntains
(
client
.
getSessionId
())
)
{
client
.
sendEvent
(
"removedFeedback"
,
arsSessions
);
break
;
}
}
}
private
UUID
findConnectionIdForUser
(
String
username
)
{
for
(
Map
.
Entry
<
UUID
,
User
>
e
:
socketid2user
.
entrySet
())
{
User
u
=
e
.
getValue
();
if
(
u
.
getUsername
().
equals
(
username
))
{
re
turn
e
.
getKey
();
private
List
<
UUID
>
findConnectionIdForUser
(
String
username
)
{
List
<
UUID
>
result
=
new
ArrayList
<
UUID
>();
for
(
Entry
<
UUID
,
User
>
e
:
socketid2user
.
entrySet
())
{
if
(
e
.
getValue
()
.
getUsername
().
equals
(
username
))
{
re
sult
.
add
(
e
.
getKey
()
)
;
}
}
return
n
ul
l
;
return
res
ul
t
;
}
...
...
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