✨ 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)
{
var secret = reader.ReadTextString();
var name = reader.ReadTextString();
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().Name = name;
await webSocket.Send(new S2CAuthenticatedPacket().Write);
}
else
+2 -1
View File
@@ -44,6 +44,7 @@ reader.ReadEndArray();
```
> Authenticate
> <string:SecretKey>
> <string:ClientName>
```
认证成功:
@@ -58,5 +59,5 @@ reader.ReadEndArray();
<! Close
```
#### 注册接收器
#### 注册频道