Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fuzzBackEnd
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钱炳权
fuzzBackEnd
Commits
1c41f8b1
Commit
1c41f8b1
authored
Apr 19, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exception is chaged
parent
3976f673
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
WebSocket.java
...n/java/com/example/fuzzControll/controller/WebSocket.java
+4
-3
No files found.
fuzzbackend/src/main/java/com/example/fuzzControll/controller/WebSocket.java
View file @
1c41f8b1
package
com
.
example
.
fuzzControll
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
javax.websocket.*
;
...
...
@@ -14,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
@Component
(
"WebSocket"
)
@ServerEndpoint
(
"/websocket/testResult/{name}"
)
@Slf4j
public
class
WebSocket
{
private
Session
session
;
//与某个客户端连接对话,通过此对客户端发送消息
...
...
@@ -24,7 +26,7 @@ public class WebSocket {
public
void
onOpen
(
Session
session
,
@PathParam
(
value
=
"name"
)
String
name
)
{
this
.
session
=
session
;
//默认客户端,没有重名
WEBSOCKET_CONCURRENTHASHMAP
.
put
(
name
,
this
);
System
.
out
.
println
(
"【webSocket连接成功】当前连接人数为:"
+
WEBSOCKET_CONCURRENTHASHMAP
.
size
()
+
",此人为:"
+
name
);
log
.
info
(
"Websocket is connected! The man is {}.There are {} people in the connection "
,
name
,
WEBSOCKET_CONCURRENTHASHMAP
.
size
()
);
}
...
...
@@ -40,8 +42,7 @@ public class WebSocket {
}
}
System
.
out
.
println
(
"【webSocket退出成功】当前连接人数为:"
+
WEBSOCKET_CONCURRENTHASHMAP
.
size
());
log
.
info
(
"Websocket is closed! There are {} people in the connection "
,
WEBSOCKET_CONCURRENTHASHMAP
.
size
());
}
@OnError
...
...
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