def sendAttachUserConfirm(self, success, param): """ Send an Attach User Confirm PDU to the client. :param success: whether the request was successful or not. :type success: bool :param param: if the request was successful, then this is a user ID. Otherwise, this is the error code. :type param: int """ if success: userID = param user = MCSUser(self, self.factory) self.users[userID] = user user.onAttachConfirmed(userID) pdu = MCSAttachUserConfirmPDU(0, userID) else: pdu = MCSAttachUserConfirmPDU(param, None) self.mcs.send(pdu)
def parseAttachUserConfirm(self, stream: BytesIO) -> MCSAttachUserConfirmPDU: """ Parse an Attach User Confirm PDU :param stream: stream containing the data """ result = per.readEnumeration(stream) data = stream.read() initiator = None if len(data) == 2: initiator = Uint16BE.unpack(data) + MCSChannelID.USERCHANNEL_BASE elif len(data) > 2: raise ParsingError("Unexpected payload") return MCSAttachUserConfirmPDU(result, initiator)