|  | @@ -44,9 +44,20 @@ var _ = require('lodash');
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Get a function that deserializes a specific type of protobuf.
 | 
	
		
			
				|  |  |   * @param {function()} cls The constructor of the message type to deserialize
 | 
	
		
			
				|  |  | + * @param {bool=} binaryAsBase64 Deserialize bytes fields as base64 instead of binary.
 | 
	
		
			
				|  |  | + *     Defaults to false
 | 
	
		
			
				|  |  | + * @param {bool=} longsAsStrings Deserialize long values as strings instead of doubles.
 | 
	
		
			
				|  |  | + *     Defaults to true
 | 
	
		
			
				|  |  |   * @return {function(Buffer):cls} The deserialization function
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -exports.deserializeCls = function deserializeCls(cls) {
 | 
	
		
			
				|  |  | +exports.deserializeCls = function deserializeCls(cls, binaryAsBase64,
 | 
	
		
			
				|  |  | +                                                 longsAsStrings) {
 | 
	
		
			
				|  |  | +  if (binaryAsBase64 === undefined || binaryAsBase64 === null) {
 | 
	
		
			
				|  |  | +    binaryAsBase64 = false;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  if (longsAsStrings === undefined || longsAsStrings === null) {
 | 
	
		
			
				|  |  | +    longsAsStrings = true;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |    /**
 | 
	
		
			
				|  |  |     * Deserialize a buffer to a message object
 | 
	
		
			
				|  |  |     * @param {Buffer} arg_buf The buffer to deserialize
 | 
	
	
		
			
				|  | @@ -55,7 +66,7 @@ exports.deserializeCls = function deserializeCls(cls) {
 | 
	
		
			
				|  |  |    return function deserialize(arg_buf) {
 | 
	
		
			
				|  |  |      // Convert to a native object with binary fields as Buffers (first argument)
 | 
	
		
			
				|  |  |      // and longs as strings (second argument)
 | 
	
		
			
				|  |  | -    return cls.decode(arg_buf).toRaw(false, true);
 | 
	
		
			
				|  |  | +    return cls.decode(arg_buf).toRaw(binaryAsBase64, longsAsStrings);
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -119,19 +130,27 @@ exports.wrapIgnoreNull = function wrapIgnoreNull(func) {
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Return a map from method names to method attributes for the service.
 | 
	
		
			
				|  |  |   * @param {ProtoBuf.Reflect.Service} service The service to get attributes for
 | 
	
		
			
				|  |  | + * @param {Object=} options Options to apply to these attributes
 | 
	
		
			
				|  |  |   * @return {Object} The attributes map
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service) {
 | 
	
		
			
				|  |  | +exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service, options) {
 | 
	
		
			
				|  |  |    var prefix = '/' + fullyQualifiedName(service) + '/';
 | 
	
		
			
				|  |  | +  var binaryAsBase64, longsAsStrings;
 | 
	
		
			
				|  |  | +  if (options) {
 | 
	
		
			
				|  |  | +    binaryAsBase64 = options.binaryAsBase64;
 | 
	
		
			
				|  |  | +    longsAsStrings = options.longsAsStrings;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |    return _.object(_.map(service.children, function(method) {
 | 
	
		
			
				|  |  |      return [_.camelCase(method.name), {
 | 
	
		
			
				|  |  |        path: prefix + method.name,
 | 
	
		
			
				|  |  |        requestStream: method.requestStream,
 | 
	
		
			
				|  |  |        responseStream: method.responseStream,
 | 
	
		
			
				|  |  |        requestSerialize: serializeCls(method.resolvedRequestType.build()),
 | 
	
		
			
				|  |  | -      requestDeserialize: deserializeCls(method.resolvedRequestType.build()),
 | 
	
		
			
				|  |  | +      requestDeserialize: deserializeCls(method.resolvedRequestType.build(),
 | 
	
		
			
				|  |  | +                                     binaryAsBase64, longsAsStrings),
 | 
	
		
			
				|  |  |        responseSerialize: serializeCls(method.resolvedResponseType.build()),
 | 
	
		
			
				|  |  | -      responseDeserialize: deserializeCls(method.resolvedResponseType.build())
 | 
	
		
			
				|  |  | +      responseDeserialize: deserializeCls(method.resolvedResponseType.build(),
 | 
	
		
			
				|  |  | +                                     binaryAsBase64, longsAsStrings)
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |    }));
 | 
	
		
			
				|  |  |  };
 |