// Path: src/main/java/com/neverwinterdp/sparkngin/Ack.java
// public class Ack implements Serializable {
//   static public enum Status { OK, ERROR, NOT_AVAIBLE }
// 
//   private Object messageId ;
//   private Status status;
//   private String message;
// 
//   public Object getMessageId() { return messageId; }
//   public void setMessageId(Object objectId) {
//     this.messageId = objectId;
//   }
// 
//   public Status getStatus() {
//     return status;
//   }
// 
//   public void setStatus(Status status) {
//     this.status = status;
//   }
// 
//   public String getMessage() {
//     return message;
//   }
// 
//   public void setMessage(String message) {
//     this.message = message;
//   }
// }


import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.QueryStringDecoder;
import com.neverwinterdp.message.Message;
import com.neverwinterdp.netty.http.RouteHandlerGeneric;
import com.neverwinterdp.sparkngin.Ack;
import com.neverwinterdp.sparkngin.Sparkngin;
import com.neverwinterdp.util.JSONSerializer;

package com.neverwinterdp.sparkngin.http;


/**
 * @author Tuan Nguyen
 * @email  tuan08@gmail.com
 */
public class JSONMessageRouteHandler extends RouteHandlerGeneric {
  private Sparkngin sparkngin ;
  
  public JSONMessageRouteHandler(Sparkngin sparkngin)  {
    this.sparkngin = sparkngin ;
  }
  
  @Override
  protected void doGet(ChannelHandlerContext ctx, HttpRequest httpReq) {
    QueryStringDecoder reqDecoder = new QueryStringDecoder(httpReq.getUri()) ;
    String data = reqDecoder.parameters().get("data").get(0) ;
    Message message = JSONSerializer.INSTANCE.fromString(data, Message.class) ;

// Path: src/main/java/com/neverwinterdp/sparkngin/Ack.java
// public class Ack implements Serializable {
//   static public enum Status { OK, ERROR, NOT_AVAIBLE }
// 
//   private Object messageId ;
//   private Status status;
//   private String message;
// 
//   public Object getMessageId() { return messageId; }
//   public void setMessageId(Object objectId) {
//     this.messageId = objectId;
//   }
// 
//   public Status getStatus() {
//     return status;
//   }
// 
//   public void setStatus(Status status) {
//     this.status = status;
//   }
// 
//   public String getMessage() {
//     return message;
//   }
// 
//   public void setMessage(String message) {
//     this.message = message;
//   }
// }


// Path: src/main/java/com/neverwinterdp/sparkngin/http/JSONMessageRouteHandler.java
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.QueryStringDecoder;
import com.neverwinterdp.message.Message;
import com.neverwinterdp.netty.http.RouteHandlerGeneric;
import com.neverwinterdp.sparkngin.Ack;
import com.neverwinterdp.sparkngin.Sparkngin;
import com.neverwinterdp.util.JSONSerializer;

package com.neverwinterdp.sparkngin.http;


/**
 * @author Tuan Nguyen
 * @email  tuan08@gmail.com
 */
public class JSONMessageRouteHandler extends RouteHandlerGeneric {
  private Sparkngin sparkngin ;
  
  public JSONMessageRouteHandler(Sparkngin sparkngin)  {
    this.sparkngin = sparkngin ;
  }
  
  @Override
  protected void doGet(ChannelHandlerContext ctx, HttpRequest httpReq) {
    QueryStringDecoder reqDecoder = new QueryStringDecoder(httpReq.getUri()) ;
    String data = reqDecoder.parameters().get("data").get(0) ;
    Message message = JSONSerializer.INSTANCE.fromString(data, Message.class) ;

    Ack ack = sparkngin.push(message);
