geut / discovery-swarm-webrtc

discovery-swarm for WebRTC
MIT License
94 stars 23 forks source link

Optimized how signalhub is used #4

Closed RangerMauve closed 5 years ago

RangerMauve commented 5 years ago

I haven't tested it yet, but this is definitely a breaking change. :P

tinchoz49 commented 5 years ago

I was thinking that if you try to send a buffer channel like an hypercore key, the concatenation between that and the prefix is not going to be great because the buffer by default stringify to utf8 and usually we stringify the keys to hex.

It's going to be something like: 'prefix�߯����U@D���'��f�����U�7�|�'

Maybe it doesn't matter, I don't know haha

Or we can work everything as buffer by default we can check the prefix and the channel using Buffer.isBuffer

RangerMauve commented 5 years ago

@tinchoz49 Yeah, I added the toString('hex") for when it's an object, it should lead to readable channel names, I think.

Discovery-channel accepts either strings or buffers and converts them to a buffer internally. I think that with the way signalhub is set up it makes more sense to convert buffers to hex strings.

tinchoz49 commented 5 years ago

So in that case I think we are good to merge this

RangerMauve commented 5 years ago

I haven't tested it yet. I'm working on discovery-swarm-web so I'll test it as part of that before merging if that works for you. :D

RangerMauve commented 5 years ago

Seems to be working. :)

RangerMauve commented 5 years ago

Ok ok, NOW it's good to merge. :P

RangerMauve commented 5 years ago

Closing in favor of the new implementation