예제 #1
0
        private static void run()
        {
            try {
            TcpClient socketClient = new TcpClient();

            Console.WriteLine("Connecting to phone...");
            socketClient.Connect(new IPEndPoint(IPAddress.Parse(LOCALHOST), PORT));
            StreamReader reader = new StreamReader(socketClient.GetStream());
            Console.WriteLine("Connection Established");

            while (!reader.EndOfStream) {
              string line = reader.ReadLine();
              Console.WriteLine("Response: {0}", line);
              DataContractJsonSerializer deserialize = new DataContractJsonSerializer(typeof(Response));
              MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(line));
              Response response = deserialize.ReadObject(stream) as Response;

              Console.WriteLine("Parsed Response: {0} {1} {2}", response.latitude, response.longitude, response.location);
              Location location;
              if (response.location == "") {
            location = new Location(response.latitude, response.longitude);
              } else {
            location = new Location(response.location);
              }
              if (location != null && location.success) {
            model.rotateTo(location.latitude, location.longitude);
              }
            }
            reader.Close();
            socketClient.Close();
              } catch (Exception e) {
            Console.WriteLine(e.Message);
            Console.WriteLine(e.StackTrace);
              }
        }
예제 #2
0
 private void jumpToLocation(Location location)
 {
     if (location.success) {
     model.rotateTo(location.latitude, location.longitude);
       }
 }