main.js
function onData(data) {

		data = data.toString("ascii");
		bufferedData += data;

		if (debug) console.log("Server: " + util.inspect(data));

		if (checkResp === true) {

			if (bufferedData.substr(0, 3) === "+OK") {

				checkResp = false;
				response = true;

			} else if (bufferedData.substr(0, 4) === "-ERR") {

				checkResp = false;
				response = false;

			// The following is only used for SASL
			} else if (multiline === false) {

				checkResp = false;
				response = true;

			}
		}

		if (checkResp === false) {

			if (multiline === true && (response === false || bufferedData.substr(bufferedData.length-5) === "\r\n.\r\n")) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			} else if (multiline === false) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			}
		} 
	}
function onData(data) {

		data = data.toString("ascii");
		bufferedData += data;

		if (debug) console.log("Server: " + util.inspect(data));

		if (checkResp === true) {

			if (bufferedData.substr(0, 3) === "+OK") {

				checkResp = false;
				response = true;

			} else if (bufferedData.substr(0, 4) === "-ERR") {

				checkResp = false;
				response = false;

			// The following is only used for SASL
			} else if (multiline === false) {

				checkResp = false;
				response = true;

			}
		}

		if (checkResp === false) {

			if (multiline === true && (response === false || bufferedData.substr(bufferedData.length-5) === "\r\n.\r\n")) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			} else if (multiline === false) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			}
		} 
	}
function onData ( data ) { data = data . toString ( "ascii" ) ; bufferedData += data ; if ( debug ) console . log ( "Server: " + util . inspect ( data ) ) ; if ( checkResp === true ) { if ( bufferedData . substr ( 0 , 3 ) === "+OK" ) { checkResp = false ; response = true ; } else if ( bufferedData . substr ( 0 , 4 ) === "-ERR" ) { checkResp = false ; response = false ; // The following is only used for SASL } else if ( multiline === false ) { checkResp = false ; response = true ; } } if ( checkResp === false ) { if ( multiline === true && ( response === false || bufferedData . substr ( bufferedData . length - 5 ) === "\r\n.\r\n" ) ) { // Make a copy to avoid race conditions var responseCopy = response ; var bufferedDataCopy = bufferedData ; response = null ; checkResp = true ; multiline = false ; bufferedData = "" ; callback ( responseCopy , bufferedDataCopy ) ; } else if ( multiline === false ) { // Make a copy to avoid race conditions var responseCopy = response ; var bufferedDataCopy = bufferedData ; response = null ; checkResp = true ; multiline = false ; bufferedData = "" ; callback ( responseCopy , bufferedDataCopy ) ; } } }
Private methods follow Event handlers follow
Private methods follow Event handlers follow