Skip to content

Commit

Permalink
Fixed improper logic of checking websocket message type
Browse files Browse the repository at this point in the history
  • Loading branch information
SinoAHpx committed May 21, 2022
1 parent d62fdf1 commit 2283f81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions Mirai.Net.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ internal static class Program
{
private static async Task Main()
{
var con = new ConnectConfig
{
HttpAddress = "",
WebsocketAddress = ""
};
return;
var exit = new ManualResetEvent(false);

using var bot = new MiraiBot
var bot = new MiraiBot
{
Address = "localhost:8080",
Address = new ConnectConfig
{
HttpAddress = new ConnectConfig.AdapterConfig("localhost", "8080"),
WebsocketAddress = new ConnectConfig.AdapterConfig("localhost", "1234")
},
VerifyKey = "1145141919810",
QQ = "1590454991"
};
Expand Down
4 changes: 2 additions & 2 deletions Mirai.Net/Sessions/MiraiBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void RedirectWebSocketData(string data)
throw new InvalidWebsocketReponseException("Websocket传回错误响应");
}

if (dataType.EndsWith("Message"))
if (dataType.Contains("Message"))
{
var receiver = ReflectionUtils.GetMessageReceiverBase(data);

Expand All @@ -250,7 +250,7 @@ private void RedirectWebSocketData(string data)

_messageReceivedSubject.OnNext(receiver);
}
else if (dataType.EndsWith("Event"))
else if (dataType.Contains("Event"))
{
_eventReceivedSubject.OnNext(ReflectionUtils.GetEventBase(data));
}
Expand Down

0 comments on commit 2283f81

Please sign in to comment.