|
|
|
@ -40,7 +40,6 @@ class _MyBodyState extends State<Body> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
// TODO: implement build
|
|
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
@ -71,34 +70,7 @@ class _MyBodyState extends State<Body> {
|
|
|
|
|
userName,
|
|
|
|
|
strategy,
|
|
|
|
|
onConnectionInitiated: (id, info) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (builder) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text("id: " + id),
|
|
|
|
|
Text("Token: " + info.authenticationToken),
|
|
|
|
|
Text("Name" + info.endpointName),
|
|
|
|
|
Text("Incoming: " +
|
|
|
|
|
info.isIncomingConnection.toString()),
|
|
|
|
|
RaisedButton(
|
|
|
|
|
child: Text("Accept Connection"),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Nearby().acceptConnection(id);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
RaisedButton(
|
|
|
|
|
child: Text("Reject Connection"),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Nearby().rejectConnection(id);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
oci(id, info);
|
|
|
|
|
},
|
|
|
|
|
onConnectionResult: (id, status) {
|
|
|
|
|
showSnackbar(status);
|
|
|
|
@ -145,53 +117,7 @@ class _MyBodyState extends State<Body> {
|
|
|
|
|
userName,
|
|
|
|
|
id,
|
|
|
|
|
onConnectionInitiated: (id, info) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (builder) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text("id: " + id),
|
|
|
|
|
Text("Token: " +
|
|
|
|
|
info.authenticationToken),
|
|
|
|
|
Text(
|
|
|
|
|
"Name" + info.endpointName),
|
|
|
|
|
Text("Incoming: " +
|
|
|
|
|
info.isIncomingConnection
|
|
|
|
|
.toString()),
|
|
|
|
|
RaisedButton(
|
|
|
|
|
child:
|
|
|
|
|
Text("Accept Connection"),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
cId = id;
|
|
|
|
|
Nearby().acceptConnection(
|
|
|
|
|
id,
|
|
|
|
|
onPayLoadRecieved:
|
|
|
|
|
(id, bytes) {
|
|
|
|
|
showSnackbar(id +
|
|
|
|
|
": " +
|
|
|
|
|
String
|
|
|
|
|
.fromCharCodes(
|
|
|
|
|
bytes));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
RaisedButton(
|
|
|
|
|
child:
|
|
|
|
|
Text("Reject Connection"),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
Nearby()
|
|
|
|
|
.rejectConnection(id);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
oci(id, info);
|
|
|
|
|
},
|
|
|
|
|
onConnectionResult: (id, status) {
|
|
|
|
|
showSnackbar(status);
|
|
|
|
@ -234,7 +160,7 @@ class _MyBodyState extends State<Body> {
|
|
|
|
|
child: Text("Send Random Payload"),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
String a = Random().nextInt(100).toString();
|
|
|
|
|
showSnackbar("Sending $a");
|
|
|
|
|
showSnackbar("Sending $a to $cId");
|
|
|
|
|
Nearby().sendPayload(cId, Uint8List.fromList(a.codeUnits));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
@ -248,4 +174,43 @@ class _MyBodyState extends State<Body> {
|
|
|
|
|
content: Text(a.toString()),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void oci(String id, ConnectionInfo info) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (builder) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text("id: " + id),
|
|
|
|
|
Text("Token: " + info.authenticationToken),
|
|
|
|
|
Text("Name" + info.endpointName),
|
|
|
|
|
Text("Incoming: " + info.isIncomingConnection.toString()),
|
|
|
|
|
RaisedButton(
|
|
|
|
|
child: Text("Accept Connection"),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
cId = id;
|
|
|
|
|
Nearby().acceptConnection(
|
|
|
|
|
id,
|
|
|
|
|
onPayLoadRecieved: (endid, bytes) {
|
|
|
|
|
showSnackbar(endid + ": " + String.fromCharCodes(bytes));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
RaisedButton(
|
|
|
|
|
child: Text("Reject Connection"),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
Nearby().rejectConnection(id);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|