// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
// 
//     /**
//      * Called once the connection has been established and the
//      * subscription has been acknowledged by the Vantiq server.
//      */
//     void onConnect();
// 
//     /**
//      * Called for every matching event that occurs
//      *
//      * @param message The information associated with the event
//      */
//     void onMessage(SubscriptionMessage message);
// 
//     /**
//      * Called whenever an error occurs that does not arise from
//      * an exception, such as if a non-success response is provided.
//      *
//      * @param error The error message
//      */
//     void onError(String error);
// 
//     /**
//      * Called whenever an exception occurs during the subscription
//      * processing.
//      *
//      * @param t The exception thrown
//      */
//     void onFailure(Throwable t);
// }
// 
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
// 
//     private int status;
//     private String contentType;
//     private Map<String, String> headers;
//     private Object body;
// 
//     /**
//      * The HTTP status code for this message.  Usually, this is 100.
//      *
//      * @return The status code for the message
//      */
//     public int getStatus() {
//         return status;
//     }
// 
//     /**
//      * The content type for the body of the message.  Usually, this is
//      * application/json indicating the content was JSON encoded.
//      *
//      * @return The MIME type for the message body
//      */
//     public String getContentType() {
//         return contentType;
//     }
// 
//     /**
//      * The headers associated with the message.
//      *
//      * @return The headers for the message.
//      */
//     public Map<String, String> getHeaders() {
//         return headers;
//     }
// 
//     /**
//      * Returns the payload for the message.  For a JSON encoded
//      * message, this would be a Map.
//      *
//      * @return The body of the message.
//      */
//     public Object getBody() {
//         return body;
//     }
// 
//     public String toString() {
//         StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
//         sb.append("  status:").append(this.status).append('\n');
//         sb.append("  contentType:").append(this.contentType).append('\n');
//         sb.append("  headers:").append(this.headers).append('\n');
//         sb.append("  body:").append(this.body).append('\n');
//         sb.append(']');
//         return sb.toString();
//     }
// }


import java.io.IOException;
import javax.websocket.Session;
import com.google.gson.internal.LinkedTreeMap;
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import io.vantiq.prontoClient.servlet.*;
package io.vantiq.prontoClient;





public class SubscriptionOutputCallback implements SubscriptionCallback {
    
    // Websocket session used to send messages to client
    Session wsSession;
    String sessionID;
    
    public SubscriptionOutputCallback(String sessionID) {
        this.sessionID = sessionID;
    }
    
    @Override
    public void onConnect() {
        // (Uncomment to debug)
        //System.out.println("Connected Successfully");
    }

    @Override
    public void onMessage(SubscriptionMessage message) { 
        // Getting message body, which contains the event data
        LinkedTreeMap<?,?> bodyTree = (LinkedTreeMap<?,?>) message.getBody();
        
        // Getting the WebSocket Session for our given Session ID
// Path: src/main/java/io/vantiq/client/SubscriptionCallback.java
// public interface SubscriptionCallback {
// 
//     /**
//      * Called once the connection has been established and the
//      * subscription has been acknowledged by the Vantiq server.
//      */
//     void onConnect();
// 
//     /**
//      * Called for every matching event that occurs
//      *
//      * @param message The information associated with the event
//      */
//     void onMessage(SubscriptionMessage message);
// 
//     /**
//      * Called whenever an error occurs that does not arise from
//      * an exception, such as if a non-success response is provided.
//      *
//      * @param error The error message
//      */
//     void onError(String error);
// 
//     /**
//      * Called whenever an exception occurs during the subscription
//      * processing.
//      *
//      * @param t The exception thrown
//      */
//     void onFailure(Throwable t);
// }
// 
// Path: src/main/java/io/vantiq/client/SubscriptionMessage.java
// public class SubscriptionMessage {
// 
//     private int status;
//     private String contentType;
//     private Map<String, String> headers;
//     private Object body;
// 
//     /**
//      * The HTTP status code for this message.  Usually, this is 100.
//      *
//      * @return The status code for the message
//      */
//     public int getStatus() {
//         return status;
//     }
// 
//     /**
//      * The content type for the body of the message.  Usually, this is
//      * application/json indicating the content was JSON encoded.
//      *
//      * @return The MIME type for the message body
//      */
//     public String getContentType() {
//         return contentType;
//     }
// 
//     /**
//      * The headers associated with the message.
//      *
//      * @return The headers for the message.
//      */
//     public Map<String, String> getHeaders() {
//         return headers;
//     }
// 
//     /**
//      * Returns the payload for the message.  For a JSON encoded
//      * message, this would be a Map.
//      *
//      * @return The body of the message.
//      */
//     public Object getBody() {
//         return body;
//     }
// 
//     public String toString() {
//         StringBuilder sb = new StringBuilder("SubscriptionMessage[\n");
//         sb.append("  status:").append(this.status).append('\n');
//         sb.append("  contentType:").append(this.contentType).append('\n');
//         sb.append("  headers:").append(this.headers).append('\n');
//         sb.append("  body:").append(this.body).append('\n');
//         sb.append(']');
//         return sb.toString();
//     }
// }


// Path: examples/JavaProntoClient/src/main/java/io/vantiq/prontoClient/SubscriptionOutputCallback.java
import java.io.IOException;
import javax.websocket.Session;
import com.google.gson.internal.LinkedTreeMap;
import io.vantiq.client.SubscriptionCallback;
import io.vantiq.client.SubscriptionMessage;
import io.vantiq.prontoClient.servlet.*;

package io.vantiq.prontoClient;





public class SubscriptionOutputCallback implements SubscriptionCallback {
    
    // Websocket session used to send messages to client
    Session wsSession;
    String sessionID;
    
    public SubscriptionOutputCallback(String sessionID) {
        this.sessionID = sessionID;
    }
    
    @Override
    public void onConnect() {
        // (Uncomment to debug)
        //System.out.println("Connected Successfully");
    }

    @Override
    public void onMessage(SubscriptionMessage message) { 
        // Getting message body, which contains the event data
        LinkedTreeMap<?,?> bodyTree = (LinkedTreeMap<?,?>) message.getBody();
        
        // Getting the WebSocket Session for our given Session ID
        if (wsSession == null) {