var state = this._state[stateId]; if(state.partIndex < state.requestParts.length){ //Get the message part. var partData = state.requestParts[state.partIndex]; //Get the command. var cmd = "part"; if(state.partIndex + 1 == state.requestParts.length){ cmd = "end"; }else if (state.partIndex == 0){ cmd = "start"; } this.setServerUrl(stateId, cmd, partData); state.partIndex++; }