forked from Blendman974/faceclaw
iOS porting: Battery indicators, app icon, add the rest of the apps
This commit is contained in:
1 parent
00a5e38f75
commit
e5ba7abc18
31 files changed
+501
-65
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "FaceclawSocket.h"
|
||||
int main(int argc, const char **argv) {
|
||||
@autoreleasepool {
|
||||
FaceclawSocket *socket = [[FaceclawSocket alloc] initWithURL:[NSString stringWithUTF8String:argv[1]]];
|
||||
BOOL opened = NO, echoed = NO, closed = NO;
|
||||
NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while (!closed && deadline.timeIntervalSinceNow > 0) {
|
||||
NSArray *events = [NSJSONSerialization JSONObjectWithData:[[socket takeEvents] dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
|
||||
for (NSDictionary *event in events) {
|
||||
NSString *kind = event[@"kind"];
|
||||
if ([kind isEqual:@"open"]) { opened = YES; [socket sendText:@"Faceclaw echo: π 🔋"]; }
|
||||
if ([kind isEqual:@"text"]) echoed = [event[@"text"] isEqual:@"Faceclaw echo: π 🔋"];
|
||||
if ([kind isEqual:@"closed"] || [kind isEqual:@"error"]) closed = YES;
|
||||
}
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
|
||||
}
|
||||
[socket close];
|
||||
if (!opened || !echoed || !closed) { NSLog(@"FAIL open=%d echo=%d close=%d", opened, echoed, closed); return 1; }
|
||||
puts("PASS: native WebSocket opens, echoes UTF-8 and reports close");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user