source: src/main/java/geniusweb/partiesserver/Info.java@ 24

Last change on this file since 24 was 24, checked in by bart, 4 years ago

Voting requests now contain Offers. Fixed windows whitespace issue. Partiesserver now supports up to 8 parties simultaneously.

File size: 1.4 KB
Line 
1package geniusweb.partiesserver;
2
3import java.io.IOException;
4
5import javax.servlet.ServletException;
6import javax.servlet.http.HttpServlet;
7import javax.servlet.http.HttpServletRequest;
8import javax.servlet.http.HttpServletResponse;
9
10import com.fasterxml.jackson.databind.ObjectMapper;
11
12import geniusweb.partiesserver.repository.RunningPartiesRepo;
13import geniusweb.serverobjects.ServerInfo;
14
15/**
16 * Servlet implementation to get general info from the server.
17 */
18public class Info extends HttpServlet {
19
20 private final static RunningPartiesRepo repo = RunningPartiesRepo
21 .instance();
22 private final static ObjectMapper jackson = new ObjectMapper();
23
24 /**
25 * see
26 * {@link HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)}.
27 * Returns to the http caller
28 * <ul>
29 * <li>URL with websocket address to contact the now running agent.
30 * <li>SC_NOT_FOUND (404) if attempt is made to access non-running party.
31 * <li>SC_SERVICE_UNAVAILABLE (503) if there are no free slots to run the
32 * party.
33 * <li>SC_EXPECTATION_FAILED (417) if something else goes wrong during
34 * instantiating the party (then see logs for more details)
35 * </ul>
36 */
37 @Override
38 protected void doGet(HttpServletRequest request,
39 HttpServletResponse response) throws ServletException, IOException {
40 response.getWriter().append(jackson.writeValueAsString(
41 new ServerInfo(repo.availableSlots(), repo.maximumSlots())));
42 }
43}
Note: See TracBrowser for help on using the repository browser.