Add EveCanvas dialogue ack
This commit is contained in:
parent
924e8db71c
commit
d8e2c15db6
3 changed files with 35 additions and 5 deletions
|
|
@ -18,6 +18,7 @@
|
|||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didReceiveVideoAccessUnit:(NSData *)data;
|
||||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didReceiveViewportWidth:(CGFloat)width height:(CGFloat)height scale:(CGFloat)scale;
|
||||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didReceiveCodec:(NSString *)codec;
|
||||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didReceiveDialogueText:(NSString *)text;
|
||||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didChangeStatus:(NSString *)status;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -52,16 +52,20 @@
|
|||
}
|
||||
|
||||
- (void)sendPointerPhase:(NSString *)phase x:(CGFloat)x y:(CGFloat)y {
|
||||
if (!self.task) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *payload = @{
|
||||
@"type": @"pointer",
|
||||
@"phase": phase,
|
||||
@"x": @(x),
|
||||
@"y": @(y),
|
||||
};
|
||||
[self sendJSONObject:payload failureStatus:@"input send failed"];
|
||||
}
|
||||
|
||||
- (void)sendJSONObject:(NSDictionary *)payload failureStatus:(NSString *)failureStatus {
|
||||
if (!self.task) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSData *json = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil];
|
||||
if (!json) {
|
||||
return;
|
||||
|
|
@ -71,7 +75,7 @@
|
|||
NSURLSessionWebSocketMessage *message = [[NSURLSessionWebSocketMessage alloc] initWithString:text];
|
||||
[self.task sendMessage:message completionHandler:^(NSError *error) {
|
||||
if (error) {
|
||||
[self publishStatus:@"input send failed"];
|
||||
[self publishStatus:failureStatus ?: @"send failed"];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
|
@ -139,6 +143,22 @@
|
|||
}
|
||||
[self.delegate frameStreamClient:self didChangeStatus:@"stream live"];
|
||||
});
|
||||
} else if ([message[@"type"] isEqualToString:@"dialogue"]) {
|
||||
NSString *text = message[@"text"];
|
||||
if (![text isKindOfClass:NSString.class]) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.delegate frameStreamClient:self didReceiveDialogueText:text];
|
||||
});
|
||||
NSDictionary *ack = @{
|
||||
@"type": @"dialogue-ack",
|
||||
@"device": @"eve",
|
||||
@"text": text,
|
||||
@"status": @"seen",
|
||||
};
|
||||
[self sendJSONObject:ack failureStatus:@"dialogue ack failed"];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ static int64_t EVEHostTimeNowNs(void) {
|
|||
@property(nonatomic, assign) CGFloat streamScale;
|
||||
@property(nonatomic, copy) NSString *streamStatus;
|
||||
@property(nonatomic, copy) NSString *streamCodec;
|
||||
@property(nonatomic, copy) NSString *dialogueLine;
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -103,6 +104,7 @@ static int64_t EVEHostTimeNowNs(void) {
|
|||
self.streamScale = 2.0;
|
||||
self.streamStatus = @"stream idle";
|
||||
self.streamCodec = @"jpeg";
|
||||
self.dialogueLine = @"awaiting Mimir";
|
||||
NSArray<NSURL *> *streamURLs = @[
|
||||
[NSURL URLWithString:@"ws://127.0.0.1:8792/stream"],
|
||||
[NSURL URLWithString:@"ws://192.168.1.66:8792/stream"],
|
||||
|
|
@ -185,6 +187,7 @@ static int64_t EVEHostTimeNowNs(void) {
|
|||
"CEF stream + native touch\n"
|
||||
"%@\n"
|
||||
"codec %@\n"
|
||||
"Mimir: %@\n"
|
||||
"points %.0fx%.0f pixels %.0fx%.0f @ %.1fx\n"
|
||||
"stream %.0fx%.0f @ %.1fx\n"
|
||||
"fps %.1f touches %lu\n"
|
||||
|
|
@ -193,6 +196,7 @@ static int64_t EVEHostTimeNowNs(void) {
|
|||
"gyro %+0.2f %+0.2f %+0.2f",
|
||||
self.streamStatus ?: @"stream",
|
||||
self.streamCodec ?: @"unknown",
|
||||
self.dialogueLine ?: @"",
|
||||
points.width, points.height, pixels.width, pixels.height, scale,
|
||||
self.streamViewportSize.width, self.streamViewportSize.height, self.streamScale,
|
||||
self.filteredFPS, (unsigned long)self.touchCount,
|
||||
|
|
@ -446,6 +450,11 @@ static int64_t EVEHostTimeNowNs(void) {
|
|||
self.streamCodec = codec;
|
||||
}
|
||||
|
||||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didReceiveDialogueText:(NSString *)text {
|
||||
(void)client;
|
||||
self.dialogueLine = text;
|
||||
}
|
||||
|
||||
- (void)frameStreamClient:(EVEFrameStreamClient *)client didChangeStatus:(NSString *)status {
|
||||
(void)client;
|
||||
self.streamStatus = status;
|
||||
|
|
|
|||
Loading…
Reference in a new issue