package com.zeiss.sughoshkumar.watchmouse;

import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;
import com.zeiss.sughoshkumar.senderobject.SenderObject;

import java.io.IOException;
import java.net.UnknownHostException;

/**
 * Created by sughoshkumar on 26/08/15.
 */
public class ListenerService extends WearableListenerService {
    @Override
    public void onMessageReceived(MessageEvent messageEvent) {
        String path = messageEvent.getPath();
        System.out.println(" Message. Path : " + path + " received");
        byte[] data = messageEvent.getData();
        SenderObject object = null;
        try {
             object = SenderObject.parseFrom(data);
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        float x = object.getX();
        float y = object.getY();
        int type = object.getType();
        int modality = object.getModality();
        System.out.println("x : " + x + " y : " + y + "type : " + type + "modality " + object.getModality(modality));
        try {
            UDPClient client = new UDPClient(ListenerService.this, "172.16.10.49", 8085, data);
            client.execute();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}

@@ -393,17 +393,16 @@
 ce %7B%0A   
- 
 @Overrid
@@ -1104,32 +1104,227 @@
 ;%0A        try %7B%0A
+            if (PhoneMainActivity.isConnected) %7B%0A                System.out.println(%22Sending from the listener to IP : %22 + PhoneMainActivity.ipAddress + %22 port : %22 + PhoneMainActivity.port);%0A    
             UDPC
@@ -1378,28 +1378,59 @@
 is, 
-%22172.16.10.49%22, 8085
+PhoneMainActivity.ipAddress, PhoneMainActivity.port
 , da
@@ -1446,16 +1446,20 @@
         
+ 
+   
 client.e
@@ -1464,24 +1464,38 @@
 .execute();%0A
+            %7D%0A
         %7D ca

Update ListenerService.java