mirror of
https://github.com/Karmaz95/Snake_Apple.git
synced 2026-06-02 17:41:35 +02:00
18 lines
715 B
Objective-C
18 lines
715 B
Objective-C
// server.m
|
|
// clang -framework Foundation server.m -o server
|
|
#import <Foundation/Foundation.h>
|
|
|
|
static CFDataRef callback(CFMessagePortRef port, SInt32 msgid, CFDataRef data, void *info) {
|
|
NSLog(@"Received: %@", [[NSString alloc] initWithData:(__bridge NSData *)data encoding:NSUTF8StringEncoding]);
|
|
return NULL;
|
|
}
|
|
|
|
int main() {
|
|
@autoreleasepool {
|
|
CFMessagePortRef port = CFMessagePortCreateLocal(NULL, CFSTR("com.crimson.message_service"), callback, NULL, NULL);
|
|
CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(NULL, port, 0);
|
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
|
|
[[NSRunLoop currentRunLoop] run];
|
|
}
|
|
return 0;
|
|
} |