Ejemplo n.º 1
0
    def clear_update(self, data, sesh):
        """Clear

		Clears the given number of messages from the sync cache

		Arguments:
			data {dict} -- Data sent with the request
			sesh {Sesh._Session} -- The session associated with the request

		Returns:
			Services.Effect
		"""

        # Verify fields
        try:
            DictHelper.eval(data, ['service', 'key', 'count'])
        except ValueError as e:
            return Services.Effect(error=(1001, [(f, "missing")
                                                 for f in e.args]))

        # Clear the messages from the sync cache
        Sync.clear(sesh.id(), data['service'], data['key'], data['count'])

        # Return OK
        return Services.Effect(True)
Ejemplo n.º 2
0
    def pull_read(self, data, sesh):
        """Pull

		A client is requesting an update on anything they might be looking at

		Arguments:
			data {dict} -- Data sent with the request
			sesh {Sesh._Session} -- The session associated with the request

		Returns:
			Services.Effect
		"""

        # Verify fields
        try:
            DictHelper.eval(data, ['service', 'key'])
        except ValueError as e:
            return Services.Effect(error=(1001, [(f, "missing")
                                                 for f in e.args]))

        # If we have messages to delete
        if 'messages' in data and data['messages']:
            Sync.clear(sesh.id(), data['service'], data['key'],
                       data['messages'])

        # Get as many messages as possible
        lRet = Sync.pull(sesh.id(), data['service'], data['key'])

        # Return whatever was found
        return Services.Effect(lRet)