Gadgeteer Web Server Responder

Richieste di supporto in merito a problemi su hardware e firmware

14/01/2013 22:13:22
Gravatar
Totale Interventi 41

Gadgeteer Web Server Responder

Secondo voi xke questo nuovo metodo fiammante non funziona???

/// <summary>
/// Updates the data with which the web event responds and sets the correct MIME type.
/// </summary>
/// <param name="resourceManager"></param>
/// <param name="resourceId"></param>
/// <param name="ContentType"></param>
public void Respond(System.Resources.ResourceManager resourceManager, Enum resourceId, string ContentType)
{
webEvent.ContentType = ContentType;

BinaryResponseTemplate template = this.webEvent.ComputeResponse();

if (template.Header != null && template.Header.Length > 0)
{
//send the http header
this.ClientSocket.Send(template.Header, 0, template.Header.Length, SocketFlags.None);

bool resourceEnded = false;
int offset = 0;

while(!resourceEnded)
{
try
{
byte[] resourceBlock = (byte[])ResourceUtility.GetObject(resourceManager, resourceId,
offset, 32);

var sent = this.ClientSocket.Send(resourceBlock, 0, resourceBlock.Length, SocketFlags.None);
}
catch (Exception)
{
resourceEnded = false;
}

offset += 32;
}

this.ClientSocket.Close();
}
}