This plug-in can use blueprints to create WebSocket servers and monitor response data.
The download address is at the end of the article.
目录(Contents)
1. Node description
Create Web Socket Server
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-9.png)
Create a WebSocket server object and listen to the corresponding port. The connection address is ws://IP:PORT, such as ws://192.168.1.5:9001
The returned object needs to be promoted to a variable, and this object will be used for operations in the future.
Bind – Bind callback function
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-10.png)
Bind server callback function
User Open: Called back when the user connects.
User Close: Called back when the user disconnects.
User Message: Message sent by the user
User ID: The user’s unique identifier, which can be saved when the user connects and used to send messages to the user in the future.
Data: User’s connection message, which can parse the user’s Protocols, Heads, and Params.
Message: Message sent by the user.
Close Server
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-11.png)
Close the current server. After closing, you can set the corresponding object to empty.
If you need to use it again, you need to recreate the server.
Get All Users
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-12.png)
Get all current connection user IDs.
Get User Data
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-13.png)
Get the connection information of the specified user.
Send Message
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-14.png)
Send string data to the specified user.
User ID: The user’s unique identifier, which can be obtained when the user connects.
Message: The string to be sent, which can be a Json string.
Close User
![[Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions [Unreal Engine] DTWebSocketServer blueprint creation WebSocket server plug-in instructions](https://dt.cq.cn/wp-content/uploads/2024/03/image-15.png)
Actively disconnect the specified user.
2. Use Cases
In the plug-in, drag BP_DTWebSocketServerActor directly into the main scene to see it.
3. Download Link
Web Socket Server in Code Plugins – UE Marketplace (unrealengine.com)
Awesome post.