Skip to content

Commit c5fe074

Browse files
committed
DRY: creates Protocol#_startSequence
1 parent b3220d3 commit c5fe074

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/protocol/Protocol.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ Protocol.prototype._enqueue = function(sequence) {
106106

107107
if (this._queue.length === 1) {
108108
this._parser.resetPacketNumber();
109-
if (sequence.constructor == Sequences.ChangeUser) {
110-
sequence.start(this._handshakeInitializationPacket);
111-
} else {
112-
sequence.start();
113-
}
109+
this._startSequence(sequence);
114110
}
115111

116112
return sequence;
@@ -231,12 +227,15 @@ Protocol.prototype._dequeue = function() {
231227

232228
this._parser.resetPacketNumber();
233229

234-
if (sequence.constructor == Sequences.ChangeUser) {
230+
this._startSequence(sequence);
231+
};
232+
233+
Protocol.prototype._startSequence = function(sequence) {
234+
if (sequence.constructor === Sequences.ChangeUser) {
235235
sequence.start(this._handshakeInitializationPacket);
236-
return;
236+
} else {
237+
sequence.start();
237238
}
238-
239-
sequence.start();
240239
};
241240

242241
Protocol.prototype.handleNetworkError = function(err) {

0 commit comments

Comments
 (0)