Amelioration Webserver

This commit is contained in:
manu 2014-01-19 16:18:59 +00:00
parent 3e73515f0d
commit 636106176a
2 changed files with 61 additions and 30 deletions

View file

@ -40,10 +40,28 @@ namespace DMX2
Console.WriteLine (context.Request.RawUrl);
string responseString = GetResponse (context);
// TODO : gerer autrement les resources
byte[] buffer = System.Text.Encoding.UTF8.GetBytes (responseString);
context.Response.ContentLength64 = buffer.Length;
context.Response.OutputStream.Write (buffer, 0, buffer.Length);
// Pour les resources, on les renvoie si elles existent
if (context.Request.Url.LocalPath.StartsWith ("/res/")) {
string res = context.Request.Url.LocalPath.Remove(0,5).Replace('/','.');
if(resources.Contains(res))
using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
{
byte[] buff = new byte[1024]; int l;
while( (l=stream.Read(buff,0,buff.Length))>0){
context.Response.OutputStream.Write(buff,0,l);
}
}
}
else
{
byte[] buffer = System.Text.Encoding.UTF8.GetBytes (responseString);
context.Response.ContentLength64 = buffer.Length;
context.Response.OutputStream.Write (buffer, 0, buffer.Length);
}
context.Response.OutputStream.Close ();
}
} catch {
@ -57,16 +75,7 @@ namespace DMX2
// Pas de conduite chargée, on renvoi un simple message
if (Conduite.Courante == null) return "<html><body>Pas de conduite</body></html>";
// Pour les resources, on les renvoie si elles existent
if (req.Url.LocalPath.StartsWith ("/res/")) {
string res = req.Url.LocalPath.Remove(0,5).Replace('/','.');
if(resources.Contains(res))
using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
using (System.IO.TextReader reader = new System.IO.StreamReader(stream))
return reader.ReadToEnd();
else return "";
}
int circuit, univ, dimmer, val;
// En fonction du http://xxxxxx:yyyy/?id=

View file

@ -11,15 +11,33 @@
A=Math.min(A,512);
A=Math.max(A,1);
this.dimmer.value=A;
B=$( "#slider").slider( "value" );
trans1(form.univ.value,form.dimmer.value,B);
}
function hop2(code)
{
A=parseInt(this.circuit.value)+parseInt(code);
A=Math.max(A,1);
this.circuit.value=A;
}
function hop2(code)
{
A=parseInt(this.circuit.value)+parseInt(code);
A=Math.max(A,1);
this.circuit.value=A;
B=$( "#slider2").slider( "value" );
trans2(form2.circuit.value,B);
}
function Balckout()
{
$( "#slider2").slider( "value",0 );
//B=$( "#slider2").slider( "value" );
//trans2(form2.circuit.value,B);
}
function Full()
{
$( "#slider2").slider( "value",255 );
//B=$( "#slider2").slider( "value" );
//trans2(form2.circuit.value,B);
}
function remplir()
{
$( "#slider" ).slider({
@ -44,11 +62,12 @@
B=$( "#slider").slider( "value" );
trans1(form.univ.value,form.dimmer.value,B);
}
function refreshSwatch2()
{
B=$( "#slider2").slider( "value" );
trans2(form2.circuit.value,B);
}
function refreshSwatch2()
{
B=$( "#slider2").slider( "value" );
trans2(form2.circuit.value,B);
}
function trans1(univ,dimmer,val)
{
@ -78,7 +97,7 @@
<span id="toto">
<div id="univers">
<form name="form">
<table border="1">
<table border="0">
<tr>
<th>
<label>Univers</label>
@ -98,7 +117,7 @@
</tr><tr>
<td><input type="button" value="C-" Onclick="hop('-100')"><input type="button" value="D-" Onclick="hop('-10')">
<input type="button" value="U-" Onclick="hop('-1')"></td>
</tr><tr>
</tr><tr><td> </td></tr><tr>
<td colspan="2">
<div id="slider"></div>
<td>
@ -109,7 +128,7 @@
<div id="circuits">
<form name="form2">
<table border="1">
<table border="0">
<tr>
<th rowspan="3" >
<label>Circuit</label>
@ -121,11 +140,14 @@
</tr><tr>
<td><input type="button" value="C-" Onclick="hop2('-100')"><input type="button" value="D-" Onclick="hop2('-10')">
<input type="button" value="U-" Onclick="hop2('-1')" >
</tr><tr>
</tr><tr><td> </td> </tr><tr>
<td colspan="2">
<div id="slider2"></div>
<td>
</tr>
<tr><td align="left"><input type="button" value="Blackout" Onclick="Balckout()"></td>
<td align="right"><input type="button" value="Full" Onclick="Full()"></td></tr>
</table>
<script>remplir();</script>
</form>