In order to return user-specific data, your Data Adapter must supply user-specific items. The Metadata Adapter can enforce that a user-specific item can only be subscribed to by the related user (or that a placeholder item name requested by a user is converted into the user-specific item name).
The Messenger Demo, in
DOCS-SDKs\sdk_adapter_java\examples\Messenger_Adapters
, shows this, though in java.
The items whose name has the form im_<nickname> are user-specific. In this simple case, the Metadata Adapter does not implement user authentication, hence it does not check that a nickname can only be requested by the related user.
About getting historical data based on time (i.e. the last 4 hours), there is no direct support. We expect that those kinds of queries can be issued to the application server that supplies the site pages.
You can still take advantage of Lightstreamer items through some workarounds.
For instance, the snapshot of a DISTINCT mode item can accumulate the history, though it must be limited in size (i.e. it cannot be set as unlimited). If the maximum history dimension expected is limited, then you could use a single DISTINCT item and set a very high snapshot length limit for it, so that all historical events and all new events are kept in the snapshot; then you could manage the requests for different history depths through a selector.
Upon the subscription of the item, the current history should be supplied by the Data Adapter as the item snapshot.
In order not to stress the Server, it is advisable that only few items are of this kind and that such items are always kept subscribed to.
Other workarounds to accomplish your goal are possible.