diffusion
Version:
Diffusion JavaScript client
30 lines (29 loc) • 1.08 kB
JavaScript
;
/**
* @module Transport
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.connectionResponse = void 0;
var connection_response_deserialiser_1 = require("./../protocol/connection-response-deserialiser");
var logger_1 = require("./../util/logger");
var log = logger_1.create('Parsing');
/**
* Connection response parser. Wraps the connection response deserialiser and takes callbacks for successful and failed
* parsing of the buffer.
*
* @param onHandshakeSuccess on success callback
* @param onHandshakeError on failure callback
* @param message the buffer to parse
* @return the parsed response or null if parsing failed
*/
function connectionResponse(onHandshakeSuccess, onHandshakeError, message) {
log.trace('Received connection handshake response');
try {
return onHandshakeSuccess(connection_response_deserialiser_1.deserialise(message));
}
catch (e) {
onHandshakeError(e);
return null;
}
}
exports.connectionResponse = connectionResponse;