Skip to content

Commit 04515a5

Browse files
authored
Merge pull request #101 from smartdevicelink/feature/private-accessors
Make some methods and class members private. Remove redundant SdlSess…
2 parents b939036 + 8fee7d5 commit 04515a5

8 files changed

Lines changed: 55 additions & 56 deletions

File tree

lib/js/dist/SDL.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/src/protocol/MessageFrameDisassembler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class MessageFrameDisassembler {
8181
*/
8282
static buildRPC (rpcRequest, sessionId, messageId, mtu, version, isEncrypted, cb) {
8383
const obj = new MessageFrameDisassembler(rpcRequest, sessionId, messageId, mtu, version, isEncrypted, cb);
84-
obj.doRequest();
84+
obj._doRequest();
8585
return obj;
8686
}
8787

@@ -128,8 +128,9 @@ class MessageFrameDisassembler {
128128
/**
129129
* Start the RPC request and use callback to send
130130
* sdl packets of the appropriate size.
131+
* @private
131132
*/
132-
doRequest () {
133+
_doRequest () {
133134
const version = this._version;
134135
const frameInfo = 0;
135136
const frameType = FrameType.SINGLE;

lib/js/src/protocol/SdlPacket.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ import { Bson } from './../util/Bson.js';
3535

3636
/**
3737
* @typedef {Object} SdlPacket
38-
* @property {number} EXTRA_PARCEL_DATA_LENGTH
39-
* @property {number} HEADER_SIZE
40-
* @property {number} HEADER_SIZE_V1
41-
* @property {number} ENCRYPTION_MASK
38+
* @property {number} _EXTRA_PARCEL_DATA_LENGTH
39+
* @property @private {number} _HEADER_SIZE
40+
* @property @private {number} _HEADER_SIZE_V1
41+
* @property @private {number} _ENCRYPTION_MASK
4242
* @property {number} SERVICE_TYPE_CONTROL
4343
* @property {number} SERVICE_TYPE_RPC
4444
* @property {number} SERVICE_TYPE_PCM
@@ -73,7 +73,7 @@ import { Bson } from './../util/Bson.js';
7373
* @property {function} getFrameType
7474
* @property {function} toUint8Array
7575
* @property {function} toString
76-
* @property {function} constructPacket
76+
* @property @private {function} _constructPacket
7777
* @property {function} putTag
7878
* @property {function} getTag
7979
*/
@@ -187,7 +187,7 @@ class SdlPacket {
187187
* @return {Number} - Returns a number representing a byte mask depending on the boolean value
188188
*/
189189
static getEncryptionBit (encryption) {
190-
return encryption ? SdlPacket.ENCRYPTION_MASK : 0;
190+
return encryption ? SdlPacket._ENCRYPTION_MASK : 0;
191191
}
192192

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

243243
if (version > 1) {
244-
dataView = new Uint8Array(SdlPacket.HEADER_SIZE + dataSize);
244+
dataView = new Uint8Array(SdlPacket._HEADER_SIZE + dataSize);
245245
} else {
246-
dataView = new Uint8Array(SdlPacket.HEADER_SIZE_V1 + dataSize);
246+
dataView = new Uint8Array(SdlPacket._HEADER_SIZE_V1 + dataSize);
247247
}
248248

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

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

285285
/**
@@ -311,11 +311,11 @@ class SdlPacket {
311311
}
312312
}
313313

314-
SdlPacket.EXTRA_PARCEL_DATA_LENGTH = 24;
315-
SdlPacket.HEADER_SIZE = 12;
316-
SdlPacket.HEADER_SIZE_V1 = 8;
314+
SdlPacket._EXTRA_PARCEL_DATA_LENGTH = 24;
315+
SdlPacket._HEADER_SIZE = 12;
316+
SdlPacket._HEADER_SIZE_V1 = 8;
317317

318-
SdlPacket.ENCRYPTION_MASK = 0x08;
318+
SdlPacket._ENCRYPTION_MASK = 0x08;
319319

320320
/**
321321
* Service Type

lib/js/src/protocol/SdlProtocolBase.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ class SdlProtocolBase {
6464
this._sdlProtocolListener = sdlProtocolListener;
6565
this._transportManager = null;
6666

67-
this.reset();
67+
this._reset();
6868
this._createTransportListener();
6969
}
7070

7171

7272
/**
7373
* Resets the sdl protocol to its default state.
74+
* @private
7475
*/
75-
reset () {
76+
_reset () {
7677
this._protocolVersion = new Version(1, 0, 0);
7778
this._transportConfig = this._baseTransportConfig;
7879
this._headerSize = SdlProtocolBase.V1_HEADER_SIZE;

lib/js/src/rpc/RpcStruct.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ class RpcStruct {
7878
* @return {Object}
7979
*/
8080
getObject (tClass, key) {
81-
return this.formatObject(tClass, this.getParameter(key));
81+
return this._formatObject(tClass, this.getParameter(key));
8282
}
8383

8484
/**
8585
* @param {Function} tClass
8686
* @param {Object} obj
87+
* @private
8788
* @return {null|Object}
8889
*/
89-
formatObject (tClass, obj) {
90+
_formatObject (tClass, obj) {
9091
if (obj === null || obj === undefined) {
9192
return null;
9293
} else if (obj.constructor === tClass) {
@@ -103,7 +104,7 @@ class RpcStruct {
103104
if (obj.length > 0) {
104105
const outArray = [];
105106
for (const item of obj) {
106-
outArray.push(this.formatObject(tClass, item));
107+
outArray.push(this._formatObject(tClass, item));
107108
}
108109
return outArray;
109110
}

lib/js/src/session/SdlSession.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { VideoStreamingParameters } from '../streaming/video/VideoStreamingParam
4545
* @property {Function} onProtocolSessionEnded
4646
* @property {Function} onProtocolSessionEndedNACKed
4747
* @property {Function} onRpcMessageReceived
48-
* @property {Function} endSession
4948
* @property {Function} sendRpc
5049
* @property {Function} getMtu
5150
* @property {Function} close
@@ -175,10 +174,6 @@ class SdlSession {
175174
* END: SdlProtocolListener implemented methods
176175
************************************************************************************************************************************************************************/
177176

178-
endSession () {
179-
this._sdlProtocol.endSession();
180-
}
181-
182177
/**
183178
* @param {RpcMessage} rpcMessage
184179
*/

lib/node/dist/index.js

Lines changed: 28 additions & 27 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)