import 'dart:convert';

import 'package:flutter_map/flutter_map.dart';
import 'package:location/socket/base_message.dart';

import 'message_data.dart';

class LocationMessage extends BaseMessage {
  static LocationMessage? message;

  static String obtainMessage(MapLocation location, String? network) {
    message ??= LocationMessage();
    message!.cmd = "u.location";
    message!.data = jsonEncode(MessageData(
      longitude: location.longitude,
      latitude: location.latitude,
      speed: location.speed,
      bearing: location.bearing,
      address: location.address,
      network: network,
    ).toJson());
    return jsonEncode(message!.toJson());
  }
}
