Examples of OSDArray


Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

    {
      for (int i = 0; i < WhiteList.length; i++)
        wl.add(OSD.FromString(WhiteList[i]));
    }

    map.put("whitelist", new OSDArray(wl));
    map.put("whitelist_enable", OSD.FromBoolean(EnableWhiteList));
    map.put("width_pixels", OSD.FromInteger(Width));

    return map;
  }
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

    m.ControlPermissions = MediaPermission.get((byte)(map.get("perms_control").asInteger()));
    m.InteractPermissions = MediaPermission.get((byte)map.get("perms_interact").asInteger());

    if (map.get("whitelist").getType() == OSDType.Array)
    {
      OSDArray wl = (OSDArray)map.get("whitelist");
      if (wl.count() > 0)
      {
        m.WhiteList = new String[wl.count()];
        for (int i = 0; i < wl.count(); i++)
        {
          m.WhiteList[i] = wl.get(i).asString();
        }
      }
    }

    m.EnableWhiteList = map.get("whitelist_enable").asBoolean();
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

                     
                      rootElement.appendChild(newChild);
                     
                      break;
                  case Array:
                      OSDArray array = (OSDArray)data;
                     
//                      writer.WriteStartElement("", "array", "");
//                      for (int i = 0; i < array.Count; i++)
//                      {
//                          SerializeLLSDXmlElement(writer, array[i]);
//                      }
//                      writer.WriteEndElement();
                     
                      newChild = doc.createElement("array");
                      for (int i = 0; i < array.count(); i++)
                      {
                          SerializeLLSDXmlElement(doc, newChild, array.get(i));
                      }
                      rootElement.appendChild(newChild);
                      break;
              }
          }
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

    if (reader.getNodeType() != Node.ELEMENT_NODE|| !reader.getNodeName().equals("array"))
      throw new OSDException("Expected <array>");

    //System.out.println("Parsing Array...");
   
    OSDArray array = new OSDArray();

    if (!reader.hasChildNodes())
    {
      return array;
    }

    NodeList nodeList = reader.getChildNodes();
   
    for(int i = 0; i < nodeList.getLength(); i++)
    {
      if(nodeList.item(i).getNodeType() == Node.ELEMENT_NODE)
      {
        array.add(ParseLLSDXmlElement(nodeList.item(i)));
      }
    }
    return array;
  }       
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

        private static OSD ParseLLSDBinaryArray(InputStream stream) throws OSDException, IOException
        {
            int numElements = NetworkToHostInt(ConsumeBytes(stream, int32Length));
            int crrElement = 0;
            OSDArray osdArray = new OSDArray();
            while (crrElement < numElements)
            {
                osdArray.add(ParseLLSDBinaryElement(stream));
                crrElement++;
            }

            if (!FindByte(stream, arrayEndBinaryMarker))
                throw new OSDException("Binary LLSD parsing: Missing end marker in array.");
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

  void requestCompletedHandler(HttpRequestBase request, HttpResponse response, byte[] responseData, Exception error)
  {
    // We don't care about this request now that it has completed
    _Request = null;

    OSDArray events = null;
    int ack = 0;

    if (responseData != null)
    {
      _errorCount = 0;
      // Got a response
      OSDMap result = (OSDMap)XmlLLSDOSDParser.DeserializeLLSDXml(responseData);

      if (result != null)
      {
        events = (OSDArray)result.get("events");
        ack = result.get("id").asInteger();
      }
      else
      {
       
        try {
          logger.warning("Got an unparseable response from the event queue: \"" +
              Utils.bytesToString(responseData) + "\"");
        } catch (UnsupportedEncodingException e) {
          logger.warning("Got an unparseable response from the event queue: \"" +
              Utils.getExceptionStackTraceAsString(e) + "\"");
        }
      }
    }
    else if (error != null)
    {
      //TODO Handle the case when the request is aborted or there is some client side error

      if(response !=null)
      {
      //region Error handling
      int code = response.getStatusLine().getStatusCode();

      if(code == HttpStatus.SC_GONE || code == HttpStatus.SC_NOT_FOUND)
      {
        logger.info(String.format("Closing event queue at {0} due to missing caps URI", _Address));
        _Running = false;
        _Dead = true;       
      }
      else if(code == HttpStatus.SC_BAD_GATEWAY)
      {
        // This is not good (server) protocol design, but it's normal.
        // The EventQueue server is a proxy that connects to a Squid
        // cache which will time out periodically. The EventQueue server
        // interprets this as a generic error and returns a 502 to us
        // that we ignore
      }
      else
      {
        ++_errorCount;       
        // Try to log a meaningful error message
        if (code != HttpStatus.SC_OK)
        {
          logger.warning(String.format("Unrecognized caps connection problem from %s: %s",
              _Address, code));
        }
        else
        {
          logger.warning(String.format("Unrecognized caps exception from %s: %s",
              _Address, error.getMessage()));
        }       
      }
      }
      else
      {
        ++_errorCount;
        logger.warning("Some client Side Error" + Utils.getExceptionStackTraceAsString(error));
      }
    }
    else
    {
      ++_errorCount;
      logger.warning("No response from the event queue but no reported error either");
   

    //      if (error instanceof HttpException)
    //      {
    //        HttpException webException = (HttpException)error;
    //
    //        if (response != null)
    //          code = response.getStatusLine().getStatusCode();
    //        else if (webException.Status == WebExceptionStatus.RequestCanceled)
    //          goto HandlingDone;
    //      }
    //
    //      if (error is WebException && ((WebException)error).Response != null)
    //        code = ((HttpWebResponse)((WebException)error).Response).StatusCode;
    //
    //      if (code == HttpStatusCode.NotFound || code == HttpStatusCode.Gone)
    //      {
    //        Logger.Log(String.format("Closing event queue at {0} due to missing caps URI", _Address), Helpers.LogLevel.Info);
    //
    //        _Running = false;
    //        _Dead = true;
    //      }
    //      else if (code == HttpStatusCode.BadGateway)
    //      {
    //        // This is not good (server) protocol design, but it's normal.
    //        // The EventQueue server is a proxy that connects to a Squid
    //        // cache which will time out periodically. The EventQueue server
    //        // interprets this as a generic error and returns a 502 to us
    //        // that we ignore
    //      }
    //      else
    //      {
    //        ++_errorCount;
    //
    //        // Try to log a meaningful error message
    //        if (code != HttpStatusCode.OK)
    //        {
    //          Logger.Log(String.format("Unrecognized caps connection problem from {0}: {1}",
    //              _Address, code), Helpers.LogLevel.Warning);
    //        }
    //        else if (error.InnerException != null)
    //        {
    //          Logger.Log(String.Format("Unrecognized internal caps exception from {0}: {1}",
    //              _Address, error.InnerException.Message), Helpers.LogLevel.Warning);
    //        }
    //        else
    //        {
    //          Logger.Log(String.Format("Unrecognized caps exception from {0}: {1}",
    //              _Address, error.Message), Helpers.LogLevel.Warning);
    //        }
    //      }
    //
    //      //endregion Error handling
    //    }
    //    else
    //    {
    //      ++_errorCount;
    //
    //      Logger.Log("No response from the event queue but no reported error either", Helpers.LogLevel.Warning);
    //    }
    //
    //    HandlingDone:
    //
    //      //region Resume the connection
    //
    //      if (_Running)
    //      {
    //        OSDMap osdRequest = new OSDMap();
    //        if (ack != 0) osdRequest["ack"] = OSD.FromInteger(ack);
    //        else osdRequest["ack"] = new OSD();
    //        osdRequest["done"] = OSD.FromBoolean(_Dead);
    //
    //        byte[] postData = OSDParser.SerializeLLSDXmlBytes(osdRequest);
    //
    //        if (_errorCount > 0) // Exponentially back off, so we don't hammer the CPU
    //          Thread.Sleep(_random.Next(500 + (int)Math.Pow(2, _errorCount)));
    //
    //        // Resume the connection. The event handler for the connection opening
    //        // just sets class _Request variable to the current HttpRequest
    //        CapsBase.UploadDataAsync(_Address, null, "application/xml", postData, REQUEST_TIMEOUT,
    //            delegate(HttpRequest newRequest) { _Request = newRequest; }, null, RequestCompletedHandler);
    //
    //        // If the event queue is dead at this point, turn it off since
    //        // that was the last thing we want to do
    //        if (_Dead)
    //        {
    //          _Running = false;
    //          Logger.DebugLog("Sent event queue shutdown message");
    //        }
    //      }
    //
    //    //endregion Resume the connection
    //
    //    //region Handle incoming events
    //
    //    if (OnEvent != null && events != null && events.Count > 0)
    //    {
    //      // Fire callbacks for each event received
    //      foreach (OSDMap evt in events)
    //      {
    //        string msg = evt["message"].AsString();
    //        OSDMap body = (OSDMap)evt["body"];
    //
    //        try { OnEvent(msg, body); }
    //        catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); }
    //      }
    //    }
    //
    ////    endregion Handle incoming events
   
   
     //region Handle incoming events
         if (eventObservable != null && events != null && events.count() > 0)
         {
             //Fire callbacks for each event received
           Iterator<OSD> itr = events.iterator();
             while(itr.hasNext())
             {
               OSDMap evt = (OSDMap)itr.next();
                 String msg = evt.get("message").asString();
                 OSDMap body = (OSDMap)evt.get("body");
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

      }     
      doc.endObject();
     
      break;
    case Array:
      OSDArray array = (OSDArray)data;
     
      doc.beginArray();
      for (int i = 0; i < array.count(); i++)
      {
        SerializeLLSDJsonElement(doc, array.get(i));
      }
     
      doc.endArray();
     
      break;
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

  private static OSDArray ParseLLSDJsonArray(JsonArray jarray) throws OSDException, URISyntaxException
  {
    //System.out.println("Parsing Array...");

    OSDArray array = new OSDArray();

    for(int i = 0; i < jarray.size(); i++)
    {
      array.add(ParseLLSDJsonElement(jarray.get(i)));
    }
    return array;
  }       
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

         private static OSD DeserializeLLSDNotationArray(StringReader reader) throws OSDException, IOException
         {
//           System.out.println("Deserializing Array...");
             int character;
             OSDArray osdArray = new OSDArray();
             while (((character = PeekAndSkipWhitespace(reader)) > 0) &&
                   ((char)character != arrayEndNotationMarker))
             {
//               System.out.print((char)character);
                 osdArray.add(DeserializeLLSDNotationElement(reader));

                 character = ReadAndSkipWhitespace(reader);
//               System.out.print((char)character);
                 if (character < 0)
                     throw new OSDException("Notation LLSD parsing: Unexpected end of array discovered.");
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDArray

    @Override
    public OSDMap Serialize()
    {
      OSDMap map = new OSDMap(1);

      OSDArray eventsArray = new OSDArray();

      for (int i = 0; i < MessageEvents.length; i++)
      {
        OSDMap eventMap = new OSDMap(2);
        eventMap.put("body", MessageEvents[i].EventMessage.Serialize());
        eventMap.put("message", OSD.FromString(MessageEvents[i].MessageKey));
        eventsArray.add(eventMap);
      }

      map.put("events", eventsArray);
      map.put("id", OSD.FromInteger(Sequence));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.