//------------------------------------------------------------------------------------------------------------------------ public void AddClient(Socket ClientSocket) { //prepare MjpegWriter and write header for client MjpegWriter wr; try { //create writer wr = new MjpegWriter(new NetworkStream(ClientSocket, true)); // Writes the response header to the client. wr.WriteHeader(); //client is now ready for streaming var clientInfo = new ClientInfo() { Socket = ClientSocket, Writer = wr, }; lock (_Clients) if (!IsDisposed) { _Clients.Add(ClientSocket, clientInfo); } else { //we are disposed, so close client socket try { ClientSocket.Close(); ClientSocket.Dispose(); } catch { } } } catch (Exception ex) { DebugEx.TraceLog("Streaming Error: " + ex.Message); //close socket on error try { ClientSocket.Close(); ClientSocket.Dispose(); } catch { } } }
//------------------------------------------------------------------------------------------------------------------------ public void AddClient(Socket ClientSocket) { //prepare MjpegWriter and write header for client MjpegWriter wr; try { //create writer wr = new MjpegWriter(new NetworkStream(ClientSocket, true)); // Writes the response header to the client. wr.WriteHeader(); //client is now ready for streaming var clientInfo = new ClientInfo() { Socket = ClientSocket, Writer = wr, }; lock (_Clients) if (!IsDisposed) _Clients.Add(ClientSocket, clientInfo); else { //we are disposed, so close client socket try { ClientSocket.Close(); ClientSocket.Dispose(); } catch { } } } catch (Exception ex) { DebugEx.TraceLog("Streaming Error: " + ex.Message); //close socket on error try { ClientSocket.Close(); ClientSocket.Dispose(); } catch { } } }