Example #1
0
    private void SendFirstData()
    {
        List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
        Dictionary<string, object> dic = new Dictionary<string, object>();
        float lat = Input.location.lastData.latitude;
        float lon = Input.location.lastData.longitude;
        double[] datas = GPSTools.gps84_To_Gcj02(lat, lon);

        dic.Add("lat", datas[0]);
        dic.Add("lon", datas[1]);
        dic.Add("userName", LoginInfo.Userinfo.name);
        list.Add(dic);
        Show(Utils.CollectionsConvert.ToJSON(list));
    }
Example #2
0
    private void ShowData()
    {
        double _lat = 0.0;
        double _lon = 0.0;

        if (PlayerPrefs.GetFloat("fenceLat") <= 0)
        {
            float    lat   = Input.location.lastData.latitude;
            float    lon   = Input.location.lastData.longitude;
            double[] datas = GPSTools.gps84_To_Gcj02(lat, lon);

            _lat = datas[0];
            _lon = datas[1];
        }
        else
        {
            _lat = PlayerPrefs.GetFloat("fenceLat");
            _lon = PlayerPrefs.GetFloat("fenceLon");
        }


        string grounpId    = PlayerPrefs.GetString("grounpId");
        int    fenceRadius = PlayerPrefs.GetInt("fenceRadius");

        if (string.IsNullOrEmpty(grounpId))
        {
            grounpId = "96";
        }
        Dictionary <string, object> dic = new Dictionary <string, object>();

        dic.Add("grounpId", grounpId);
        dic.Add("fenceRadius", fenceRadius);
        dic.Add("lat", _lat);
        dic.Add("lon", _lon);
        dic.Add("ip", Config.parse("ServerIP"));
        string json         = Utils.CollectionsConvert.ToJSON(dic);
        string functionName = "CreateMap" + "(" + json + ")";

        //不能传递多个参数,网页插件有限制
        GetComponent <UniWebView>().EvaluateJavaScript(functionName);
    }
Example #3
0
 private void SendData()
 {
     //  TestData();
   //  MessageShow.instance.ShowMesage("isEnabledByUser="******":"+ Application.internetReachability);
     if (Input.location.isEnabledByUser && Application.internetReachability != NetworkReachability.NotReachable)
     {
         
         float lat = Input.location.lastData.latitude;
         float lon = Input.location.lastData.longitude;
         double[] datas = GPSTools.gps84_To_Gcj02(lat, lon);
         double _lat = datas[0];
         double _lon = datas[1];
         GPSItem gpsItem = new GPSItem();
        // gpsItem.telephone = LoginInfo.Userinfo.telephone;
         gpsItem.userName = LoginInfo.Userinfo.name;
         gpsItem.userId = LoginInfo.Userinfo.id;
         gpsItem.lat = _lat;
         gpsItem.lon = _lon;
         gpsItem.userType = LoginInfo.Userinfo.type;
         string json = Utils.CollectionsConvert.ToJSON(gpsItem);
         string sendData = CommandName.UpdatePosition.ToString() + Constant.START_SPLIT + json;
         SocketService.instance.SendData(sendData);
     }
     else
     {
         GPSItem gpsItem = new GPSItem();
         // gpsItem.telephone = LoginInfo.Userinfo.telephone;
         gpsItem.userName = LoginInfo.Userinfo.name;
         gpsItem.userId = LoginInfo.Userinfo.id;
         gpsItem.lat = 34.218229;
         gpsItem.lon = 108.964176;
         gpsItem.userType = LoginInfo.Userinfo.type;
         string json = Utils.CollectionsConvert.ToJSON(gpsItem);
         string sendData = CommandName.UpdatePosition.ToString() + Constant.START_SPLIT + json;
         SocketService.instance.SendData(sendData);
     }
 }
Example #4
0
    public object ExecuteCommand(string body, string[] parameter)
    {
        Dictionary <string, object> resultDic = Utils.CollectionsConvert.ToObject <Dictionary <string, object> >(body);
        string         gpsJson  = Utils.CollectionsConvert.ToJSON(resultDic["gpsData"]);
        List <GPSItem> gpsItems = Utils.CollectionsConvert.ToObject <List <GPSItem> >(gpsJson);

        string grounpJson = Utils.CollectionsConvert.ToJSON(resultDic["grounp"]);

        Grounp grounp = Utils.CollectionsConvert.ToObject <Grounp>(grounpJson);

        string roomJson = Utils.CollectionsConvert.ToJSON(resultDic["room"]);
        Room   room     = Utils.CollectionsConvert.ToObject <Room>(roomJson);


        string lifeJson = Utils.CollectionsConvert.ToJSON(resultDic["life"]);
        Life   life     = Utils.CollectionsConvert.ToObject <Life>(lifeJson);


        if (grounp == null)
        {
            grounp = new Grounp();
        }
        //if (gpsItems==null || gpsItems.Count==0)
        //{
        //   // MessageShow.instance.ShowMesage("发送数据为空");
        //    return null;
        //}
        GPSItem currentUser = null;

        for (int i = 0; gpsItems != null && i < gpsItems.Count; i++)
        {
            if (gpsItems[i].userId.Equals(LoginInfo.Userinfo.id))
            {
                gpsItems[i].color = colors[0];
                currentUser       = gpsItems[i];
            }
            else
            {
                gpsItems[i].color = colors[1];
            }
        }
        if (currentUser == null)
        {
            currentUser = new GPSItem();
            float    lat   = Input.location.lastData.latitude;
            float    lon   = Input.location.lastData.longitude;
            double[] datas = GPSTools.gps84_To_Gcj02(lat, lon);
            currentUser.lat      = datas[0];
            currentUser.lon      = datas[1];
            currentUser.userId   = LoginInfo.Userinfo.id;
            currentUser.userName = LoginInfo.Userinfo.name;
            currentUser.userType = 1;
        }

        Dictionary <string, object> result = new Dictionary <string, object>();

        result.Add("currentUser", currentUser);
        result.Add("gpsData", gpsItems);
        result.Add("grounp", grounp);
        result.Add("room", room);
        result.Add("life", life);
        result.Add("ip", Config.parse("ServerIP"));

        string sendJson = Utils.CollectionsConvert.ToJSON(result);

        //Debug.Log(sendJson);
        ShowMapPoint.instacne.Show(Utils.CollectionsConvert.ToJSON(sendJson));
        return(null);
    }