Beispiel #1
0
    def sendChannelJoinConfirm(self, result, userID, channelID, notify=True):
        """
        Send a Channel Join Confirm PDU.
        :param result: the result code (0 if the request was successful).
        :type result: int
        :param userID: the user ID.
        :type result: int
        :param channelID: the channel ID.
        :type channelID: int
        :param notify: True if the user should be notified (default).
        :type notify: bool
        """

        if notify:
            if result == MCSResult.RT_SUCCESSFUL:
                self.users[userID].channelJoinAccepted(self.mcs, channelID)
            else:
                self.users[userID].channelJoinRefused(result, channelID)

        # t.125 specification document, section 11.22
        channelIdField = channelID if result == MCSResult.RT_SUCCESSFUL else None

        pdu = MCSChannelJoinConfirmPDU(result, userID, channelID,
                                       channelIdField, b"")
        self.mcs.send(pdu)
Beispiel #2
0
    def parseChannelJoinConfirm(self, stream: BytesIO) -> MCSChannelJoinConfirmPDU:
        """
        Parse a Channel Join Confirm PDU
        :param stream: stream containing the data
        """
        result = per.readEnumeration(stream)
        data = stream.read()

        if len(data) < 4 or len(data) == 5:
            raise ParsingError("Invalid Channel Join Confirm PDU received")
        elif len(data) >= 6:
            channelID = Uint16BE.unpack(data[4 : 6])
            payload = data[6 :]
        else:
            channelID = None
            payload = b""

        initiator = Uint16BE.unpack(data[0 : 2]) + MCSChannelID.USERCHANNEL_BASE
        requested = Uint16BE.unpack(data[2 : 4])
        return MCSChannelJoinConfirmPDU(result, initiator, requested, channelID, payload)