Created
November 28, 2012 13:20
-
-
Save cthree/4161228 to your computer and use it in GitHub Desktop.
Example crashes CocoaAsyncSocket in rubymotion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@payload = "M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250\r\nMAN: ssdp:discover\r\nST: upnp:rootdevice\r\n" | |
@socket = GCDAsyncUdpSocket.alloc.initWithDelegate(self, delegateQueue:Dispatch::Queue.main) | |
@socket.bindToPort(1900, error:nil) | |
@socket.beginReceiving(nil) | |
puts "Socket Ready" | |
@socket.sendData(@payload.dataUsingEncoding(NSUTF8StringEncoding), | |
toHost:"239.255.255.250", | |
port:1900, | |
withTimeout:-1, | |
tag:0) | |
puts "SSDP M-SEARCH Message Sent" | |
true | |
end | |
def udpSocket(socket, didReceiveData:data, fromAddress:address, withFilterContext:filterContext) | |
puts "Message Received: #{data}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment