forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flutter channels for iOS (flutter#3470)
Flutter channels now also supported on iOS. Use FlutterMessageChannel or FlutterMethodChannel with binary/string/json/standard codecs.
- Loading branch information
1 parent
65fcbf7
commit b97103b
Showing
25 changed files
with
1,431 additions
and
150 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_BUFFER_CONVERSIONS_H_ | ||
#define FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_BUFFER_CONVERSIONS_H_ | ||
|
||
#include <Foundation/Foundation.h> | ||
|
||
#include <vector> | ||
|
||
namespace shell { | ||
|
||
std::vector<uint8_t> GetVectorFromNSData(NSData* data); | ||
|
||
NSData* GetNSDataFromVector(const std::vector<uint8_t>& buffer); | ||
|
||
} // namespace shell | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_BUFFER_CONVERSIONS_H_ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2016 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/darwin/common/buffer_conversions.h" | ||
|
||
namespace shell { | ||
|
||
std::vector<uint8_t> GetVectorFromNSData(NSData* data) { | ||
if (!data.length) | ||
return std::vector<uint8_t>(); | ||
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data.bytes); | ||
return std::vector<uint8_t>(bytes, bytes + data.length); | ||
} | ||
|
||
NSData* GetNSDataFromVector(const std::vector<uint8_t>& buffer) { | ||
return [NSData dataWithBytes:buffer.data() length:buffer.size()]; | ||
} | ||
|
||
} // namespace shell |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
29 changes: 29 additions & 0 deletions
29
shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_FLUTTERBINARYMESSAGES_H_ | ||
#define FLUTTER_FLUTTERBINARYMESSAGES_H_ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#include "FlutterMacros.h" | ||
|
||
typedef void (^FlutterBinaryReplyHandler)(NSData* reply); | ||
typedef void (^FlutterBinaryMessageHandler)( | ||
NSData* message, | ||
FlutterBinaryReplyHandler replyHandler); | ||
|
||
FLUTTER_EXPORT | ||
@protocol FlutterBinaryMessenger<NSObject> | ||
- (void)sendBinaryMessage:(NSData*)message channelName:(NSString*)channelName; | ||
|
||
- (void)sendBinaryMessage:(NSData*)message | ||
channelName:(NSString*)channelName | ||
binaryReplyHandler:(FlutterBinaryReplyHandler)handler; | ||
|
||
- (void)setBinaryMessageHandlerOnChannel:(NSString*)channelName | ||
binaryMessageHandler:(FlutterBinaryMessageHandler)handler; | ||
@end | ||
|
||
#endif // FLUTTER_FLUTTERBINARYMESSAGES_H_ |
Oops, something went wrong.