private void ReceiveConnack() { PacketBase packet = Transport.Read(); ConnackPacket connack = packet as ConnackPacket; if (packet == null) { WriteToLog(Localization.UseRussian ? String.Format("Первый принимаемый пакет должен быть Connack, но получили {0}", packet.GetType().Name) : String.Format("First received message should be Connack, but {0} received instead", packet.GetType().Name)); throw new MqttProtocolException(String.Format("First received message should be Connack, but {0} received instead", packet.GetType().Name)); } if (connack.ReturnCode != ConnackReturnCode.Accepted) { WriteToLog(Localization.UseRussian ? "Соединение не разрешено брокером" : "The connection was not accepted"); throw new MqttConnectException("The connection was not accepted", connack.ReturnCode); } this.IsSessionPresent = connack.SessionPresent; }
private void ReceiveConnack() { PacketBase packet = Transport.Read(); this.LastRead = Environment.TickCount; var connack = packet as ConnackPacket; if (packet == null) { throw new MqttProtocolException(String.Format("First received message should be Connack, but {0} received instead", packet.GetType().Name)); } if (connack.ReturnCode != ConnackReturnCode.Accepted) { throw new MqttConnectException("The connection was not accepted", connack.ReturnCode); } this.IsSessionPresent = connack.SessionPresent; }
private bool ReceiveConnack() { PacketBase packet = Transport.Read(); if (packet == null) { WriteToLog(Localization.UseRussian ? "Ошибка: первый пакет не получен" : "Error: first packet is not received"); } else if (!(packet is ConnackPacket connack)) { WriteToLog(string.Format(Localization.UseRussian ? "Ошибка: первый принимаемый пакет должен быть Connack, но получили {0}" : "Error: first packet must be Connack, but {0} received", packet.GetType().Name)); }