Commit 66e6295d by Dapperstout

Send "Hello" upon connection. Fails currently because Syncthing switched away…

Send "Hello" upon connection. Fails currently because Syncthing switched away from XDR in favor of proto3.
parent deed2158
public protocol Connection {
func send(hello: Hello)
func send(message: Message)
func disconnect()
}
\ No newline at end of file
}
......@@ -17,7 +17,12 @@ class SocketConnection: NSObject, GCDAsyncSocketDelegate, Connection {
self.socket.synchronouslySetDelegate(self)
readHeader()
}
func send(hello: Hello) {
let data = NSData(bytes: hello.serialize())
self.socket.writeData(data, withTimeout: -1, tag: 0)
}
func send(message: Message) {
let data = NSData(bytes: message.encode().serialize())
self.socket.writeData(data, withTimeout:-1, tag: 0)
......
......@@ -49,6 +49,11 @@ class ConnectionIntegrationTests: QuickSpec {
onConnection: {
connection = $0
if connection != nil {
connection!.send(Hello(
deviceName: "my device",
clientName: "pulse-swift",
clientVersion: "0.1"
))
connection!.send(ClusterConfig(
clientName:"pulse-swift",
clientVersion:"0.1",
......
......@@ -134,7 +134,11 @@ class SynchronizationTests: QuickSpec {
class ConnectionSpy: Connection {
var sent = [Message]()
func send(hello: Hello) {
}
func send(message: Message) {
sent.append(message)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment