Exemple #1
0
    def disconnect(self, reason=DisconnectReason.Unspecified, error=0):
        """
        Disconnect console session

        Args:
            reason (:class:`DisconnectReason`): Disconnect reason
            error (int): Error Code

        Returns: None
        """
        msg = factory.disconnect(reason, error)
        self.send_message(msg)
    async def disconnect(
            self,
            reason: DisconnectReason = DisconnectReason.Unspecified,
            error: int = 0) -> None:
        """
        Disconnect console session

        Args:
            reason: Disconnect reason
            error: Error Code

        Returns: None
        """
        msg = factory.disconnect(reason, error)
        await self.send_message(msg)
Exemple #3
0
def test_disconnect(packets, crypto):
    bin_name = 'disconnect'
    msg = factory.disconnect(reason=enum.DisconnectReason.Unspecified,
                             error_code=0)
    msg.header(sequence_number=57, source_participant_id=31)
    msg.header.flags(need_ack=False)
    packed = _pack(msg, crypto)

    assert msg.header.pkt_type == enum.PacketType.Message
    assert msg.header.flags.msg_type == enum.MessageType.Disconnect

    assert msg.protected_payload.reason == enum.DisconnectReason.Unspecified
    assert msg.protected_payload.error_code == 0

    assert len(packed) == len(packets[bin_name])
    assert packed == packets[bin_name]