Package com.ngt.jopenmetaverse.shared.sim.events

Examples of com.ngt.jopenmetaverse.shared.sim.events.AutoResetEvent


    int serverPort = 9786;
    startUDPServer(serverPort);

    UDPPacketBuffer[] bufArray = new UDPPacketBuffer[1];
    InetSocketAddress saddress;
    AutoResetEvent onPacketReceive = new AutoResetEvent(false);
    try {
      saddress = new InetSocketAddress(Inet4Address.getByName("127.0.0.1"), serverPort);
      UDPBase udp = createUDPBase(saddress, bufArray, onPacketReceive);
      udp.Start();
      byte[] data = Utils.stringToBytes("This is ping message");

      sendAndReceiveData(udp, saddress, bufArray, data, data.length);
      if(!onPacketReceive.waitOne(5000))
      {
        Assert.fail("No Packet Recieved from UDP Server");
      }
    } catch (Exception e) {
      Assert.fail();
View Full Code Here


    startUDPServer(serverPort);

    UDPPacketBuffer[] bufArray = new UDPPacketBuffer[1];
    InetSocketAddress saddress;
    try {
      AutoResetEvent onPacketReceive = new AutoResetEvent(false);
      saddress = new InetSocketAddress(Inet4Address.getByName("127.0.0.1"), serverPort);
      UDPBase udp = createUDPBase(saddress, bufArray, onPacketReceive);
      udp.Start();

      File[] files = getFileList(fileLocation.getPath());

      for(File f: files)
      {
        JLogger.debug("Reading from File: " + f.getAbsolutePath());
        byte[] data = getFileBytes(f);
        sendAndReceiveData(udp, saddress, bufArray, data, data.length);
        if(!onPacketReceive.waitOne(5000))
        {
          Assert.fail("No Packet Recieved from UDP Server");
        }     
      }
View Full Code Here

  {
    try
    {
      final int max = 3000;
      final int p = 50;
      final AutoResetEvent event = new AutoResetEvent(false);
      DownloadManager downloadManager = new DownloadManager();
      final AtomicInteger noItemsDownloaded = new AtomicInteger(0);
      for(int j =0; j< max/p; j++)
      {
      for(int i = 0; i< p; i++)
      {
        final int itemno = i;
        DownloadRequest request = new DownloadRequest(fileServer.createURI("/files/json/ex1.txt"), 5000,
            "*/*", new MethodDelegate<Void,HttpBaseDownloadProgressArg>()
            {
          public Void execute(HttpBaseDownloadProgressArg e) {
            return null;
          }

            }, new MethodDelegate<Void,HttpBaseRequestCompletedArg>()
            {
              public Void execute(HttpBaseRequestCompletedArg e) {
                if(e.getError() != null)
                {
                  System.out.println(Utils.getExceptionStackTraceAsString(e.getError()));
                  event.set();
                }
                else if(e.getResponseData().length <= 0)
                {
                  event.set();
                }
                Assert.assertNull(e.getError());
                Assert.assertTrue(e.getResponseData().length > 0);
                noItemsDownloaded.incrementAndGet();
                System.out.println("Downloaded item: " + noItemsDownloaded.intValue() + " of size " + e.getResponseData().length);
                if(max <= noItemsDownloaded.intValue())
                  event.set();
                return null;
              }
            });
        downloadManager.QueueDownlad(request);
      }
        PlatformUtils.sleep(500);
      }
      System.out.println("Main Thread is going to sleep...");
      event.waitOne();
    }
    catch(Exception e)
    {Assert.fail(Utils.getExceptionStackTraceAsString(e));}
  }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.sim.events.AutoResetEvent

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.