yosef-abraham / swamp

the WAMP WebSocket subprotocol implemented purely in Swift using Starscream & SwiftyJSON
MIT License
42 stars 36 forks source link

updating swamp #8

Closed eliburke closed 7 years ago

eliburke commented 7 years ago

@iscriptology I'm not sure the best way to proceed with this. I need to get SWAMP working quickly so I can move on to other things. I would like to be able to work with you and create a more robust implementation, but as I said in my PR for Carthage support, my patches are going to all depend on each other.

If you don't have spare time to work on this right now, I'll proceed with development in my own fork, and maybe at some point in the future we can work together to merge the two.

Here's my short term plan: add enums for WAMP protocol and auth method add separate WebSocketSwampTransport initializers for JSON and MsgPack fix wampcra support for salted passwords remove cryptoswift, replace with CommonCrypto (CryptoSwift is a very heavy dependency for one single call to HMAC)

I can't figure out if is possible to advertise multiple protocols [json, msgpack] and get enough information back via the websocket to set the mode and serializer properly, but it would be nice to have that happen programmatically.

yosef-abraham commented 7 years ago

As long as you keep your code kinda clean, I don't see a reason for you not to work on your own fork, and once it's good we can merge it. I do have time on weekends actually, we can do it together. might be fun.

eliburke commented 7 years ago

@iscriptology I've hit a snag with adding MsgPack support. MessagePack.swift consumes all Signed and Unsigned Int values and stores them in the minimum size possible (so, an Int64(17) will be stored as a single byte). When unpacking, all values are unpacked to Int64 or UInt64

This behavior is permissible within the MsgPack specification, but it wreaks havoc on the SwampMessages serializer / deserializer workflow that is designed around using Int.

If I try to make everything use UInt64 and Int64, it breaks the json serializer. Probably, MessagePack.swift needs to be modified to behave a little differently, but I'm fairly certain the maintainer won't accept a PR for the purpose. He might be OK with importing a modified copy into the SWAMP repo.

We are close to giving up on MsgPack and sticking with JSON and base64, so if you don't have any good ideas I'll just commit my changes and pull a PR for you to look at, and move on for a bit.