-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
//MQTTParse中 Write函对ISession参数做了一些处理,但是MQTTClientPacke中调用直接传空,导致发送时异常,请问MQTTClientPacke中如何才能拿到ISession解决此报错呢
public void Write(MQTTMessage msg, Stream stream, ISession session)
{
IServer server = session.Server;
if (server.EnableLog(LogType.Debug))
{
server.Log(LogType.Debug, session, $"write mqtt message {msg}");
}
MemoryStream protocolStream = GetProtocolStream();
int num = 0;
num |= (int)msg.Type << 4;
if (msg.DUP)
{
num |= 8;
}
num |= (int)msg.QoS << 1;
if (msg.Retain)
{
num |= 1;
}
stream.WriteByte((byte)num);
msg.Write(protocolStream, session);
if (server.EnableLog(LogType.Debug))
{
server.Log(LogType.Debug, session, $"write mqtt message body size {protocolStream.Length}");
}
mInt7BitHandler.Write(stream, (int)protocolStream.Length);
protocolStream.Position = 0L;
protocolStream.CopyTo(stream);
if (server.EnableLog(LogType.Debug))
{
server.Log(LogType.Debug, session, "write mqtt message success");
}
}
}
MQTTClientPacket中加密部分中:
public void Encode(object data, IClient client, Stream stream)
{
MQTTMessage mQTTMessage = data as MQTTMessage;
if (mQTTMessage != null)
{
mMQTTParse.Write(mQTTMessage, stream.ToPipeStream(), null);
return;
}
throw new BXException("Invalid message type!");
}
Metadata
Metadata
Assignees
Labels
No labels