// Path: src/main/java/org/tagsys/tagbeat/cr/Signal.java
// public  class Signal{
// 	
// 		public static final int CODE_NO_ERROR = 0;
// 	
// 		public static final int CODE_NO_VIBRATION = 1;
// 	
// 		protected int code;
// 		
// 		protected boolean[] timeIndicator;
// 		
// 		protected RealMatrix phaseSeries;
// 		
// 		protected RealMatrix phi;
// 		
// 		protected RealMatrix recoveredSeries;
// 		
// 		protected double frequency;//the fundamental frequency
// 		
// 
// 		public boolean[] getTimeIndicator() {
// 			return timeIndicator;
// 		}
// 
// 		public void setTimeIndicator(boolean[] timeIndicator) {
// 			this.timeIndicator = timeIndicator;
// 		}
// 
// 		public RealMatrix getPhaseSeries() {
// 			return phaseSeries;
// 		}
// 
// 		public void setPhaseSeries(RealMatrix phaseSeries) {
// 			this.phaseSeries = phaseSeries;
// 		}
// 
// 		public RealMatrix getPhi() {
// 			return phi;
// 		}
// 
// 		public void setPhi(RealMatrix phi) {
// 			this.phi = phi;
// 		}
// 
// 		public RealMatrix getRecoveredSeries() {
// 			return recoveredSeries;
// 		}
// 
// 		public void setRecoveredSeries(RealMatrix recoveredSeries) {
// 			this.recoveredSeries = recoveredSeries;
// 		}
// 		
// 		public double getFrequency() {
// 			return frequency;
// 		}
// 
// 		public void setFrequency(double frequency) {
// 			this.frequency = frequency;
// 		}
// 		
// 	
// 						
// }


import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.websocket.api.*;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.tagsys.tagbeat.cr.Signal;
import com.google.gson.Gson;
package org.tagsys.tagbeat;




/**
 * Handler the messages needed to broadcast to browsers.
 * 
 * @author Young
 *
 */
@WebSocket
public class WebSocketServer {

	private static List<Session> sessions = new ArrayList<Session>();
		
	protected static WebSocketServer instance;
	
	public static WebSocketServer getInstance(){
		return instance;
	}
	
	public WebSocketServer(){
		
		instance = this;
		
	}
	
    @OnWebSocketConnect
    public void onConnect(Session session) throws Exception {
    	    	
    	System.out.println("on connect");
    	
    	sessions.add(session);
    		
    }

    @OnWebSocketClose
    public void onClose(Session session, int statusCode, String reason) {
    	    	
        sessions.remove(session);
    }

    @OnWebSocketMessage
    public void onMessage(Session session, String message) {
   	
    	//keep nothing, we don't need receive any message from browser.
  
    }
    
   
// Path: src/main/java/org/tagsys/tagbeat/cr/Signal.java
// public  class Signal{
// 	
// 		public static final int CODE_NO_ERROR = 0;
// 	
// 		public static final int CODE_NO_VIBRATION = 1;
// 	
// 		protected int code;
// 		
// 		protected boolean[] timeIndicator;
// 		
// 		protected RealMatrix phaseSeries;
// 		
// 		protected RealMatrix phi;
// 		
// 		protected RealMatrix recoveredSeries;
// 		
// 		protected double frequency;//the fundamental frequency
// 		
// 
// 		public boolean[] getTimeIndicator() {
// 			return timeIndicator;
// 		}
// 
// 		public void setTimeIndicator(boolean[] timeIndicator) {
// 			this.timeIndicator = timeIndicator;
// 		}
// 
// 		public RealMatrix getPhaseSeries() {
// 			return phaseSeries;
// 		}
// 
// 		public void setPhaseSeries(RealMatrix phaseSeries) {
// 			this.phaseSeries = phaseSeries;
// 		}
// 
// 		public RealMatrix getPhi() {
// 			return phi;
// 		}
// 
// 		public void setPhi(RealMatrix phi) {
// 			this.phi = phi;
// 		}
// 
// 		public RealMatrix getRecoveredSeries() {
// 			return recoveredSeries;
// 		}
// 
// 		public void setRecoveredSeries(RealMatrix recoveredSeries) {
// 			this.recoveredSeries = recoveredSeries;
// 		}
// 		
// 		public double getFrequency() {
// 			return frequency;
// 		}
// 
// 		public void setFrequency(double frequency) {
// 			this.frequency = frequency;
// 		}
// 		
// 	
// 						
// }


// Path: src/main/java/org/tagsys/tagbeat/WebSocketServer.java
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.websocket.api.*;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.tagsys.tagbeat.cr.Signal;
import com.google.gson.Gson;

package org.tagsys.tagbeat;




/**
 * Handler the messages needed to broadcast to browsers.
 * 
 * @author Young
 *
 */
@WebSocket
public class WebSocketServer {

	private static List<Session> sessions = new ArrayList<Session>();
		
	protected static WebSocketServer instance;
	
	public static WebSocketServer getInstance(){
		return instance;
	}
	
	public WebSocketServer(){
		
		instance = this;
		
	}
	
    @OnWebSocketConnect
    public void onConnect(Session session) throws Exception {
    	    	
    	System.out.println("on connect");
    	
    	sessions.add(session);
    		
    }

    @OnWebSocketClose
    public void onClose(Session session, int statusCode, String reason) {
    	    	
        sessions.remove(session);
    }

    @OnWebSocketMessage
    public void onMessage(Session session, String message) {
   	
    	//keep nothing, we don't need receive any message from browser.
  
    }
    
   
    public void broadcast(String epc, Signal signal){