Skip to content

Commit

Permalink
Merge pull request #101 from smartdevicelink/feature/private-accessors
Browse files Browse the repository at this point in the history
Make some methods and class members private. Remove redundant SdlSess…
  • Loading branch information
crokita committed Jan 22, 2020
2 parents b939036 + 8fee7d5 commit 04515a5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 56 deletions.
4 changes: 2 additions & 2 deletions lib/js/dist/SDL.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lib/js/src/protocol/MessageFrameDisassembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MessageFrameDisassembler {
*/
static buildRPC (rpcRequest, sessionId, messageId, mtu, version, isEncrypted, cb) {
const obj = new MessageFrameDisassembler(rpcRequest, sessionId, messageId, mtu, version, isEncrypted, cb);
obj.doRequest();
obj._doRequest();
return obj;
}

Expand Down Expand Up @@ -128,8 +128,9 @@ class MessageFrameDisassembler {
/**
* Start the RPC request and use callback to send
* sdl packets of the appropriate size.
* @private
*/
doRequest () {
_doRequest () {
const version = this._version;
const frameInfo = 0;
const frameType = FrameType.SINGLE;
Expand Down
28 changes: 14 additions & 14 deletions lib/js/src/protocol/SdlPacket.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import { Bson } from './../util/Bson.js';

/**
* @typedef {Object} SdlPacket
* @property {number} EXTRA_PARCEL_DATA_LENGTH
* @property {number} HEADER_SIZE
* @property {number} HEADER_SIZE_V1
* @property {number} ENCRYPTION_MASK
* @property {number} _EXTRA_PARCEL_DATA_LENGTH
* @property @private {number} _HEADER_SIZE
* @property @private {number} _HEADER_SIZE_V1
* @property @private {number} _ENCRYPTION_MASK
* @property {number} SERVICE_TYPE_CONTROL
* @property {number} SERVICE_TYPE_RPC
* @property {number} SERVICE_TYPE_PCM
Expand Down Expand Up @@ -73,7 +73,7 @@ import { Bson } from './../util/Bson.js';
* @property {function} getFrameType
* @property {function} toUint8Array
* @property {function} toString
* @property {function} constructPacket
* @property @private {function} _constructPacket
* @property {function} putTag
* @property {function} getTag
*/
Expand Down Expand Up @@ -187,7 +187,7 @@ class SdlPacket {
* @return {Number} - Returns a number representing a byte mask depending on the boolean value
*/
static getEncryptionBit (encryption) {
return encryption ? SdlPacket.ENCRYPTION_MASK : 0;
return encryption ? SdlPacket._ENCRYPTION_MASK : 0;
}

/**
Expand Down Expand Up @@ -236,14 +236,14 @@ class SdlPacket {
* @param {Uint8Array} payload - Raw data that will be attached to the packet (RPC message, raw bytes, etc)
* @return {Uint8Array} - A byte[] representation of an SdlPacket built using the supplied params
*/
static constructPacket (version, encryption, frameType, serviceType, controlFrameInfo, sessionID, dataSize, messageID, payload) {
static _constructPacket (version, encryption, frameType, serviceType, controlFrameInfo, sessionID, dataSize, messageID, payload) {
let dataView = null;
let dataViewIndex = 0;

if (version > 1) {
dataView = new Uint8Array(SdlPacket.HEADER_SIZE + dataSize);
dataView = new Uint8Array(SdlPacket._HEADER_SIZE + dataSize);
} else {
dataView = new Uint8Array(SdlPacket.HEADER_SIZE_V1 + dataSize);
dataView = new Uint8Array(SdlPacket._HEADER_SIZE_V1 + dataSize);
}

dataView[dataViewIndex++] = (version << 4) + SdlPacket.getEncryptionBit(encryption) + frameType;
Expand Down Expand Up @@ -279,7 +279,7 @@ class SdlPacket {
this._dataSize = this._payload.length;
}

return SdlPacket.constructPacket(this._version, this._encryption, this._frameType, this._serviceType, this._frameInfo, this._sessionID, this._dataSize, this._messageID, this._payload);
return SdlPacket._constructPacket(this._version, this._encryption, this._frameType, this._serviceType, this._frameInfo, this._sessionID, this._dataSize, this._messageID, this._payload);
}

/**
Expand Down Expand Up @@ -311,11 +311,11 @@ class SdlPacket {
}
}

SdlPacket.EXTRA_PARCEL_DATA_LENGTH = 24;
SdlPacket.HEADER_SIZE = 12;
SdlPacket.HEADER_SIZE_V1 = 8;
SdlPacket._EXTRA_PARCEL_DATA_LENGTH = 24;
SdlPacket._HEADER_SIZE = 12;
SdlPacket._HEADER_SIZE_V1 = 8;

SdlPacket.ENCRYPTION_MASK = 0x08;
SdlPacket._ENCRYPTION_MASK = 0x08;

/**
* Service Type
Expand Down
5 changes: 3 additions & 2 deletions lib/js/src/protocol/SdlProtocolBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ class SdlProtocolBase {
this._sdlProtocolListener = sdlProtocolListener;
this._transportManager = null;

this.reset();
this._reset();
this._createTransportListener();
}


/**
* Resets the sdl protocol to its default state.
* @private
*/
reset () {
_reset () {
this._protocolVersion = new Version(1, 0, 0);
this._transportConfig = this._baseTransportConfig;
this._headerSize = SdlProtocolBase.V1_HEADER_SIZE;
Expand Down
7 changes: 4 additions & 3 deletions lib/js/src/rpc/RpcStruct.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ class RpcStruct {
* @return {Object}
*/
getObject (tClass, key) {
return this.formatObject(tClass, this.getParameter(key));
return this._formatObject(tClass, this.getParameter(key));
}

/**
* @param {Function} tClass
* @param {Object} obj
* @private
* @return {null|Object}
*/
formatObject (tClass, obj) {
_formatObject (tClass, obj) {
if (obj === null || obj === undefined) {
return null;
} else if (obj.constructor === tClass) {
Expand All @@ -103,7 +104,7 @@ class RpcStruct {
if (obj.length > 0) {
const outArray = [];
for (const item of obj) {
outArray.push(this.formatObject(tClass, item));
outArray.push(this._formatObject(tClass, item));
}
return outArray;
}
Expand Down
5 changes: 0 additions & 5 deletions lib/js/src/session/SdlSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { VideoStreamingParameters } from '../streaming/video/VideoStreamingParam
* @property {Function} onProtocolSessionEnded
* @property {Function} onProtocolSessionEndedNACKed
* @property {Function} onRpcMessageReceived
* @property {Function} endSession
* @property {Function} sendRpc
* @property {Function} getMtu
* @property {Function} close
Expand Down Expand Up @@ -175,10 +174,6 @@ class SdlSession {
* END: SdlProtocolListener implemented methods
************************************************************************************************************************************************************************/

endSession () {
this._sdlProtocol.endSession();
}

/**
* @param {RpcMessage} rpcMessage
*/
Expand Down
55 changes: 28 additions & 27 deletions lib/node/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 04515a5

Please sign in to comment.