Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for binary response / hex output: #145

Open
franky436 opened this issue Jan 1, 2023 · 1 comment
Open

Support for binary response / hex output: #145

franky436 opened this issue Jan 1, 2023 · 1 comment

Comments

@franky436
Copy link

Before “ws.send(programOptions.execute);” add:
ws.binaryType = "arraybuffer";

For hex output use:
wsConsole.print(Console.Types.Incoming, buf2hex(data), Console.Colors.Blue);

p.s.
function buf2hex(buffer) { // buffer is an ArrayBuffer
return [...new Uint8Array(buffer)]
.map(x => x.toString(16).padStart(2, '0'))
.join('');
}

@franky436
Copy link
Author

p.s. buf2hex output may then be used like this:

wscat -c ws://1.2.3.4/api/something -w 0 | xxd -p -r | protoc --decode_raw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant