Package org.eclipse.ecf.core.util

Examples of org.eclipse.ecf.core.util.ECFException


  public Object connect(ID remote, Object data, int timeout) throws ECFException {
    try {
      trace("connect(" + remote + "," + data + "," + timeout + ")");
      if (socket != null) {
        throw new ECFException("Already connected to " + getURL(null));
      }

      final URL url = new URL(remote.getName());
      /*
       * // Get socket factory and create/connect socket SocketFactory fact =
       * SocketFactory.getSocketFactory(); if(fact == null) { fact =
       * SocketFactory.getDefaultSocketFactory(); }
       */

      final int port = url.getPort() != -1 ? url.getPort() : DEFAULT_PORT;
      // socket = fact.createSocket(url.getHost(), port, timeout);
      socket = new Socket(url.getHost(), port);
    } catch (final IOException e) {
      throw new ECFException(e);
    }

    return null;
  }
View Full Code Here


    Assert.isNotNull(container);
    Assert.isNotNull(roomInfo);
    // Check to make sure given container is connected.
    ID connectedID = container.getConnectedID();
    if (connectedID == null)
      throw new ECFException(Messages.MultiRosterView_EXCEPTION_JOIN_ROOM_NOT_CONNECTED);
    // Check to make sure that the given container is one that we have in
    // our accounts set
    if (findAccountForContainer(container) == null)
      throw new ECFException(Messages.MultiRosterView_EXCEPTION_JOIN_ROOM_INVALID_ACCOUNT);

    IWorkbenchWindow ww = getViewSite().getPage().getWorkbenchWindow();
    IWorkbenchPage wp = ww.getActivePage();
    // Get existing roomView...if it's there
    RoomWithAView roomView = (RoomWithAView) chatRooms.get(connectedID);
    if (roomView != null) {
      // We've already connected to this room, so just show it.
      ChatRoomManagerView chatroommanagerview = roomView.getView();
      wp.activate(chatroommanagerview);
      chatroommanagerview.joinRoom(roomInfo, password);
      return;
    }
    try {
      IViewReference ref = wp.findViewReference(org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView.VIEW_ID, connectedID.getName());
      // Open view for given connectedID (secondaryID)
      final ChatRoomManagerView chatroommanagerview = (ChatRoomManagerView) ((ref == null) ? wp.showView(org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView.VIEW_ID, connectedID.getName(), IWorkbenchPage.VIEW_ACTIVATE) : ref.getView(true));
      // initialize new view
      chatroommanagerview.initializeWithoutManager(ChatRoomManagerView.getUsernameFromID(connectedID), ChatRoomManagerView.getHostnameFromID(connectedID), createChatRoomCommandListener(), createChatRoomViewCloseListener(connectedID));
      // join room
      chatroommanagerview.joinRoom(roomInfo, password);

      roomView = new RoomWithAView(chatroommanagerview, connectedID);
      chatRooms.put(roomView.getID(), roomView);
    } catch (Exception e1) {
      throw new ECFException(e1);
    }

  }
View Full Code Here

    sendChatMessage(toID, body);
  }

  public void sendChatMessage(ID toID, String body) throws ECFException {
    if (toID == null) {
      throw new ECFException(
          Messages.IRCRootContainer_EXCEPTION_TARGETID_CANNOT_BE_NULL);
    }

    // FIXME: temporary workaround to allow for the sending of messages to
    // users that are operators
View Full Code Here

      IChatRoomManager manager = (IChatRoomManager) container
          .getAdapter(IChatRoomManager.class);

      if (manager == null)
        throw new ECFException("No chat room manager available"); //$NON-NLS-1$

      firePreConnect();

      String password = bot.getPassword();
      IConnectContext context = (password == null) ? null
View Full Code Here

    try {
      // open a server socket
      serverSocketChannel = ServerSocketChannel.open();
      serverSocketChannel.configureBlocking(false);
    } catch (IOException e) {
      throw new ECFException(new Status(IStatus.ERROR, Util.PLUGIN_ID,
          "Could not create server socket", e)); //$NON-NLS-1$
    }

    try {
      // bind to a local port
      ServerSocket socket = serverSocketChannel.socket();
      socket.bind(getBindAddress(), getBackLog());
    } catch (IOException e) {
      throw new ECFException(new Status(IStatus.ERROR, Util.PLUGIN_ID,
          "Could not bind server socket", e)); //$NON-NLS-1$
    }

    localPort = serverSocketChannel.socket().getLocalPort();
View Full Code Here

   * @see NIODatashareContainer#enqueue(SocketAddress)
   */
  protected abstract void sendRequest(ID receiver) throws ECFException;

  public void sendMessage(byte[] message) throws ECFException {
    throw new ECFException(new Status(IStatus.ERROR, Util.PLUGIN_ID,"A receiver must be specified, see sendMessage(ID, byte[])"));
  }
View Full Code Here

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(data);
        return baos.toByteArray();
      } catch (IOException e) {
        throw new ECFException(e);
      }
    }
View Full Code Here

  }

  public Object callSync(IRemoteCall call) throws ECFException {
    IRemoteCallable callable = getRegistration().lookupCallable(call);
    if (callable == null)
      throw new ECFException("Callable not found for call=" + call); //$NON-NLS-1$
    return invokeRemoteCall(call, callable);
  }
View Full Code Here

  }

  public void fireAsync(IRemoteCall call) throws ECFException {
    IRemoteCallable callable = getRegistration().lookupCallable(call);
    if (callable == null)
      throw new ECFException("Remote callable not found"); //$NON-NLS-1$
    callAsync(call, callable);
  }
View Full Code Here

  protected Object invokeSync(IRemoteCall remoteCall) throws ECFException {
    // Now lookup callable
    IRemoteCallable callable = getRegistration().lookupCallable(remoteCall);
    // If not found...we're finished
    if (callable == null)
      throw new ECFException("Callable not found for call=" + remoteCall); //$NON-NLS-1$
    return invokeRemoteCall(remoteCall, callable);

  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.core.util.ECFException

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.