Dangerous Prototypes

Other projects => Past projects => Web platform => Topic started by: M0KHZ on February 07, 2011, 08:51:22 pm

Title: C# GUI interface to Web Server
Post by: M0KHZ on February 07, 2011, 08:51:22 pm
Having great fun (and learning) from the Web Server platform - here on my bench for the last 4 days :), my thoughts are now turning towards a Windows GUI interface to toggle LED2, plus anything else I hang off the header.

I’m guessing a GUI button could ‘talk’ to the server via http, has anyone tried this?
Has anyone any pointers as how to implement this?

At the moment I have a new C# project started, a single button on Form1, but have NO idea what needs to go into the event handler for the button :)

Regards
Kevin
Title: Re: C# GUI interface to Web Server
Post by: sqkybeaver on February 07, 2011, 09:39:56 pm
you could get a minimalist pipe running on a nonstandard port to input commands to the web server
Title: Re: C# GUI interface to Web Server
Post by: M0KHZ on February 08, 2011, 07:53:52 pm
Update (& a happy man)....

OK I now have a very basic version working, below is the code for the button click event handler:

 private void button1_Click(object sender, EventArgs e)
        {
          // In this method you need to set up an event
            int count;
            byte[] buffer = new byte[8192];
           
          // create the request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.0.5/leds.cgi?led=1");
 
          // send request & get a response
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

          // process the response
            Stream responseStream = response.GetResponseStream();
            count = responseStream.Read(buffer, 0, buffer.Length);

            response.Close();

        }

Now I can toggle LED2 via a simple windows application. The learning continues :)

Regards
Kevin

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.02242056192session_write_close ( )...(null):0
20.02302187784ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.02302188560Database_MySQL->query( ).../DatabaseHandler.php:119
40.08682327296Database_MySQL->error( ).../Db-mysql.class.php:273