...
 
Commits (3)
......@@ -3,7 +3,6 @@ import CocoaAsyncSocket
public struct Announcement : XdrWritable, XdrReadable {
public static let magic : UInt32 = 0x9D79BC39
public static let ipv4BroadcastPort : UInt16 = 21025
public var thisDevice : Device
public var extraDevices : [Device]
......@@ -80,7 +79,7 @@ public struct Announcement : XdrWritable, XdrReadable {
public struct Address : XdrWritable, XdrReadable {
public var ip : [UInt8] = []
public var port : UInt16 = Announcement.ipv4BroadcastPort
public var port : UInt16 = Greeter.ipv4BroadcastPort
public init() {}
public init(port:UInt16) { self.port = port }
public init(ip:(b1:UInt8,b2:UInt8,b3:UInt8,b4:UInt8)) {
......
This diff is collapsed.
......@@ -3,21 +3,28 @@ import CocoaAsyncSocket
class UdpSocketSpy : GCDAsyncUdpSocket {
var boundLocalPort: UInt16 = 0
var boundInterface: String = ""
var lastToHost: String = ""
var lastToPort: UInt16 = 0
var sentData: [UInt8] = []
var sentData: NSData? = nil
var begunReceiving: Bool = false
var broadcastEnabled: Bool = false
var lastJoinedGroup: String = ""
var lastJoinedInterface: String = ""
override func bindToPort(port: UInt16) throws {
boundLocalPort = port
}
override func bindToPort(port: UInt16, interface: String!) throws {
boundLocalPort = port
boundInterface = interface
}
override func sendData(data: NSData!, toHost host: String!, port: UInt16, withTimeout timeout: NSTimeInterval, tag: Int) {
lastToHost = host
lastToPort = port
sentData = [UInt8](count: data.length, repeatedValue: 0)
data.getBytes(&sentData, length: data.length)
sentData = data
}
override func beginReceiving() throws {
......@@ -27,5 +34,10 @@ class UdpSocketSpy : GCDAsyncUdpSocket {
override func enableBroadcast(flag: Bool) throws {
broadcastEnabled = flag
}
override func joinMulticastGroup(group: String!, onInterface interface: String!) throws {
lastJoinedGroup = group
lastJoinedInterface = interface
}
}
\ No newline at end of file