public HttpRawMessage GetHttpRawMessage(int receivedBytes) { HttpRawMessage result = null; if (receivedBytes < 1) { return(result); } return(HttpRawMessage.ParseFromBytes(_szBuffer, 0, receivedBytes)); }
protected virtual void OnReceivedData(IAsyncResult ar) { ClientManager clmngr = null; Socket sock = null; bool recieving = false; try { clmngr = (ClientManager)ar.AsyncState; if (clmngr.Socket == null || !clmngr.Socket.Connected) { ShutdownClient(clmngr); return; } sock = clmngr.Socket; SocketError err; int nBytesRec = sock.EndReceive(ar, out err); if (nBytesRec == 0) { ShutdownClient(clmngr); return; } clmngr.dtLastHeart = DateTime.Now.AddSeconds(60); HttpRawMessage request = clmngr.GetHttpRawMessage(nBytesRec); if (request != null && request.Length > 0) { recieving = HandleRequest(clmngr, request); } if (recieving) { SetupReceiveCallback(clmngr); } } catch (Exception ex) { string strError = ex.Message; ShutdownClient(clmngr); Console.WriteLine(string.Format("Unusual error druing Recieve!({0})", ex.Message)); } finally { } }