package titan.client;

import neptulon.client.Middleware;
import neptulon.client.ReqCtx;
import titan.client.callbacks.ConnCallbacks;
import titan.client.messages.Message;

/**
 * Incoming messages handler middleware.
 */
public class RecvMsgsMiddleware implements Middleware {
    private final ConnCallbacks cbs;

    public RecvMsgsMiddleware(ConnCallbacks cbs) {
        this.cbs = cbs;
    }

    @Override
    public void middleware(ReqCtx ctx) {
        Message[] msgs = ctx.getParams(Message[].class);
        ctx.next();
        cbs.messagesReceived(msgs);
    }
}

@@ -82,16 +82,49 @@
 ReqCtx;%0A
+import neptulon.client.Response;%0A
 import t
@@ -548,20 +548,18 @@
     
-ctx.next();%0A
+try %7B%0A    
     
@@ -586,20 +586,160 @@
 ived(msgs);%0A
+            //        todo: set ctx.response%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A        ctx.next();%0A
     %7D%0A%7D%0A

set response todo in msg.recv