Exemplo n.º 1
0
		public IAdaptingType read( FlashorbBinaryReader reader, ParseContext parseContext )
		{
            double dateTime = reader.ReadDouble();
            // ignore the stupid timezone
            reader.ReadUnsignedShort();

            DateTime sent = new DateTime( 1970, 1, 1 );

#if (FULL_BUILD || PURE_CLIENT_LIB )
            // get the offset of the time zone the server is in
            double localTimezoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset( sent ).TotalMilliseconds;
            // convert 1/1/1970 12AM to UTC
            sent = TimeZone.CurrentTimeZone.ToUniversalTime( sent );
#else
            double localTimezoneOffset = TimeZoneInfo.Local.GetUtcOffset( sent ).TotalMilliseconds;
            sent = TimeZoneInfo.ConvertTime( sent, TimeZoneInfo.Utc );
#endif
            
            // bring it back to 12AM
            sent = sent.AddMilliseconds( localTimezoneOffset );

            // now that the sent object is in UTC and it represents 1/1/1970 12AM
            // convert it to the time sent by the client. The result of the operation
            // is going to be client's datetime object in UTC
            sent = sent.AddMilliseconds( dateTime );

            return new DateType( sent );
		}	
Exemplo n.º 2
0
		public IAdaptingType read( FlashorbBinaryReader reader, ParseContext parseContext )
		{
			int pointer = reader.ReadUnsignedShort();
			return parseContext.getReference( pointer );
		}
Exemplo n.º 3
0
    public Request readMessage(Stream input)
    {
      FlashorbBinaryReader reader = new FlashorbBinaryReader(input);

      try
      {
        if (Log.isLogging(LoggingConstants.DEBUG))
          Log.log(LoggingConstants.DEBUG, "MessageReader:: parsing stream");

        int version = reader.ReadUnsignedShort();
        int totalHeaders = reader.ReadUnsignedShort();

        if (Log.isLogging(LoggingConstants.DEBUG))
          Log.log(LoggingConstants.DEBUG, "MessageReader:: parsing message - version: " + version + " totalHeaders: " + totalHeaders);

        Header[] headers = new Header[totalHeaders];

        for (int i = 0; i < totalHeaders; i++)
          headers[i] = readHeader(reader);

        int totalBodyParts = reader.ReadUnsignedShort();

        if (Log.isLogging(LoggingConstants.DEBUG))
          Log.log(LoggingConstants.DEBUG, "MessageReader:: Total body parts: " + totalBodyParts);

        Body[] bodies = new Body[totalBodyParts];

        for (int i = 0; i < totalBodyParts; i++)
          bodies[i] = readBodyPart(reader);

        if (Log.isLogging(LoggingConstants.DEBUG))
          Log.log(LoggingConstants.DEBUG, "MessageReader:: returning AMFMessage");

        Request request = new Request(version, headers, bodies);
        request.SetFormatter(version == 3 ? (IProtocolFormatter)new AmfV3Formatter() : (IProtocolFormatter)new AmfFormatter());
        return request;
      }
      catch (Exception exception)
      {
        if (Log.isLogging(LoggingConstants.EXCEPTION))
          Log.log(LoggingConstants.EXCEPTION, "Exception: " + exception.Message + " StackTrace: " + exception.StackTrace);
        return null;
      }
    }
Exemplo n.º 4
0
    private Body readBodyPart(FlashorbBinaryReader reader)
    {
      int serviceURILength = reader.ReadUnsignedShort();
#if (FULL_BUILD)
      string serviceURI = encoding.GetString(reader.ReadBytes(serviceURILength));
#else
            string serviceURI = BitConverter.ToString( reader.ReadBytes( serviceURILength ) );
#endif
      int responseURILength = reader.ReadUnsignedShort();
#if (FULL_BUILD)
      string responseURI = encoding.GetString(reader.ReadBytes(responseURILength));
#else
            string responseURI = BitConverter.ToString( reader.ReadBytes( responseURILength ) );
#endif
      int length = reader.ReadInteger();

      if (Log.isLogging(LoggingConstants.DEBUG))
        Log.log(LoggingConstants.DEBUG, "MessageReader::readBodyPart: serviceURI - " + serviceURI + " responseURI - " + responseURI + " length: " + length);

      return new Body(serviceURI, responseURI, length, readData(reader));
    }
Exemplo n.º 5
0
    private Header readHeader(FlashorbBinaryReader reader)
    {
      int nameLength = reader.ReadUnsignedShort();
      byte[] bytes = reader.ReadBytes(nameLength);
#if (FULL_BUILD)
      string headerName = encoding.GetString(bytes);
#else 
            string headerName = BitConverter.ToString( bytes );
#endif
      bool mustUnderstand = reader.ReadBoolean();
      //int length = reader.ReadInt32();
      int length = reader.ReadInteger();

      if (Log.isLogging(LoggingConstants.DEBUG))
        Log.log(LoggingConstants.DEBUG, "MessageReader::readHeader: name - " + headerName + " mustUnderstand - " + mustUnderstand + " length - " + length);

      return new Header(headerName, mustUnderstand, length, readData(reader));
    }