
package com.andreistraut.gaps.controller.dispatchers;

import com.andreistraut.gaps.controller.Controller;
import com.andreistraut.gaps.controller.MessageRequest;
import com.andreistraut.gaps.controller.MessageResponse;
import com.andreistraut.gaps.controller.MessageType;
import java.util.ArrayList;
import javax.websocket.Session;

public abstract class MessageDispatcher {
    protected MessageRequest request;
    protected ArrayList<Object> parameters;
    
     public MessageDispatcher(Controller controller, Session session, MessageType type) {}
     
    /**
     * Validates the MessageRequest given to this class for processing, and sets
     * it as a property if valid
     * 
     * @param request The MessageRequest to process
     * 
     * @return True if request is valid, false otherwise, Exception for malformed
     * request
     * @throws java.lang.Exception
     */
    abstract boolean setRequest(MessageRequest request) throws Exception;
    
    /**
     * If there are additional parameters the class needs to do its job, init them here
     * 
     * @param parameters Additional parameters / preconditions the dispatcher may need 
     * @throws java.lang.Exception 
     */
    abstract void setParameters(ArrayList<Object> parameters) throws Exception;
    abstract boolean process() throws Exception;
    abstract void updateProgress(MessageResponse response);
}

@@ -1,9 +1,8 @@
-%0A
 package 
@@ -369,16 +369,17 @@
 tcher %7B%0A
+%0A
     prot
@@ -456,18 +456,55 @@
 rs;%0A    
+protected boolean sendUpdates = true;%0A
 %0A
- 
     publ
@@ -587,15 +587,391 @@
 e) %7B
-%7D%0A     
+%0A    %7D%0A%0A    /**%0A     * Enable or disable communications from server. Setting this parameter to False%0A     * will cause the server to go silent. Introduced mainly to help with testing%0A     * %0A     * @param sendUpdates True to enable communication from server, false otherwise%0A     */%0A    public void setSendUpdates(boolean sendUpdates) %7B%0A        this.sendUpdates = sendUpdates;%0A    %7D%0A
 %0A   
@@ -1091,25 +1091,24 @@
 valid%0A     *
- 
 %0A     * @par
@@ -1150,25 +1150,24 @@
 ocess%0A     *
- 
 %0A     * @ret
@@ -1226,16 +1226,23 @@
 tion for
+%0A     *
  malform
@@ -1243,23 +1243,16 @@
 alformed
-%0A     *
  request
@@ -1373,13 +1373,9 @@
 on;%0A
-    
 %0A
+
     
@@ -1455,16 +1455,30 @@
 ob, init
+ializes%0A     *
  them he
@@ -1482,25 +1482,24 @@
  here%0A     *
- 
 %0A     * @par
@@ -1564,16 +1564,23 @@
 spatcher
+%0A     *
  may nee
@@ -1580,17 +1580,16 @@
 may need
- 
 %0A     * 
@@ -1615,17 +1615,16 @@
 xception
- 
 %0A     */
@@ -1696,32 +1696,33 @@
 rows Exception;%0A
+%0A
     abstract boo
@@ -1754,16 +1754,17 @@
 eption;%0A
+%0A
     abst

Allow possibility to turn off server communication (for testing purposes mostly)