Skip to main content
Version: 1.2

Short data

LINE Planet provides APIs that let you send a limited size of data ("short data") to peers during communications. This page describes how to send and receive short data by call type.

Supported call typeSupported SDK version
1-to-1 call, group call1.2

Common features​

The following applies to sending short data regardless of call types.

Size limitation​

The methods to send short data accept the type of the data along with the data itself. The maximum sizes for the data type and the data are as follows:

  • Data type: 100 bytes (including the null termination character)
  • Data: 800 bytes

Retrieving the result of sending short data​

sendShortData() returns a Future<bool> indicating whether the transmission request was accepted by the native SDK. A false result means the request was rejected before transmission (for example, due to an invalid size). Network-level delivery failures are not reported separately.

1-to-1 call​

In 1-to-1 calls, you can send and receive short data as follows.

Sending short data​

To send short data to the call peer, use sendShortData() of PlanetKitCall.

Future<bool> sendShortDataExample(PlanetKitCall call, String type, String data) async {
final byteData = Uint8List.fromList(utf8.encode(data));

final success = await call.sendShortData(type: type, data: byteData);
if (success) {
print('sendShortData succeeded: type=$type, data=$data');
} else {
print('sendShortData failed');
}
return success;
}

Handling received short data​

The peer can receive the short data through onShortDataReceived of PlanetKitCallEventHandler.

final eventHandler = PlanetKitCallEventHandler(
// ... other required callbacks ...
onShortDataReceived: (PlanetKitCall call, String type, Uint8List data) {
// This is called when short data is received from the peer.
final receivedData = utf8.decode(data);
print('Received short data: type=$type, data=$receivedData');
// Write your own code here to handle the received data.
},
);

Group call​

In group calls, you can send short data to a specific peer or all peers.

Sending short data to a specific peer​

To send short data to a specific peer, use sendShortDataToPeer() of PlanetKitConference.

Future<bool> sendShortDataToSpecificPeerExample(
PlanetKitConference conference,
PlanetKitUserId peerId,
String type,
String data,
) async {
final byteData = Uint8List.fromList(utf8.encode(data));

final success = await conference.sendShortDataToPeer(
peerId: peerId,
type: type,
data: byteData,
);
if (success) {
print('sendShortDataToPeer succeeded: type=$type, data=$data');
} else {
print('sendShortDataToPeer failed');
}
return success;
}

Sending short data to all peers​

To send short data to all peers, use sendShortData() of PlanetKitConference.

Future<bool> sendShortDataToAllPeersExample(
PlanetKitConference conference,
String type,
String data,
) async {
final byteData = Uint8List.fromList(utf8.encode(data));

final success = await conference.sendShortData(type: type, data: byteData);
if (success) {
print('sendShortData to all peers succeeded: type=$type, data=$data');
} else {
print('sendShortData failed');
}
return success;
}

Handling received short data​

The peers can receive the short data through onShortDataReceived of PlanetKitConferenceEventHandler.

final eventHandler = PlanetKitConferenceEventHandler(
// ... other required callbacks ...
onShortDataReceived: (
PlanetKitConference conference,
PlanetKitUserId senderId,
String type,
Uint8List data,
) {
// This is called when short data is received from a peer in the conference.
final receivedData = utf8.decode(data);
print('Received short data from ${senderId.userId}: type=$type, data=$receivedData');
// Write your own code here to handle the received data.
},
);

APIs related to sending short data are as follows.

1-to-1 call​

Methods​

Events​

Group call​

Methods​

Events​