Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FlutterBinaryMessenger.h 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2013 The Flutter Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef FLUTTER_FLUTTERBINARYMESSENGER_H_
  5. #define FLUTTER_FLUTTERBINARYMESSENGER_H_
  6. #import <Foundation/Foundation.h>
  7. #include "FlutterMacros.h"
  8. NS_ASSUME_NONNULL_BEGIN
  9. /**
  10. * A message reply callback.
  11. *
  12. * Used for submitting a binary reply back to a Flutter message sender. Also used
  13. * in for handling a binary message reply received from Flutter.
  14. *
  15. * @param reply The reply.
  16. */
  17. typedef void (^FlutterBinaryReply)(NSData* _Nullable reply);
  18. /**
  19. * A strategy for handling incoming binary messages from Flutter and to send
  20. * asynchronous replies back to Flutter.
  21. *
  22. * @param message The message.
  23. * @param reply A callback for submitting an asynchronous reply to the sender.
  24. */
  25. typedef void (^FlutterBinaryMessageHandler)(NSData* _Nullable message, FlutterBinaryReply reply);
  26. /**
  27. * A facility for communicating with the Flutter side using asynchronous message
  28. * passing with binary messages.
  29. *
  30. * Implementated by:
  31. * - `FlutterBasicMessageChannel`, which supports communication using structured
  32. * messages.
  33. * - `FlutterMethodChannel`, which supports communication using asynchronous
  34. * method calls.
  35. * - `FlutterEventChannel`, which supports commuication using event streams.
  36. */
  37. FLUTTER_EXPORT
  38. @protocol FlutterBinaryMessenger <NSObject>
  39. /**
  40. * Sends a binary message to the Flutter side on the specified channel, expecting
  41. * no reply.
  42. *
  43. * @param channel The channel name.
  44. * @param message The message.
  45. */
  46. - (void)sendOnChannel:(NSString*)channel message:(NSData* _Nullable)message;
  47. /**
  48. * Sends a binary message to the Flutter side on the specified channel, expecting
  49. * an asynchronous reply.
  50. *
  51. * @param channel The channel name.
  52. * @param message The message.
  53. * @param callback A callback for receiving a reply.
  54. */
  55. - (void)sendOnChannel:(NSString*)channel
  56. message:(NSData* _Nullable)message
  57. binaryReply:(FlutterBinaryReply _Nullable)callback
  58. // TODO: Add macOS support for replies once
  59. // https://github.com/flutter/flutter/issues/18852 is fixed.
  60. API_UNAVAILABLE(macos);
  61. /**
  62. * Registers a message handler for incoming binary messages from the Flutter side
  63. * on the specified channel.
  64. *
  65. * Replaces any existing handler. Use a `nil` handler for unregistering the
  66. * existing handler.
  67. *
  68. * @param channel The channel name.
  69. * @param handler The message handler.
  70. */
  71. - (void)setMessageHandlerOnChannel:(NSString*)channel
  72. binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler;
  73. @end
  74. NS_ASSUME_NONNULL_END
  75. #endif // FLUTTER_FLUTTERBINARYMESSENGER_H_