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

chrome.sockets.tcp implementation #178

Closed
matbee-eth opened this issue Oct 9, 2014 · 4 comments
Closed

chrome.sockets.tcp implementation #178

matbee-eth opened this issue Oct 9, 2014 · 4 comments

Comments

@matbee-eth
Copy link

Here's how it looks:
socket.connect({
client.handshake();
})

tlsDataReady({
var data = connection.tlsData.getBytes();
var datab = str2ab(data);
socket.send(datab, function(writeInfo) {
});
})

socket.on("receive", function (msg) {
client.process(ab2str(msg.data));
});

How should I be converting the Data? Array Buffer <-> String data

[socket] connected
tlsDataReady ������������������������**utf characters**
[tls] server certificate verified
tlsDataReady utf characters

It just sits idle at this point...

@matbee-eth matbee-eth reopened this Oct 9, 2014
@matbee-eth
Copy link
Author

@dlongley
Copy link
Member

dlongley commented Oct 9, 2014

var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char

You don't need 2 bytes for each char. The string's internal implementation will use two bytes to store each character in a binary string, but each character code is < 256 and when converting to a Uint8Array the number of bytes will match the number of characters.

@matbee-eth
Copy link
Author

Wow. Yep. Sorry for bothering you.

@dlongley
Copy link
Member

dlongley commented Oct 9, 2014

No problem! Glad that fixed it. :)

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

2 participants