Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.peacefulcraft.xcom.api.session;

import java.util.Date;

import net.peacefulcraft.xcom.api.party.IParty;
import net.peacefulcraft.xcom.api.profile.IUserProfile;

public interface ISession {

/**
* @return The unique Id associated with this session, as issued by the API server.
*/
public Long sessionId();

/**
* @return The UserProfile associated with this session
*/
public IUserProfile getUserProfile();

/**
* @return True if the associated user is still "online," false otherwise
*/
public boolean isActive();

/**
* @return The datetime (UTC) which this session began
*/
public Date sessionStart();

/**
* @return The datetime (UTC) which this session ended
*/
public Date sessionEnd();

/**
* Get the party which this user is a member of, if they are a party member.
* @return Party instance, or null if user is not a member of a party.
*/
public IParty getParty();

/**
* Append a simple k/v property to this session that will be synchronized accross the API.
*
* @param property The key for this property
* @param value Thing to store on this session.
*/
public void setSessionProperty(String property, String value);

/**
* Delete the session property with the provided key.
* @param property
*/
public void removeSessionProperty(String property);

/**
* Retrieve a k/v property stored on this session
*
* @param property The key for the property to fetch
* @return The value of the property, or NULL if no such property exists.
*/
public String getSessionProperty(String property);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package net.peacefulcraft.xcom.api.session;

import java.util.List;
import java.util.Map;

import net.peacefulcraft.xcom.api.profile.IUserProfile;

public interface ISessionService {

/**
* Create a new Session for the indicated Session holder
*
* @param holder The user to which this session belongs
*/
public ISession createSession(IUserProfile Holder);

/**
* @param sessionId Id of the session to fetch
* @return Session instance, or null if one was not found.
*/
public ISession getSessionById(Long sessionId);

/**
* @param Holder User who holds this session
* @return Session instance, or null if one was not found.
*/
public ISession getSessionByUserProfile(IUserProfile Holder);

/**
* Destroy the Session - and all associated data - with this sessionId
* @param sessionId
*/
public void destroySession(Long sessionId);

/**
* Fetches all existing sessions that meet the search criteria provided.
*
* @param filters K/V pairs to search for. Both may contain wildcards (%).
* IE: <xcom.party%, %> would fetch all profiles with any property matching
* "xcom.party%" that has "any" (%) value.
*/
public List<ISession> filterSessionsByProperties(Map<String, String> filters);
}