Hello,

i want to develop an app for controlling my Windows Media Center with
my Android phone. Therefore i use the vmccontroller plugin (http://
vmccontroller.codeplex.com/Release/ProjectReleases.aspx?
ReleaseId=23251). With this plugin i can controll my MediaCenter by
sending Strings like "button-up" through sockets to the MediaCenter.
Also it is possible to get data from the MediaCenter, like all
artists.

My problem ist getting data through sockets. This is my code:

public class Connector implements Runnable{
        static final String IP = "192.168.2.33";
        //static final String IP = "192.168.1.92";
        static final int PORT = 40500;

        //system
        public static final String ALIVE = "version";

        //general
        public static final String UP = "button-up";
        public static final String RIGHT = "button-right";
        public static final String DOWN = "button-down";
        public static final String LEFT = "button-left";
        public static final String OK = "button-ok";
        public static final String BACK = "button-back";

        //music
        public static final String ARTISTS = "list-artists";

        static Socket s;
        static BufferedReader reader;
        static PrintWriter writer;

        public static void createConnection(){
                try {
                        s = new Socket(IP, PORT);
                        reader = new BufferedReader(new 
InputStreamReader(s.getInputStream
()));
                        writer = new PrintWriter(new BufferedWriter(new 
OutputStreamWriter
(s.getOutputStream())), true);
                } catch (UnknownHostException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                }
        }

        public static String sendMessage(String message){
                if(s == null){
                        createConnection();
                }

                String response = null;
                try {
                        writer.println(message);
                        response = reader.readLine();
                        Log.v(message,response);
                } catch (IOException e) {
                        e.printStackTrace();
                }

                return response;
        }

        public static void closeConnection(){
                writer.println("END");
                try {
                        reader.close();
                        writer.close();
                        s.close();
                } catch (IOException e) {
                        e.printStackTrace();
                }
        }

        @Override
        public void run() {
                createConnection();
                sendMessage(ARTISTS);
                closeConnection();
        }
}


If i create a new thread with "new Thread(new Connector()).start()" it
sends the correct message. But instead of receiving the artistdata it
receives only a statusmessage like "204 Success".

I tried this with telnet and i received the artistsdata without any
problems. What do i wrong with th sockets.

Any help would be nice. Thanks.

PS: Sorry for my bad english ;)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to