// --------- This code has been automatically generated !!! 2018-09-03T20:28:09.260Z
"use strict";
/**
* @module opcua.address_space.types
*/
const assert = require("node-opcua-assert").assert;
const util = require("util");
const _ = require("underscore");
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const schema_helpers = require("node-opcua-factory/src/factories_schema_helpers");
const extract_all_fields = schema_helpers.extract_all_fields;
const resolve_schema_field_types = schema_helpers.resolve_schema_field_types;
const initialize_field = schema_helpers.initialize_field;
const initialize_field_array = schema_helpers.initialize_field_array;
const check_options_correctness_against_schema = schema_helpers.check_options_correctness_against_schema;
const _defaultTypeMap = require("node-opcua-factory/src/factories_builtin_types")._defaultTypeMap;
const ec = require("node-opcua-basic-types");
const encodeArray = ec.encodeArray;
const decodeArray = ec.decodeArray;
const makeExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").makeExpandedNodeId;
const generate_new_id = require("node-opcua-factory").generate_new_id;
const _enumerations = require("node-opcua-factory/src/factories_enumerations")._private._enumerations;
const schema = require("../schemas/CreateSessionResponse_schema").CreateSessionResponse_Schema;
const getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
const ResponseHeader = getFactory("ResponseHeader");
const EndpointDescription = getFactory("EndpointDescription");
const SignedSoftwareCertificate = require("./_auto_generated_SignedSoftwareCertificate").SignedSoftwareCertificate;
const SignatureData = getFactory("SignatureData");
const BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;
/**
* Creates a new session with the server.
*
* @class CreateSessionResponse
* @constructor
* @extends BaseUAObject
* @param options {Object}
*/
function CreateSessionResponse(options)
{
options = options || {};
/* istanbul ignore next */
if (schema_helpers.doDebug) { check_options_correctness_against_schema(this,schema,options); }
const self = this;
assert(this instanceof BaseUAObject); // ' keyword "new" is required for constructor call')
resolve_schema_field_types(schema);
BaseUAObject.call(this,options);
if (options === null) {
BaseUAObject.call(this,options);
self.responseHeader = null; /* new ResponseHeader(null); */
self.serverEndpoints = null; /* null array */
self.serverSoftwareCertificates = null; /* null array */
self.serverSignature = null; /* new SignatureData(null); */
return ;
}
/**
* 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;
const encode_NodeId = _defaultTypeMap.NodeId.encode;
const decode_NodeId = _defaultTypeMap.NodeId.decode;
const encode_SessionAuthenticationToken = _defaultTypeMap.SessionAuthenticationToken.encode;
const decode_SessionAuthenticationToken = _defaultTypeMap.SessionAuthenticationToken.decode;
const encode_Duration = _defaultTypeMap.Duration.encode;
const decode_Duration = _defaultTypeMap.Duration.decode;
const encode_ByteString = _defaultTypeMap.ByteString.encode;
const decode_ByteString = _defaultTypeMap.ByteString.decode;
const encode_UInt32 = _defaultTypeMap.UInt32.encode;
const 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}
*/
CreateSessionResponse.prototype.decode = function(stream) {
// call base class implementation first
BaseUAObject.prototype.decode.call(this,stream);
this.responseHeader.decode(stream);
this.sessionId = decode_NodeId(stream);
this.authenticationToken = decode_SessionAuthenticationToken(stream);
this.revisedSessionTimeout = decode_Duration(stream);
this.serverNonce = decode_ByteString(stream);
this.serverCertificate = decode_ByteString(stream);
this.serverEndpoints = decodeArray(stream, function(stream) {
const obj = new EndpointDescription(null);
obj.decode(stream);
return obj;
});
this.serverSoftwareCertificates = decodeArray(stream, function(stream) {
const obj = new SignedSoftwareCertificate(null);
obj.decode(stream);
return obj;
});
this.serverSignature.decode(stream);
this.maxRequestMessageSize = decode_UInt32(stream);
};
CreateSessionResponse.possibleFields = [
"responseHeader",
"sessionId",
"authenticationToken",
"revisedSessionTimeout",
"serverNonce",
"serverCertificate",
"serverEndpoints",
"serverSoftwareCertificates",
"serverSignature",
"maxRequestMessageSize"
];
exports.CreateSessionResponse = CreateSessionResponse;
const register_class_definition = require("node-opcua-factory/src/factories_factories").register_class_definition;
register_class_definition("CreateSessionResponse",CreateSessionResponse);