001package core.tut.pori.websocket;
002
003import javax.websocket.CloseReason;
004
005import core.tut.pori.http.Response;
006
007/**
008 * Definitions for websocket package.
009 * 
010 */
011public final class Definitions {
012  /* close reasons */
013  /** CloseReason with HTTP status code Bad Request */
014  public static final CloseReason CLOSE_REASON_BAD_REQUEST = new CloseReason(new CloseReason.CloseCode() {    
015    @Override
016    public int getCode() {
017      return Response.Status.BAD_REQUEST.toStatusCode();
018    }
019  }, Response.Status.BAD_REQUEST.name());
020  
021  /** CloseReason with HTTP status code Forbidden */
022  public static final CloseReason CLOSE_REASON_FORBIDDEN = new CloseReason(new CloseReason.CloseCode() {    
023    @Override
024    public int getCode() {
025      return Response.Status.FORBIDDEN.toStatusCode();
026    }
027  }, Response.Status.FORBIDDEN.name());
028  
029  /** CloseReason with HTTP status code Not Found */
030  public static final CloseReason CLOSE_REASON_NOT_FOUND = new CloseReason(new CloseReason.CloseCode() {    
031    @Override
032    public int getCode() {
033      return Response.Status.NOT_FOUND.toStatusCode();
034    }
035  }, Response.Status.NOT_FOUND.name());
036  
037  /** CloseReason with HTTP status code Internal Server Error */
038  public static final CloseReason CLOSE_REASON_INTERNAL_SERVER_ERROR = new CloseReason(new CloseReason.CloseCode() {    
039    @Override
040    public int getCode() {
041      return Response.Status.INTERNAL_SERVER_ERROR.toStatusCode();
042    }
043  }, Response.Status.INTERNAL_SERVER_ERROR.name());
044  
045  /** CloseReason with HTTP status code Unauthorized */
046  public static final CloseReason CLOSE_REASON_UNAUTHORIZED = new CloseReason(new CloseReason.CloseCode() {   
047    @Override
048    public int getCode() {
049      return Response.Status.UNAUTHORIZED.toStatusCode();
050    }
051  }, Response.Status.UNAUTHORIZED.name());
052  
053  
054  /**
055   * 
056   */
057  private Definitions(){
058    // nothing needed
059  }
060}