How to write a browser app for Apache?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #1

    How to write a browser app for Apache?

    I'm trying to write an browser application that will let me control an instance of Windows Media Player running on my computer. So far I have a client application working great, but now I need to make it into a webpage that access over my network using my phone. I'm running an Apache server.

    I've got a few ideas for how I could do it, but one might not work.

    First, a browser app that will render as a webpage when requested. I dunno if this'll work because of being on Apache and not IIS.

    Second, a console app that I can send commands to using php's exec() function.

    Finally, a network listener that'll basically be it's own server, I'll be able to connect to that app on a specific port and send commands to it as url parameters. I'd wrap this in an html page.

    Does anyone else have any ideas as to how I might do this, or comments on the ideas I've had so far?
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    Well this has been helpful. Am I to understand that no one here has any clue how I might do this?

    Comment

    • GaryTexmo
      Recognized Expert Top Contributor
      • Jul 2009
      • 1501

      #3
      Unfortunately, it looks like that's the case. If you do get this figured out, it might be a great thing to write an insight on it so people looking for similar ideas in the future can learn something from your experiences :)

      Good luck! I wish I had something to offer, but this is outside of my area of expertise.

      Comment

      • peochei
        New Member
        • Oct 2010
        • 12

        #4
        You can configure your Apache to serve ASP.NET pages for you. Then you could write a web site which would have some controls on it to control your application. This would probably force you to override System.Web.UI.P age or even controls used on the page (lets say it would be Buttons). Than you would write a triggers to execute local operations to operate on the local application.

        The other possibility, which surely will be more lightweight, is to create your own tiny WebServer which would provide only few buttons to enable controlling of the application. The effort here could be the same or even lower and the server-application would be more portable (no Apache required).
        There is a HttpListener which simulates basic HTTP requests. Quite a lot of samples are over internet as well. See C# WebServer project.

        You can also use WebServices, which are supported by .NET, if you don't want to bother playing with controls.

        Comment

        • HaLo2FrEeEk
          Contributor
          • Feb 2007
          • 404

          #5
          Bingo peochei, this is actually what I've started doing. I've currently got it listening on IP.All and port 7777. I can load up, in my computer's browser or my Droid connected to Wifi, 192.168.1.110:7 777 (my computer's network IP) and it'll serve a page that says:

          Hello Client

          Your request: none

          If I request 192.168.1.110:7 777/something, then the page will print out:

          Hello Client

          Your request: something

          The only problem I've run into is that the listening and client communication is handled in its own thread, and I' have exactly 0 experience with actual threads (not counting the background worker), so I'll have to figure out how to send information back to the main thread from the client communication thread. When I do this, I can accept requests like:

          Play
          Pause
          Next
          Previous

          in the URL, and act on them in the server-side program. Like you said, the advantage to this is that it's portable, so anyone can run the server and use the program on their Windows PC.

          Comment

          • peochei
            New Member
            • Oct 2010
            • 12

            #6
            It's not that hard as you probably see it. You will need one additional thread to listen for requests. Some samples can be found on the internet (try searching HTTPListener, also on http://codeproject.com). There is also TCPListener class which has more clear examples and you can benefit from it as well.

            The most attention is needed to be focused on the method which will be handling requests received from GetContext() of HTTPListener. It can use ThreadPool.Queu eUserWorkItem to put a request into new thread.

            However, at first I wouldn't go into threading but just test simple processing of HTTPListenerCon text elements in the main loop.

            Actually, you don't have to take care about synchronization because of simplicity of the problem, so the easiest solution could be using simple event to inform about what has changed.

            Comment

            Working...