-
Notifications
You must be signed in to change notification settings - Fork 8
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
Move TCP connection away from Mac Network lib over to swift-nio enabling #5
Move TCP connection away from Mac Network lib over to swift-nio enabling #5
Conversation
return decoded | ||
} | ||
|
||
private func readFrame(buffer: inout ByteBuffer) throws -> ByteBuffer? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I did implemented correctly frames decoding, but I left some comments here. Let me know how does it look.
This handler is mostly responsible for reading data and packaging them up into frames.
send(data: greeting) | ||
} | ||
|
||
private func stateDidChange(to state: IBConnection.State) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is not Network from MacOs we manage the state ourselves. Not sure if you want to do anything with it
_ = channel.writeAndFlush(buffer) | ||
} | ||
|
||
public func receiveMessage(_ data: Data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being called, by our 2nd Handler that handles frames from the 1st handler. If that make sense.
and I understand we 1st need to get the initial frame after the greeting. otherwise we read data as usual
import Foundation | ||
import NIOCore | ||
|
||
class IBMessageHandler: ChannelInboundHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is our massage handler, that simply converts frames in data and we pass them to our IBConnection
# Conflicts: # .DS_Store # .gitignore
To get us into same page i included your proposal as NIOClient etc into the dev branch. Hopefully didn't miss anything crucial. At the moment it seems to stuck at opening connection though and never reach connected state to write the greeting message. |
@stensoosaar |
@stensoosaar let me convert this PR into draft. Till I fix the connection so it is reliable. |
@stensoosaar PR ready for review :) connection is working! |
} | ||
|
||
let lengthPrefix = buffer.getInteger(at: buffer.readerIndex, as: Int32.self)! | ||
let frameLength = Int(lengthPrefix.littleEndian) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move TCP connection away from Mac Network lib over to swift-nio enabling, by doing this we enable framework to work wherever Swift does. such as Linux, Windows, even server side.
@stensoosaar
I've tried to keep everything as you had with modifying the connection layer in most.
I haven't had a chance to test it with the IB as IU will get my access back after 15th next month. I'm counting here on your help.
I will leave comments below to address what I think is important.
Let me know what you think :)!