2018-11-07 12:24:35 -08:00
|
|
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
2017-03-01 13:54:32 +01:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package io.flutter.plugin.common;
|
|
|
|
|
|
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
|
|
|
|
|
|
/**
|
2017-04-28 23:31:11 +02:00
|
|
|
* A {@link MessageCodec} using unencoded binary messages, represented as
|
|
|
|
|
* {@link ByteBuffer}s.
|
|
|
|
|
*
|
|
|
|
|
* <p>This codec is guaranteed to be compatible with the corresponding
|
|
|
|
|
* <a href="https://docs.flutter.io/flutter/services/BinaryCodec-class.html">BinaryCodec</a>
|
|
|
|
|
* on the Dart side. These parts of the Flutter SDK are evolved synchronously.</p>
|
|
|
|
|
*
|
|
|
|
|
* <p>On the Dart side, messages are represented using {@code ByteData}.</p>
|
2017-03-01 13:54:32 +01:00
|
|
|
*/
|
2017-03-17 09:04:59 +01:00
|
|
|
public final class BinaryCodec implements MessageCodec<ByteBuffer> {
|
2017-03-01 13:54:32 +01:00
|
|
|
// This codec must match the Dart codec of the same name in package flutter/services.
|
2017-03-17 09:04:59 +01:00
|
|
|
public static final BinaryCodec INSTANCE = new BinaryCodec();
|
2017-03-01 13:54:32 +01:00
|
|
|
|
2017-03-17 09:04:59 +01:00
|
|
|
private BinaryCodec() {
|
2017-03-01 13:54:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ByteBuffer encodeMessage(ByteBuffer message) {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ByteBuffer decodeMessage(ByteBuffer message) {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
}
|