Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 48c8b3c

Browse files
authored
[Core] Adjust log level for Unsupported SSOFrame message (#829)
1 parent b449346 commit 48c8b3c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Lagrange.Core/Internal/Context/ServiceContext.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ namespace Lagrange.Core.Internal.Context;
1616
internal class ServiceContext : ContextBase
1717
{
1818
private const string Tag = nameof(ServiceContext);
19-
19+
2020
private readonly SequenceProvider _sequenceProvider;
2121
private readonly Dictionary<string, IService> _services;
2222
private readonly Dictionary<Type, List<(ServiceAttribute Attribute, IService Instance)>> _servicesEventType;
2323

24-
public ServiceContext(ContextCollection collection, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device)
24+
public ServiceContext(ContextCollection collection, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device)
2525
: base(collection, keystore, appInfo, device)
2626
{
2727
_sequenceProvider = new SequenceProvider();
2828
_services = new Dictionary<string, IService>();
2929
_servicesEventType = new Dictionary<Type, List<(ServiceAttribute, IService)>>();
30-
30+
3131
RegisterServices();
3232
}
3333

@@ -47,7 +47,7 @@ private void RegisterServices()
4747
{
4848
var service = (IService)type.CreateInstance();
4949
_services[serviceAttribute.Command] = service;
50-
50+
5151
foreach (var attribute in type.GetCustomAttributes<EventSubscribeAttribute>())
5252
{
5353
_servicesEventType[attribute.EventType].Add((serviceAttribute, service));
@@ -71,30 +71,30 @@ public List<SsoPacket> ResolvePacketByEvent(ProtocolEvent protocolEvent)
7171
if (success && binary != null)
7272
{
7373
result.Add(new SsoPacket(attribute.PacketType, attribute.Command, (uint)_sequenceProvider.GetNewSequence(), binary.ToArray()));
74-
74+
7575
if (extraPackets is { } extra)
7676
{
7777
var packets = extra.Select(e => new SsoPacket(attribute.PacketType, attribute.Command, (uint)_sequenceProvider.GetNewSequence(), e.ToArray()));
7878
result.AddRange(packets);
7979
}
80-
80+
8181
Collection.Log.LogDebug(Tag, $"Outgoing SSOFrame: {attribute.Command}");
8282
}
8383
}
8484

8585
return result;
8686
}
87-
87+
8888
/// <summary>
8989
/// Resolve the incoming event by the packet
9090
/// </summary>
9191
public List<ProtocolEvent> ResolveEventByPacket(SsoPacket packet)
9292
{
9393
var result = new List<ProtocolEvent>();
94-
94+
9595
if (!_services.TryGetValue(packet.Command, out var service))
9696
{
97-
Collection.Log.LogWarning(Tag, $"Unsupported SSOFrame Received: {packet.Command}");
97+
Collection.Log.LogInfo(Tag, $"Unsupported SSOFrame Received: {packet.Command}");
9898
Collection.Log.LogDebug(Tag, $"Unsuccessful SSOFrame Payload: {packet.Payload.Hex()}");
9999
return result; // 没找到 滚蛋吧
100100
}
@@ -105,27 +105,27 @@ public List<ProtocolEvent> ResolveEventByPacket(SsoPacket packet)
105105
{
106106
if (@event != null) result.Add(@event);
107107
if (extraEvents != null) result.AddRange(extraEvents);
108-
108+
109109
Collection.Log.LogDebug(Tag, $"Incoming SSOFrame: {packet.Command}");
110110
}
111-
111+
112112
return result;
113113
}
114-
114+
115115
public int GetNewSequence() => _sequenceProvider.GetNewSequence();
116-
116+
117117
private class SequenceProvider
118118
{
119119
private readonly ConcurrentDictionary<string, int> _sessionSequence = new();
120-
120+
121121
private int _sequence = Random.Shared.Next(5000000, 9900000);
122122

123123
public int GetNewSequence()
124124
{
125125
Interlocked.CompareExchange(ref _sequence, 5000000, 9900000);
126126
return Interlocked.Increment(ref _sequence);
127127
}
128-
128+
129129
public int RegisterSession(string sessionId) => _sessionSequence.GetOrAdd(sessionId, GetNewSequence());
130130
}
131131
}

0 commit comments

Comments
 (0)