Exemple #1
0
class SimpleUserRPCWrapper(object):
    def __init__(self, hostname, username, password, ssl, pin):
        self._pin = pin
        self.rpc = SimpleLazyObject(
            lambda: user.User(hostname, user=username, password=password, ssl=ssl)
        )

    def authenticate_endpoint(self, **kwargs):
        """
        Get information necessary to allow an endpoint to authenticate itself.
        All kwargs are passed to the underlying transport.
        """
        # We modify kwargs
        kwargs = copy.copy(kwargs)
        guest = kwargs.pop('guest', True)
        return self.rpc.endpoint_login_data(guest=guest, **kwargs)

    def activate_endpoint(self, endpoint_id, **kwargs):
        """
        Given an authenticated endpoint, activate it so that calls can be made.
        It is an error to attempt to activate an inactive client, but this is
        not checked.
        """
        return self.rpc.activate_endpoint(endpoint_id, **kwargs)

    def join_conference(self, conference, **kwargs):
        """
        Bring an activated endpoint into a call. It is an error to call this
        on an inactive endpoint.
        """
        if not isinstance(conference, (int, )):
            raise TypeError(
                "Conferences must be referenced by their integer id, or"
                "be a subclass of VidyoUserBase"
            )
        return self.rpc.join_room(None, room_id=conference, pin=self._pin, **kwargs)

    def terminate(self):
        """
        Eject the user's endpoints from all calls, and deauthenticate known
        endpoints.
        """
        self.rpc.log_out()