示例#1
0
 public void Browser_RL_Async_send(String EVentreply, int eventno) {
   int EVcounter;
   for (EVcounter = 0; EVcounter < BrowserGlobals.EVno; EVcounter++) {
     if (BrowserGlobals.EVarray[EVcounter] == eventno) {
       break;
     }
   }
   // System.out.println ("Browser_RL_Async_send sending " + EVentreply + " to number " +
   // EVcounter);
   RL_Async.send(EVentreply, EVcounter);
 }
示例#2
0
  // Associates this instance with the first embedded plugin in the current frame.
  public Browser(Applet pApplet, int portnum) {
    int counter;

    // Create a socket here for an EAI server on localhost
    int incrport = -1;
    EAISocket = null;

    counter = 1;
    while (EAISocket == null) {
      try {
        EAISocket = new Socket("localhost", portnum);
      } catch (IOException e) {
        // wait up to 30 seconds for FreeWRL to answer.
        counter = counter + 1;
        if (counter == 60) {
          System.out.println("EAI: Java code timed out finding FreeWRL");
          System.exit(1);
        }
        try {
          Thread.sleep(500);
        } catch (InterruptedException f) {
        }
      }
    }

    sock = EAISocket; // JAS - these are the same now...

    // ===================================================================
    // create the EAIinThread to Browser.

    // Open the pipe for EAI replies to be sent to us...
    try {
      EAIinThreadtoBrowserPipe = new PipedWriter();
      BrowserfromEAIPipe = new PipedReader(EAIinThreadtoBrowserPipe);
    } catch (IOException ie) {
      System.out.println("EAI: caught error in new PipedReader: " + ie);
    }

    EAIinThreadtoBrowser = new PrintWriter(EAIinThreadtoBrowserPipe);
    BrowserfromEAI = new BufferedReader(BrowserfromEAIPipe);

    // Start the readfrom FREEWRL thread...

    // ===================================================================
    // create the EAIinThread to Browser.

    // Open the pipe for EAI replies to be sent to us...
    try {
      EAIinThreadtoBrowserPipe = new PipedWriter();
      BrowserfromEAIPipe = new PipedReader(EAIinThreadtoBrowserPipe);
    } catch (IOException ie) {
      System.out.println("EAI: caught error in new PipedReader: " + ie);
    }

    EAIinThreadtoBrowser = new PrintWriter(EAIinThreadtoBrowserPipe);
    BrowserfromEAI = new BufferedReader(BrowserfromEAIPipe);

    // Start the readfrom FREEWRL thread...
    FreeWRLThread = new Thread(new EAIinThread(sock, pApplet, EAIinThreadtoBrowser, this));
    FreeWRLThread.start();

    // ====================================================================
    // Start the thread that allows Registered Listenered
    // updates to come in.
    RL_Async = new EAIAsyncThread();
    RL_Async.start();

    // ====================================================================
    // create the EAIoutThread - send data to FreeWRL.
    try {
      EAIout = new PrintWriter(sock.getOutputStream());
    } catch (IOException e) {
      System.out.print("EAI: Problem in handshaking with Browser");
    }

    // Start the SendTo FREEWRL thread...
    EAIoutSender = new EAIoutThread(EAIout);
    EAIoutSender.start();

    // ====================================================================
    // Browser is "gotten", and is started.
    return;
  }