use of com.google.samples.apps.iosched.server.schedule.server.GCMPing in project iosched by google.
the class UserdataEndpoint method addReservedSession.
/**
* Add a reserved session for the specified user. If the session is already in the user's feed,
* it will be annotated with status=RESERVED.
*
* @param user Service account making the request (injected by Endpoints)
* @param userId User ID of user that reserved a session.
* @param sessionId Session ID to mark as reserved.
* @param timestampUTC The time (in millis, UTC) when the user performed this action. May be
* different than the time this method is called if offline sync is
* implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
* @return The list of reserved sessions for the user
*/
@ApiMethod(name = "addReservedSession", path = "reservations", httpMethod = ApiMethod.HttpMethod.PUT, clientIds = { Ids.SERVICE_ACCOUNT_CLIENT_ID })
public Map<String, ReservedSession> addReservedSession(User user, @Named("userId") String userId, @Named("sessionId") String sessionId, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
UserData data = getUser(user, userId);
ReservedSession s = new ReservedSession(sessionId, Status.RESERVED, timestampUTC);
data.reservedSessions.put(sessionId, s);
save(data);
// notify user's clients of reservation change change
new GCMPing().notifyUserSync(data.userId);
return data.reservedSessions;
}
use of com.google.samples.apps.iosched.server.schedule.server.GCMPing in project iosched by google.
the class UserdataEndpoint method removeReservedSession.
/**
* Remove a reserved session for the specified user. The session will still be
* attached to the user's feed, but will be annotated with status=DELETED.
*
* @param user Service account making the request (injected by Endpoints)
* @param userId User ID of user that reserved a session.
* @param sessionId Session ID to mark as not reserved.
* @param timestampUTC The time (in millis, UTC) when the user performed this action. May be
* different than the time this method is called if offline sync is
* implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
*/
@ApiMethod(name = "removeReservedSession", path = "reservations", httpMethod = ApiMethod.HttpMethod.DELETE, clientIds = { Ids.SERVICE_ACCOUNT_CLIENT_ID })
public void removeReservedSession(User user, @Named("userId") String userId, @Named("sessionId") String sessionId, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
UserData data = getUser(user, userId);
ReservedSession s = new ReservedSession(sessionId, Status.DELETED, timestampUTC);
data.reservedSessions.put(sessionId, s);
save(data);
// notify user's clients of reservation change change
new GCMPing().notifyUserSync(data.userId);
}
use of com.google.samples.apps.iosched.server.schedule.server.GCMPing in project iosched by google.
the class UserdataEndpoint method addWaitlistedSession.
/**
* Add a waitlisted session for the specified user. If the session is already in the user's feed,
* it will be annotated with status=WAITLISTED.
*
* @param user Service account making the request (injected by Endpoints)
* @param userId User ID of user that reserved a session.
* @param sessionId Session ID to mark as reserved.
* @param timestampUTC The time (in millis, UTC) when the user performed this action. May be
* different than the time this method is called if offline sync is
* implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
* @return The list of reserved sessions for the user
*/
@ApiMethod(name = "addWaitlistedSession", path = "reservations/waitlist", httpMethod = ApiMethod.HttpMethod.PUT, clientIds = { Ids.SERVICE_ACCOUNT_CLIENT_ID })
public Map<String, ReservedSession> addWaitlistedSession(User user, @Named("userId") String userId, @Named("sessionId") String sessionId, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
UserData data = getUser(user, userId);
ReservedSession s = new ReservedSession(sessionId, Status.WAITLISTED, timestampUTC);
data.reservedSessions.put(sessionId, s);
save(data);
// notify user's clients of reservation change change
new GCMPing().notifyUserSync(data.userId);
return data.reservedSessions;
}
Aggregations