Package com.myjavatools.web

Examples of com.myjavatools.web.ClientHttpRequest


      notifyNetworkStreamListener(ExitCode.DESKSHARE_SERVICE_UNAVAILABLE);
    }
  }

  private void sendCaptureStartEvent(Dimension screen, Dimension block) throws ConnectionException {
    ClientHttpRequest chr;
    try {
      chr = new ClientHttpRequest(conn);
      chr.setParameter(ROOM, room);     
      chr.setParameter(SEQ_NUM, seqNumGenerator.getNext());
      String screenInfo = Integer.toString(screen.getWidth()) + "x" + Integer.toString(screen.getHeight());
      chr.setParameter(SCREEN, screenInfo);     
      String blockInfo = Integer.toString(block.getWidth()) + "x" + Integer.toString(block.getHeight());
      chr.setParameter(BLOCK, blockInfo);
      chr.setParameter(EVENT, CaptureEvents.CAPTURE_START.getEvent());
      chr.setParameter(USE_SVC2, Boolean.toString(useSVC2));
      chr.post();
    } catch (IOException e) {
      e.printStackTrace();
      throw new ConnectionException("IOException while sending capture start event.");
    }
View Full Code Here


      processBlocks = false;
    }
  }

  private void sendCaptureEndEvent() throws ConnectionException {
    ClientHttpRequest chr;
    try {
      chr = new ClientHttpRequest(conn);
      chr.setParameter(ROOM, room);
      chr.setParameter(SEQ_NUM, seqNumGenerator.getNext());
      chr.setParameter(EVENT, CaptureEvents.CAPTURE_END.getEvent());
      chr.post();
    } catch (IOException e) {
      e.printStackTrace();
      throw new ConnectionException("IOException while sending capture end event.");
    }
  }
View Full Code Here

      long encStart = 0;
      long encEnd = 0;
      int totalBytes = 0;
      long totalMillis = 0;

      ClientHttpRequest chr;

      try {

        // Open a connection to the web server and create a request that has
        // the room and event type.
        System.out.println(getTimeStamp() + " Http[" + id + "] Open connection. In sendBlockData");
        openConnection();
        chr = new ClientHttpRequest(conn);
        chr.setParameter(ROOM, room);
        chr.setParameter(EVENT, CaptureEvents.CAPTURE_UPDATE.getEvent());

        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // For each changed block, append an uploaded-file entry to the form data.
        // The file name contains the block info.  The file name has this format:
        // "blockgroup_<seqnum>_<position>".  The original filename is just set to
        // "block<i>".
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        for (int i = 0; i < changedBlocks.length; i++)
        { // append each changed-block to the form

          EncodedBlockData block = retriever.getBlockToSend((Integer) changedBlocks[i]);
          String changed_blocks_upload_filename =
                  BLOCKGROUP + "_" + seqNumGenerator.getNext() + "_" + block.getPosition();
         
          chr.setParameter(changed_blocks_upload_filename, "block"+i, new ByteArrayInputStream(block.getVideoData()));

        } // append each changed-block to the form

        // Post the multi-part form to the server
        chr.post();
        HttpURLConnection httpConnection = (HttpURLConnection) chr.connection;
        int status = httpConnection.getResponseCode();
       
        System.out.println("******* POST status = [" + status + "] ***************");
       
View Full Code Here

      }               
    }
  }
 
  private void sendCursor(Point mouseLoc, String room) {
    ClientHttpRequest chr;
    try {
      System.out.println("Http[" + id + "] Open connection. In sendCursor");
      openConnection();
      chr = new ClientHttpRequest(conn);
      chr.setParameter(ROOM, room);
      chr.setParameter(SEQ_NUM, seqNumGenerator.getNext());
      chr.setParameter(EVENT, CaptureEvents.MOUSE_LOCATION_EVENT.getEvent());
      chr.setParameter(MOUSEX, mouseLoc.x);
      chr.setParameter(MOUSEY, mouseLoc.y);
      chr.post();   
      } catch (IOException e) {
        e.printStackTrace();
      } catch (ConnectionException e) {
        System.out.println("ERROR: Failed to send block data.");
      }
View Full Code Here

    return strDate;
        }
 
  private void sendBlockData(BlockVideoData blockData) {
    long start = System.currentTimeMillis();
      ClientHttpRequest chr;
    try {
      System.out.println(getTimeStamp()+ " Http[" + id + "] Open connection. In sendBlockData");
      openConnection();
      chr = new ClientHttpRequest(conn);
        chr.setParameter(ROOM, blockData.getRoom());
        chr.setParameter(SEQ_NUM, seqNumGenerator.getNext());
        chr.setParameter(POSITION, blockData.getPosition());
        chr.setParameter(KEYFRAME, blockData.isKeyFrame());
        chr.setParameter(EVENT, CaptureEvents.CAPTURE_UPDATE.getEvent());
      ByteArrayInputStream block = new ByteArrayInputStream(blockData.getVideoData());       
      chr.setParameter(BLOCKDATA, "block", block);
      chr.post();
               //         try {
               //         Thread.sleep(1000);
               //         }
               //         catch (InterruptedException e)
               //         { }
View Full Code Here

      throw new ConnectionException("IOException while connecting to " + url.toString());
    }
  }
 
  private void sendCaptureStartEvent() throws ConnectionException {
    ClientHttpRequest chr;
    try {
      chr = new ClientHttpRequest(conn);
      chr.setParameter("room", room);
     
      videoInfo = Integer.toString(videoWidth)
                + "x" + Integer.toString(videoHeight);
      //          + "x" + Integer.toString(frameRate);
      //StringBuilder sb = new StringBuilder(videoWidth);
      //sb.append("x").append(videoHeight);

      chr.setParameter("videoInfo", videoInfo);
      chr.setParameter("event", CaptureEvents.CAPTURE_START.getEvent());
      chr.post();
    } catch (IOException e) {
      e.printStackTrace();
      throw new ConnectionException("IOException while sending capture start event.");
    }
View Full Code Here

    openConnection();
    sendCaptureEndEvent();
  }

  private void sendCaptureEndEvent() throws ConnectionException {
    ClientHttpRequest chr;
    try {
      chr = new ClientHttpRequest(conn);
      chr.setParameter("room", room);
     
      chr.setParameter("event", CaptureEvents.CAPTURE_END.getEvent());
      chr.post();
    } catch (IOException e) {
      e.printStackTrace();
      throw new ConnectionException("IOException while sending capture end event.");
    }
  }
View Full Code Here

    long completeTime = System.currentTimeMillis();
    System.out.println("Sending took " + (completeTime - snapshotTime) + "ms.");
  }
 
  private void sendVideoData(ByteArrayOutputStream videoData, boolean isKeyFrame) throws ConnectionException {
      ClientHttpRequest chr;
    try {
      chr = new ClientHttpRequest(conn);
        chr.setParameter("room", room);
       
        chr.setParameter("event", CaptureEvents.CAPTURE_UPDATE.getEvent());
        chr.setParameter("keyframe", isKeyFrame);
       
      ByteArrayInputStream cap = new ByteArrayInputStream(videoData.toByteArray());
       
      chr.setParameter("videodata", "screen", cap);
      System.out.println("Video data length = " + videoData.toByteArray().length);
     
      chr.post();   
    } catch (IOException e) {
      e.printStackTrace();
      throw new ConnectionException("IOException while sending video data.");
    }
View Full Code Here

TOP

Related Classes of com.myjavatools.web.ClientHttpRequest

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.