stoiandan / Howdy

Zero configuration network discovery tool for macOS
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

File Transfer #3

Open stoiandan opened 6 months ago

stoiandan commented 6 months ago

Howdy could be used to transfer files between instances. All that is need is some additional meta-data, probably in the header, though it could be encoded even in the existing UInt, but let's not be too frugal. The new meta-data should be a bool saying "Do we do a file transfer now?", and if so the data with its already present size, should be treated like a file and saved somewhere, as opposed to a hostname message.

stoiandan commented 6 months ago

@N3v1 if you want to work with me in this ^^ let me know.

N3v1 commented 6 months ago

Sure - What needs to be done? Can you provide me with any resources about this topic I can read?

stoiandan commented 6 months ago

Well, there's the UI part and there's the networking part. From the networking part, we need to extend the HowdyMessageHeader struct to include a bool, I think. This should tell is if the incoming message is a hostname message, were all you get is a string of a hostname to list it. On the other hand, if the bool (say isFileTransfer, but maybe an enum Operation with two cases hostName and fileTransfer is a better idea) is coming set to true then we treat the incoming bytes (Data) as a file, no a string.

We can then check for this bool or enum in HowdyProtocol class' handleInput, this is were we are called by Network.framework every time we receive some bytes (the buffer) in order to form them into a higher order message (this is our protocol, the heart of it).

So HowdyProtocol's handleInput and handleOutput are the low-level methods that form the message for the higher-level receiveMessage and send . So it's in the higher-level send were would decide what message to send, and the in handleInput to repare it for receiveMessage

Does that make sense?