WriteHeader() public method

public WriteHeader ( ) : void
return void
示例#1
0
        //------------------------------------------------------------------------------------------------------------------------

        public void AddClient(Socket ClientSocket)
        {
            Mp3Writer wr;

            try
            {
                wr = new Mp3Writer(new NetworkStream(ClientSocket, true));
                //write the http audio header to the network stream
                wr.WriteHeader();
                //write mp3 header
                wr.WriteMp3Header();
                //client is now ready for streaming
                //each client is chatracterized by its socket and its mp3writer
                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.TraceError(ex.Message);
                try
                {
                    ClientSocket.Close();
                    ClientSocket.Dispose();
                }
                catch { }
            }
        }
示例#2
0
        //------------------------------------------------------------------------------------------------------------------------

        public void AddClient(Socket ClientSocket)
        {
            Mp3Writer wr;
            try
            {
                wr = new Mp3Writer(new NetworkStream(ClientSocket, true));
                //write the http audio header to the network stream
                wr.WriteHeader();
                //write mp3 header
                wr.WriteMp3Header();
                //client is now ready for streaming
                //each client is chatracterized by its socket and its mp3writer
                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.TraceError(ex.Message);
                try
                {
                    ClientSocket.Close();
                    ClientSocket.Dispose();
                }
                catch { }
            }
        }