APIs

Show:
// --------- This code has been automatically generated !!! 2017-12-15T21:14:00.075Z
"use strict";
/**
 * @module opcua.address_space.types
 */
var assert = require("node-opcua-assert");
var util = require("util");
var _  = require("underscore");
var makeNodeId = require("node-opcua-nodeid").makeNodeId;
var schema_helpers =  require("node-opcua-factory/src/factories_schema_helpers");
var extract_all_fields                       = schema_helpers.extract_all_fields;
var resolve_schema_field_types               = schema_helpers.resolve_schema_field_types;
var initialize_field                         = schema_helpers.initialize_field;
var initialize_field_array                   = schema_helpers.initialize_field_array;
var check_options_correctness_against_schema = schema_helpers.check_options_correctness_against_schema;
var _defaultTypeMap = require("node-opcua-factory/src/factories_builtin_types")._defaultTypeMap;
var ec = require("node-opcua-basic-types");
var encodeArray = ec.encodeArray;
var decodeArray = ec.decodeArray;
var makeExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").makeExpandedNodeId;
var generate_new_id = require("node-opcua-factory").generate_new_id;
var _enumerations = require("node-opcua-factory/src/factories_enumerations")._private._enumerations;
var schema = require("../schemas/CreateSessionResponse_schema").CreateSessionResponse_Schema;
var getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
var ResponseHeader = getFactory("ResponseHeader");
var EndpointDescription = getFactory("EndpointDescription");
var SignedSoftwareCertificate = require("./_auto_generated_SignedSoftwareCertificate").SignedSoftwareCertificate;
var SignatureData = getFactory("SignatureData");
var BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;

/**
 * Creates a new session with the server.
 * 
 * @class CreateSessionResponse
 * @constructor
 * @extends BaseUAObject
 * @param  options {Object}
 * @param  [options.responseHeader] {ResponseHeader} A standard header included in all responses returned by servers.
 * @param  [options.sessionId] {NodeId} A identifier which uniquely identifies the session.
 * @param  [options.authenticationToken] {SessionAuthenticationToken} The token used to authenticate the client in subsequent requests.
 * @param  [options.revisedSessionTimeout] {Duration} The session timeout in milliseconds.
 * @param  [options.serverNonce] {ByteString} A random number generated by the server.
 * @param  [options.serverCertificate] {ByteString} The application certificate for the server.
 * @param  [options.serverEndpoints] {EndpointDescription[]} The endpoints provided by the server.
 * @param  [options.serverSoftwareCertificates] {SignedSoftwareCertificate[]} The software certificates owned by the server.
 * @param  [options.serverSignature] {SignatureData} A signature created with the server certificate.
 * @param  [options.maxRequestMessageSize] {UInt32} The maximum message size accepted by the server.
 */
function CreateSessionResponse(options)
{
    options = options || {};
    /* istanbul ignore next */
    if (schema_helpers.doDebug) { check_options_correctness_against_schema(this,schema,options); }
    var self = this;
    assert(this instanceof BaseUAObject); //  ' keyword "new" is required for constructor call')
    resolve_schema_field_types(schema);

    BaseUAObject.call(this,options);

    /**
      * A standard header included in all responses returned by servers.
      * @property responseHeader
      * @type {ResponseHeader}
      */
    self.responseHeader =  new ResponseHeader( options.responseHeader);

    /**
      * A identifier which uniquely identifies the session.
      * @property sessionId
      * @type {NodeId}
      */
    self.sessionId = initialize_field(schema.fields[1], options.sessionId);

    /**
      * The token used to authenticate the client in subsequent requests.
      * @property authenticationToken
      * @type {SessionAuthenticationToken}
      */
    self.authenticationToken = initialize_field(schema.fields[2], options.authenticationToken);

    /**
      * The session timeout in milliseconds.
      * @property revisedSessionTimeout
      * @type {Duration}
      */
    self.revisedSessionTimeout = initialize_field(schema.fields[3], options.revisedSessionTimeout);

    /**
      * A random number generated by the server.
      * @property serverNonce
      * @type {ByteString}
      */
    self.serverNonce = initialize_field(schema.fields[4], options.serverNonce);

    /**
      * The application certificate for the server.
      * @property serverCertificate
      * @type {ByteString}
      */
    self.serverCertificate = initialize_field(schema.fields[5], options.serverCertificate);

    /**
      * The endpoints provided by the server.
      * @property serverEndpoints
      * @type {EndpointDescription[]}
      */
    self.serverEndpoints = [];
    if (options.serverEndpoints) {
        assert(_.isArray(options.serverEndpoints));
        self.serverEndpoints = options.serverEndpoints.map(function(e){ return new EndpointDescription(e); } );
    }

    /**
      * The software certificates owned by the server.
      * @property serverSoftwareCertificates
      * @type {SignedSoftwareCertificate[]}
      */
    self.serverSoftwareCertificates = [];
    if (options.serverSoftwareCertificates) {
        assert(_.isArray(options.serverSoftwareCertificates));
        self.serverSoftwareCertificates = options.serverSoftwareCertificates.map(function(e){ return new SignedSoftwareCertificate(e); } );
    }

    /**
      * A signature created with the server certificate.
      * @property serverSignature
      * @type {SignatureData}
      */
    self.serverSignature =  new SignatureData( options.serverSignature);

    /**
      * The maximum message size accepted by the server.
      * @property maxRequestMessageSize
      * @type {UInt32}
      */
    self.maxRequestMessageSize = initialize_field(schema.fields[9], options.maxRequestMessageSize);

   // Object.preventExtensions(self);
}
util.inherits(CreateSessionResponse,BaseUAObject);
CreateSessionResponse.prototype.encodingDefaultBinary = makeExpandedNodeId(464,0);
CreateSessionResponse.prototype.encodingDefaultXml = makeExpandedNodeId(463,0);
CreateSessionResponse.prototype._schema = schema;

var encode_NodeId = _defaultTypeMap.NodeId.encode;
var decode_NodeId = _defaultTypeMap.NodeId.decode;
var encode_SessionAuthenticationToken = _defaultTypeMap.SessionAuthenticationToken.encode;
var decode_SessionAuthenticationToken = _defaultTypeMap.SessionAuthenticationToken.decode;
var encode_Duration = _defaultTypeMap.Duration.encode;
var decode_Duration = _defaultTypeMap.Duration.decode;
var encode_ByteString = _defaultTypeMap.ByteString.encode;
var decode_ByteString = _defaultTypeMap.ByteString.decode;
var encode_UInt32 = _defaultTypeMap.UInt32.encode;
var decode_UInt32 = _defaultTypeMap.UInt32.decode;
/**
 * encode the object into a binary stream
 * @method encode
 *
 * @param stream {BinaryStream} 
 */
CreateSessionResponse.prototype.encode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.encode.call(this,stream,options);
   this.responseHeader.encode(stream,options);
    encode_NodeId(this.sessionId,stream);
    encode_SessionAuthenticationToken(this.authenticationToken,stream);
    encode_Duration(this.revisedSessionTimeout,stream);
    encode_ByteString(this.serverNonce,stream);
    encode_ByteString(this.serverCertificate,stream);
    encodeArray(this.serverEndpoints,stream,function(obj,stream){ obj.encode(stream,options); }); 
    encodeArray(this.serverSoftwareCertificates,stream,function(obj,stream){ obj.encode(stream,options); }); 
   this.serverSignature.encode(stream,options);
    encode_UInt32(this.maxRequestMessageSize,stream);
};
/**
 * decode the object from a binary stream
 * @method decode
 *
 * @param stream {BinaryStream} 
 * @param [option] {object} 
 */
CreateSessionResponse.prototype.decode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.decode.call(this,stream,options);
    this.responseHeader.decode(stream,options);
    this.sessionId = decode_NodeId(stream,options);
    this.authenticationToken = decode_SessionAuthenticationToken(stream,options);
    this.revisedSessionTimeout = decode_Duration(stream,options);
    this.serverNonce = decode_ByteString(stream,options);
    this.serverCertificate = decode_ByteString(stream,options);
    this.serverEndpoints = decodeArray(stream, function(stream) { 
       var obj = new EndpointDescription();
       obj.decode(stream,options);
       return obj; 
    });
    this.serverSoftwareCertificates = decodeArray(stream, function(stream) { 
       var obj = new SignedSoftwareCertificate();
       obj.decode(stream,options);
       return obj; 
    });
    this.serverSignature.decode(stream,options);
    this.maxRequestMessageSize = decode_UInt32(stream,options);
};
CreateSessionResponse.possibleFields = [
  "responseHeader",
         "sessionId",
         "authenticationToken",
         "revisedSessionTimeout",
         "serverNonce",
         "serverCertificate",
         "serverEndpoints",
         "serverSoftwareCertificates",
         "serverSignature",
         "maxRequestMessageSize"
];


exports.CreateSessionResponse = CreateSessionResponse;
var register_class_definition = require("node-opcua-factory/src/factories_factories").register_class_definition;
register_class_definition("CreateSessionResponse",CreateSessionResponse);