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
391e8b23
Commit
391e8b23
authored
12 years ago
by
Christoph Thelen
Browse files
Options
Downloads
Patches
Plain Diff
Code formatting
parent
83eba294
Branches
Branches containing commit
Tags
Tags containing commit
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+34
-44
34 additions, 44 deletions
...ain/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
with
34 additions
and
44 deletions
src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+
34
−
44
View file @
391e8b23
...
@@ -73,54 +73,44 @@ public class ARSnovaSocketIOServer {
...
@@ -73,54 +73,44 @@ public class ARSnovaSocketIOServer {
}
}
server
=
new
SocketIOServer
(
config
);
server
=
new
SocketIOServer
(
config
);
server
.
addEventListener
(
"setFeedback"
,
Feedback
.
class
,
server
.
addEventListener
(
"setFeedback"
,
Feedback
.
class
,
new
DataListener
<
Feedback
>()
{
new
DataListener
<
Feedback
>()
{
@Override
@Override
public
void
onData
(
SocketIOClient
client
,
Feedback
data
,
AckRequest
ackSender
)
{
public
void
onData
(
SocketIOClient
client
,
Feedback
data
,
/**
AckRequest
ackSender
)
{
* do a check if user is in the session, for which he would give
/**
* a feedback
* do a check if user is in the session, for which he
*/
* would give a feedback
User
u
=
userService
.
getUser2SocketId
(
client
.
getSessionId
());
*/
if
(
u
==
null
||
userService
.
isUserInSession
(
u
,
data
.
getSessionkey
())
==
false
)
{
User
u
=
userService
.
getUser2SocketId
(
client
return
;
.
getSessionId
());
}
if
(
u
==
null
feedbackService
.
saveFeedback
(
data
.
getSessionkey
(),
data
.
getValue
(),
u
);
||
userService
.
isUserInSession
(
u
,
data
.
getSessionkey
())
==
false
)
{
/**
return
;
* send feedback back to clients
}
*/
feedbackService
.
saveFeedback
(
data
.
getSessionkey
(),
reportUpdatedFeedbackForSession
(
data
.
getSessionkey
());
data
.
getValue
(),
u
);
}
});
/**
* send feedback back to clients
server
.
addEventListener
(
"arsnova/question/create"
,
Question
.
class
,
new
DataListener
<
Question
>()
{
*/
@Override
reportUpdatedFeedbackForSession
(
data
.
getSessionkey
());
public
void
onData
(
SocketIOClient
client
,
Question
question
,
AckRequest
ackSender
)
{
}
questionService
.
saveQuestion
(
question
);
});
}
});
server
.
addEventListener
(
"arsnova/question/create"
,
Question
.
class
,
new
DataListener
<
Question
>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
Question
question
,
AckRequest
ackSender
)
{
questionService
.
saveQuestion
(
question
);
}
});
server
.
addConnectListener
(
new
ConnectListener
()
{
server
.
addConnectListener
(
new
ConnectListener
()
{
@Override
@Override
public
void
onConnect
(
SocketIOClient
client
)
{
public
void
onConnect
(
SocketIOClient
client
)
{
logger
.
info
(
"addConnectListener.onConnect: Client: {}"
,
logger
.
info
(
"addConnectListener.onConnect: Client: {}"
,
new
Object
[]
{
client
});
new
Object
[]
{
client
});
}
}
});
});
server
.
addDisconnectListener
(
new
DisconnectListener
()
{
server
.
addDisconnectListener
(
new
DisconnectListener
()
{
@Override
@Override
public
void
onDisconnect
(
SocketIOClient
client
)
{
public
void
onDisconnect
(
SocketIOClient
client
)
{
logger
.
info
(
"addDisconnectListener.onDisconnect: Client: {}"
,
logger
.
info
(
"addDisconnectListener.onDisconnect: Client: {}"
,
new
Object
[]
{
client
});
new
Object
[]
{
client
});
userService
.
removeUser2SocketId
(
client
.
getSessionId
());
userService
.
removeUser2SocketId
(
client
.
getSessionId
());
}
}
});
});
...
@@ -208,9 +198,9 @@ public class ARSnovaSocketIOServer {
...
@@ -208,9 +198,9 @@ public class ARSnovaSocketIOServer {
public
void
reportUpdatedFeedbackForSession
(
String
session
)
{
public
void
reportUpdatedFeedbackForSession
(
String
session
)
{
/**
/**
* collect a list of users which are in the current
* collect a list of users which are in the current
session iterate over
*
session iterate over
all connected clients and if
* all connected clients and if
send feedback, if user is in current
*
send feedback, if user is in current
session
* session
*/
*/
List
<
String
>
users
=
userService
.
getUsersInSession
(
session
);
List
<
String
>
users
=
userService
.
getUsersInSession
(
session
);
de
.
thm
.
arsnova
.
entities
.
Feedback
fb
=
feedbackService
.
getFeedback
(
session
);
de
.
thm
.
arsnova
.
entities
.
Feedback
fb
=
feedbackService
.
getFeedback
(
session
);
...
@@ -218,10 +208,10 @@ public class ARSnovaSocketIOServer {
...
@@ -218,10 +208,10 @@ public class ARSnovaSocketIOServer {
for
(
SocketIOClient
c
:
server
.
getAllClients
())
{
for
(
SocketIOClient
c
:
server
.
getAllClients
())
{
User
u
=
userService
.
getUser2SocketId
(
c
.
getSessionId
());
User
u
=
userService
.
getUser2SocketId
(
c
.
getSessionId
());
if
(
u
!=
null
&&
users
.
contains
(
u
.
getUsername
()))
{
if
(
u
!=
null
&&
users
.
contains
(
u
.
getUsername
()))
{
logger
.
info
(
"sending out to client {}, username is: {}, current session is: {}"
,
logger
.
info
(
"sending out to client {}, username is: {}, current session is: {}"
,
new
Object
[]
{
c
.
getSessionId
(),
u
.
getUsername
(),
session
});
new
Object
[]
{
c
.
getSessionId
(),
u
.
getUsername
(),
session
});
c
.
sendEvent
(
"updateFeedback"
,
fb
.
getValues
());
c
.
sendEvent
(
"updateFeedback"
,
fb
.
getValues
());
}
}
}
}
}
}
}
}
\ No newline at end of file
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