Package org.eclipse.php.debug.core.debugger.messages

Examples of org.eclipse.php.debug.core.debugger.messages.IDebugRequestMessage


  public Object sendRequest(Object request) throws Exception {
    if (PHPDebugPlugin.DEBUG) {
      System.out.println("Sending syncrhonic request: " + request); //$NON-NLS-1$
    }
    try {
      IDebugRequestMessage theMsg = (IDebugRequestMessage) request;
      synchronized (byteArrayOutputStream) {
        byteArrayOutputStream.reset();
        theMsg.setID(lastRequestID++);
        theMsg.serialize(dataOutputStream);

        int messageSize = byteArrayOutputStream.size();
        synchronized (connectionOut) {
          requestsTable.put(theMsg.getID(), theMsg);
          connectionOut.writeInt(messageSize);
          byteArrayOutputStream.writeTo(connectionOut);
          connectionOut.flush();
        }
      }

      IDebugResponseMessage response = null;
      int timeoutTick = 500; // 0.5 of second
      int waitedTime = 0;
      while (response == null && isConnected()) {
        synchronized (request) {
          response = (IDebugResponseMessage) responseTable
              .remove(theMsg.getID());
          if (response == null) {
            if (PHPDebugPlugin.DEBUG) {
              System.out
                  .println("Response is null. Waiting " + waitedTime + " milliseconds"); //$NON-NLS-1$ //$NON-NLS-2$
            }
            if (waitedTime > debugResponseTimeout / 4) { // Display
                                    // a
                                    // progress
                                    // dialog
                                    // after
                                    // a
                                    // quarter
                                    // of
                                    // the
                                    // assigned
                                    // time
                                    // have
                                    // passed.
              // Display a message that we are waiting for the
              // server response.
              // In case that the response finally arrives, remove
              // the message.
              // In case we have a timeout, close the connection
              // and display a different message.
              PHPLaunchUtilities.showWaitForDebuggerMessage(this);
            }
            request.wait(timeoutTick);
          }
        }
        if (response == null) {
          response = (IDebugResponseMessage) responseTable
              .remove(theMsg.getID());
        }

        // if the response is null. it means that there is no answer
        // from the server.
        // This can be because on the peerResponseTimeout.
View Full Code Here


  public void sendRequest(Object request, ResponseHandler responseHandler) {
    if (PHPDebugPlugin.DEBUG) {
      System.out.println("Sending asynchronic request: " + request); //$NON-NLS-1$
    }
    int msgId = lastRequestID++;
    IDebugRequestMessage theMsg = (IDebugRequestMessage) request;
    try {
      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      DataOutputStream dataOutputStream = new DataOutputStream(
          byteArrayOutputStream);
      theMsg.setID(msgId);
      theMsg.serialize(dataOutputStream);

      int messageSize = byteArrayOutputStream.size();
      synchronized (connectionOut) {
        requestsTable.put(msgId, request);
        responseHandlers.put(Integer.valueOf(msgId), responseHandler);
        connectionOut.writeInt(messageSize);
        byteArrayOutputStream.writeTo(connectionOut);
        connectionOut.flush();
      }
    } catch (Exception exc) { // Return null for any exception
      System.out
          .println("Exception for request no." + theMsg.getType() + exc.toString()); //$NON-NLS-1$
      responseHandler.handleResponse(request, null);
      responseHandlers.remove(Integer.valueOf(msgId));
    }
  }
View Full Code Here

      stopImmediately(true);

      synchronized (requestsTable) {
        Iterator i = requestsTable.values().iterator();
        while (i.hasNext()) {
          IDebugRequestMessage r = (IDebugRequestMessage) i.next();
          synchronized (r) {
            r.notifyAll();
          }
        }
      }

      requestsTable.clear();
View Full Code Here

                  IDebugResponseMessage r = (IDebugResponseMessage) newInputMessage;
                  int requestId = r.getID(); // take the
                                // request ID
                                // from the
                                // response.
                  IDebugRequestMessage req = (IDebugRequestMessage) requestsTable
                      .remove(requestId); // find the
                                // request.
                  ResponseHandler handler = responseHandlers
                      .remove(Integer.valueOf(requestId)); // find
                                        // the
View Full Code Here

              // WAITING FOR THE REQUEST
              ResponseHandler handler = responseHandlers
                  .get(Integer.valueOf(idd)); // find the handler.
              if (handler == null) {
                responseTable.put(/* requestId */idd, message);
                IDebugRequestMessage req = (IDebugRequestMessage) requestsTable
                    .remove(idd); // find the request.
                if (req != null) {
                  synchronized (req) {
                    req.notifyAll(); // Notify the response
                              // is here.
                  }
                } else {
                  // Remove this message.
                  responseTable.remove(idd);
View Full Code Here

TOP

Related Classes of org.eclipse.php.debug.core.debugger.messages.IDebugRequestMessage

Copyright © 2018 www.massapicom. 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.