✨ Client name.

Signed-off-by: 秋雨落 <i@rain.cx>
This commit is contained in:
秋雨落
2023-09-14 15:21:21 +08:00
parent cf814e05fc
commit 1d62b1aae9
2 changed files with 5 additions and 2 deletions
@@ -29,10 +29,12 @@ public class WebSocketHandler
if (!webSocket.GetConnectionInfo().Authenticated) if (!webSocket.GetConnectionInfo().Authenticated)
{ {
var secret = reader.ReadTextString(); var secret = reader.ReadTextString();
var name = reader.ReadTextString();
if (secret == Config.GetSecretKey()) if (secret == Config.GetSecretKey())
{ {
Logger.LogInformation("Client {Id} authorized", webSocket.GetConnectionInfo().Id); Logger.LogInformation("Client {Name}({Id}) authorized", name, webSocket.GetConnectionInfo().Id);
webSocket.GetConnectionInfo().Authenticated = true; webSocket.GetConnectionInfo().Authenticated = true;
webSocket.GetConnectionInfo().Name = name;
await webSocket.Send(new S2CAuthenticatedPacket().Write); await webSocket.Send(new S2CAuthenticatedPacket().Write);
} }
else else
+2 -1
View File
@@ -44,6 +44,7 @@ reader.ReadEndArray();
``` ```
> Authenticate > Authenticate
> <string:SecretKey> > <string:SecretKey>
> <string:ClientName>
``` ```
认证成功: 认证成功:
@@ -58,5 +59,5 @@ reader.ReadEndArray();
<! Close <! Close
``` ```
#### 注册接收器 #### 注册频道