Examples of JICPPacket


Examples of jade.imtp.leap.JICP.JICPPacket

            droppedToDisconnected();
            requestRefresh();
            throw new ICPException("Connection dropped");
        } else {
            // Normal dispatch
            JICPPacket pkt = new JICPPacket(JICPProtocol.COMMAND_TYPE, JICPProtocol.DEFAULT_INFO, payload);
            pkt = inpManager.dispatch(pkt, flush);
            return pkt.getData();
        }
    }
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

        try {
            // If the INP connection is down or we have some postponed command
            // to flush, refuse dropping the connection
            if (inpManager.isConnected() && inpManager.isEmpty()) {
                JICPPacket rsp = new JICPPacket(JICPProtocol.RESPONSE_TYPE, JICPProtocol.DEFAULT_INFO, null);
                c.writePacket(rsp);

                inpManager.resetConnection();
                outManager.resetConnection();
                connectionDropped = true;
            } else {
                myLogger.log(Logger.WARNING, myID + ": DROP_DOWN request refused.");
                JICPPacket rsp = new JICPPacket(JICPProtocol.ERROR_TYPE, getReconnectInfo(), null);
                c.writePacket(rsp);
            }
        } catch (Exception e) {
            myLogger.log(Logger.WARNING, myID + ": Error writing DROP_DOWN response. " + e);
        }
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

                        long start = System.currentTimeMillis();
                        myConnection.writePacket(pkt);
                        // Asynch-reply: JICPPacket reply = waitForReply(RESPONSE_TIMEOUT);
                        readStartTime = System.currentTimeMillis();
                        JICPPacket reply = myConnection.readPacket();
                        readStartTime = -1;
                        checkTerminatedInfo(reply);
                        lastReceivedTime = System.currentTimeMillis();
                        long end = lastReceivedTime;
                        System.out.println("INP Session " + inpCnt + ". Dispatching time = " + (end - start));

                        if (myLogger.isLoggable(Logger.FINER)) {
                            myLogger.log(Logger.FINER, myID + ": Received response " + inpCnt + " from FE");
                        }
                        if (reply.getType() == JICPProtocol.ERROR_TYPE) {
                            // Communication OK, but there was a JICP error on the peer
                            throw new ICPException(new String(pkt.getData()));
                        }
                        if (!peerActive) {
                            // This is the response to an exit command --> Suicide, without
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

                resetConnection();
            }
        }

        public void sendServerKeepAlive() throws ICPException {
            JICPPacket pkt = new JICPPacket(JICPProtocol.KEEP_ALIVE_TYPE, JICPProtocol.DEFAULT_INFO, null);
            dispatch(pkt, false);
        }
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

            resetConnection();
        }

        final synchronized JICPPacket handleCommand(Connection c, JICPPacket cmd) throws ICPException {
            checkConnection(c);
            JICPPacket reply = null;
            byte sid = cmd.getSessionID();
            if (sid == lastSid) {
                myLogger.log(Logger.WARNING, myID + ": Duplicated command from FE " + sid);
                reply = lastResponse;
            } else {
                if (myLogger.isLoggable(Logger.FINE)) {
                    myLogger.log(Logger.FINE, myID + ": Received command " + sid + " from FE");
                }

                byte[] rspData = mySkel.handleCommand(cmd.getData());
                if (myLogger.isLoggable(Logger.FINER)) {
                    myLogger.log(Logger.FINER, myID + ": Command " + sid + " from FE served ");
                }

                reply = new JICPPacket(JICPProtocol.RESPONSE_TYPE, getReconnectInfo(), rspData);
                reply.setSessionID(sid);
                lastSid = sid;
                lastResponse = reply;
            }
            return reply;
        }
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

        synchronized JICPPacket handleKeepAlive(Connection c, JICPPacket command) throws ICPException {
            checkConnection(c);
            if (myLogger.isLoggable(Logger.FINEST)) {
                myLogger.log(Logger.FINEST, myID + ": Keep-alive received");
            }
            return new JICPPacket(JICPProtocol.RESPONSE_TYPE, getReconnectInfo(), null);
        }
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

        throw new IOException("bytes left in stream after constructing HTTPRequest");
      }
    }
    if (request.getMethod().equals("GET")) {
      String recipientID = request.getField(RECIPIENT_ID_FIELD);
      JICPPacket pkt = new JICPPacket(JICPProtocol.CONNECT_MEDIATOR_TYPE, JICPProtocol.DEFAULT_INFO, recipientID, null);
      ByteBuffer b = ByteBuffer.allocateDirect(pkt.getLength());
      MyOut out = new MyOut(b);
      pkt.writeTo(out);
      b.flip();
      return b;
    } else {
      // Read the JICPPacket from the HTTP request payload
      byte[] a = request.getPayload();
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

      recipientID = recipientID + ":" +port;
    }
   
    if (status == CONNECTED) {
      myLogger.log(Logger.FINEST, "PB-SMSManager sending SMS request to the helper phone. Recipient: "+recipientID);
      JICPPacket pkt = new JICPPacket(JICPProtocol.COMMAND_TYPE, type, recipientID, data);
      try {
        myConnection.writePacket(pkt);
        myLogger.log(Logger.FINEST, "PB-SMSManager: request correctly sent.");
        // We are not expecting any response
      }
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

    HTTPRequest request = new HTTPRequest();
    request.readFrom(is);
    if (request.getMethod().equals("GET")) {
      // This is a CONNECT_MEDIATOR
      String recipientID = request.getField(RECIPIENT_ID_FIELD);
      JICPPacket pkt = new JICPPacket(JICPProtocol.CONNECT_MEDIATOR_TYPE, JICPProtocol.DEFAULT_INFO, recipientID, null);
      return pkt;
    } else {
      // Read the JICPPacket from the HTTP request payload
      ByteArrayInputStream bis = new ByteArrayInputStream(request.getPayload());
      return JICPPacket.readFrom(bis);
View Full Code Here

Examples of jade.imtp.leap.JICP.JICPPacket

        writeAvailable = false;
    }

    public JICPPacket readPacket() throws IOException {
        if (readAvailable) {
            JICPPacket pkt = HTTPHelper.readPacketFromHttp(sc.getInputStream());
            readAvailable = false;
            writeAvailable = true;
            return pkt;
        } else {
            throw new IOException("Read not available");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.