@bsv/authsocket-client
Version:
Mutually Authenticated Web Sockets Client
26 lines • 705 B
JavaScript
export class SocketClientTransport {
socket;
onDataCallback;
constructor(socket) {
this.socket = socket;
// Subscribe to the 'authMessage' event from the server
this.socket.on('authMessage', async (msg) => {
if (this.onDataCallback) {
await this.onDataCallback(msg);
}
});
}
/**
* Send an AuthMessage to the server.
*/
async send(message) {
this.socket.emit('authMessage', message);
}
/**
* Register a callback to handle incoming AuthMessages.
*/
async onData(callback) {
this.onDataCallback = callback;
}
}
//# sourceMappingURL=SocketClientTransport.js.map