Package com.opera.core.systems.scope.exceptions

Examples of com.opera.core.systems.scope.exceptions.CommunicationException


      sleep(sleepDuration);
      recover();
      return eval(using, variables);
    } else if (retries >= SCRIPT_RETRIES) {
      resetCounters();
      throw new CommunicationException("No response on ECMAScript evaluation command");
    }

    resetCounters();
    return parseEvalData(response);
  }
View Full Code Here


    Response response = executeMessage(ScopeMessage.HOST_INFO, null);

    try {
      return HostInfo.parseFrom(response.getPayload());
    } catch (InvalidProtocolBufferException e) {
      throw new CommunicationException("Error while parsing host info", e);
    }
  }
View Full Code Here

  }

  private void internalWait(long timeout) {
    try {
      if (!connected) {
        throw new CommunicationException("Waiting aborted - not connected!");
      }
      lock.wait(timeout);
    } catch (InterruptedException e) {
      throw new ScopeException(e);
    }
View Full Code Here

          case RESPONSE:
            if (result.data == match && type == ResponseType.RESPONSE) {
              return result;
            } else if (type == ResponseType.HANDSHAKE) {
              throw new CommunicationException("Expected handshake, got response");
            }
            break;

          case ERROR:
            if (result.data == match && type == ResponseType.RESPONSE) {
              return null;
            } else if (type == ResponseType.HANDSHAKE) {
              throw new CommunicationException("Expected handshake, got error");
            }
            break;

          case EXCEPTION:
            Throwables.propagate(result.getException());
            break;

          case DISCONNECTED:
            throw new CommunicationException(String.format("Problem encountered: %s", waitResult));

          case EVENT_WINDOW_LOADED:
            if (result.data == match && type == ResponseType.WINDOW_LOADED) {
              return null;
            }
            break;

          case EVENT_WINDOW_CLOSED:
            if (result.data == match && type == ResponseType.WINDOW_LOADED) {
              throw new CommunicationException("Window closed unexpectedly");
            }
            break;

          case EVENT_DESKTOP_WINDOW_SHOWN:
            if (type == ResponseType.DESKTOP_WINDOW_SHOWN) {
View Full Code Here

          bytesWeHaveBeenReading = 6; // 6 bytes will be removed from buffer
          String handShake = new String(dst);
          if (!handShake.equals("STP/1\n")) {
            close();
            connectionHandler.onException(
                new CommunicationException("Expected STP/1, got: " + handShake));
          }
          setState(State.EMPTY);
          connectionHandler.onHandshake(true);
        }
        break;

      case EMPTY: // read 4 byte header: STP/0
        if (buffer.limit() >= 4) {
          byte[] headerPrefix = new byte[4];
          buffer.get(headerPrefix);
          buffer.position(0);
          bytesWeHaveBeenReading = 4;
          ByteString incomingPrefix = ByteString.copyFrom(headerPrefix);
          if (stpPrefix.equals(incomingPrefix)) {
            setState(State.STP);
            /*
            if(buffer.hasRemaining()){
                buffer.compact();
                readMessage(buffer, buffer.position(), true);
            } else {
                buffer.clear();
            }
            */
          } else {
            close();
            connectionHandler.onException(
                new CommunicationException("Expected empty header"));
          }
        }
        break;

      case STP:
        // Try to read size
        buffer.position(0);
        if (buffer.limit() <= 0) {
          logger.finest("STP: Empty buffer");
          break;
        }
        int messageSize = readRawVarint32(buffer);// read part of buffer
        bytesWeHaveBeenReading = buffer.position();
        buffer.position(0);

        // If we got size, read more, if not just leave it!
        if (buffer.limit() >= bytesWeHaveBeenReading + messageSize) {
          buffer.position(bytesWeHaveBeenReading);

          // Read type and Payload!
          int messageType = buffer.get();
          bytesWeHaveBeenReading += 1;

          byte[] payload = new byte[--messageSize];
          buffer.get(payload);
          buffer.position(0);

          bytesWeHaveBeenReading += messageSize; // 32 bits = 4 bytes :-)

          setState(State.EMPTY);

          try {
            processMessage(messageType, payload);
          } catch (IOException e) {
            close();
            connectionHandler.onException(new CommunicationException(
                "Error while processing the message: " + e.getMessage()));
          }
        } else {
          // 4 + messageSize because of the int at the beginning
          logger.finest(String.format("Tried to read a message and expected %d bytes, but got %d",
View Full Code Here

            (service.equals("desktop-utils") && error.getCommandID() == DesktopUtilsMessage
                .GET_STRING.getID())) {
          signalResponse(error.getTag(), null);
        } else {
          connectionHandler.onException(
              new CommunicationException(String.format("Error on command: %s", error)));
        }

        break;

      default:
        connectionHandler.onException(new CommunicationException(
            String.format("Unhandled STP type: %d", stpType)));
    }
  }
View Full Code Here

      sleep(sleepDuration);
      recover();
      return eval(using, variables);
    } else if (retries >= SCRIPT_RETRIES) {
      resetCounters();
      throw new CommunicationException("No response on ECMAScript evaluation command");
    }

    resetCounters();
    return response;
  }
View Full Code Here

   * After this call, messages to the driver about window events are not thrown away, so that the
   * notification about window shown is not lost because of other events or messages
   */
  public void waitStart() {
    if (getScopeServices().getConnection() == null) {
      throw new CommunicationException(
          "waiting for a window failed because Opera is not connected.");
    }

    getScopeServices().waitStart();
  }
View Full Code Here

   * @param windowName - window to wait for shown event on
   * @return id of window
   */
  public int waitForWindowShown(String windowName) {
    if (getScopeServices().getConnection() == null) {
      throw new CommunicationException(
          "waiting for a window failed because Opera is not connected.");
    }

    return getScopeServices()
        .waitForDesktopWindowShown(windowName, OperaIntervals.WINDOW_EVENT_TIMEOUT.getMs());
View Full Code Here

   * @param windowName - window to wait for shown event on
   * @return id of window
   */
  public int waitForWindowUpdated(String windowName) {
    if (getScopeServices().getConnection() == null) {
      throw new CommunicationException(
          "waiting for a window failed because Opera is not connected.");
    }

    return getScopeServices().waitForDesktopWindowUpdated(windowName,
                                                          OperaIntervals.WINDOW_EVENT_TIMEOUT
View Full Code Here

TOP

Related Classes of com.opera.core.systems.scope.exceptions.CommunicationException

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.