1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1657: Refine code

This commit is contained in:
winlin 2020-11-05 15:18:13 +08:00
parent 24125b9770
commit 9cf4203201
3 changed files with 15 additions and 15 deletions

View file

@ -72,7 +72,7 @@ public:
}; };
// The dynamic http connection, never drop the body. // The dynamic http connection, never drop the body.
class SrsDynamicHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsHttpMessageHandler class SrsDynamicHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsHttpConnOwner
{ {
private: private:
// The manager object to manage the connection. // The manager object to manage the connection.
@ -93,7 +93,7 @@ public:
private: private:
virtual srs_error_t do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec); virtual srs_error_t do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec);
// Extract APIs from SrsTcpConnection. // Extract APIs from SrsTcpConnection.
// Interface ISrsHttpMessageHandler. // Interface ISrsHttpConnOwner.
public: public:
virtual srs_error_t on_http_message(ISrsHttpMessage* msg); virtual srs_error_t on_http_message(ISrsHttpMessage* msg);
virtual void on_conn_done(); virtual void on_conn_done();

View file

@ -59,15 +59,15 @@ using namespace std;
#include <srs_app_utility.hpp> #include <srs_app_utility.hpp>
#include <srs_app_st.hpp> #include <srs_app_st.hpp>
ISrsHttpMessageHandler::ISrsHttpMessageHandler() ISrsHttpConnOwner::ISrsHttpConnOwner()
{ {
} }
ISrsHttpMessageHandler::~ISrsHttpMessageHandler() ISrsHttpConnOwner::~ISrsHttpConnOwner()
{ {
} }
SrsHttpConn::SrsHttpConn(ISrsHttpMessageHandler* handler, srs_netfd_t fd, ISrsHttpServeMux* m, string cip, int cport) SrsHttpConn::SrsHttpConn(ISrsHttpConnOwner* handler, srs_netfd_t fd, ISrsHttpServeMux* m, string cip, int cport)
{ {
parser = new SrsHttpParser(); parser = new SrsHttpParser();
cors = new SrsHttpCorsMux(); cors = new SrsHttpCorsMux();
@ -184,7 +184,7 @@ srs_error_t SrsHttpConn::do_cycle()
return err; return err;
} }
ISrsHttpMessageHandler* SrsHttpConn::handler() ISrsHttpConnOwner* SrsHttpConn::handler()
{ {
return handler_; return handler_;
} }

View file

@ -54,12 +54,12 @@ class SrsHttpMessage;
class SrsHttpStreamServer; class SrsHttpStreamServer;
class SrsHttpStaticServer; class SrsHttpStaticServer;
// The handler for HTTP message. // The owner of HTTP connection.
class ISrsHttpMessageHandler class ISrsHttpConnOwner
{ {
public: public:
ISrsHttpMessageHandler(); ISrsHttpConnOwner();
virtual ~ISrsHttpMessageHandler(); virtual ~ISrsHttpConnOwner();
public: public:
// Handle the HTTP message msg, which may be parsed partially. // Handle the HTTP message msg, which may be parsed partially.
// For the static service or api, discard any body. // For the static service or api, discard any body.
@ -77,7 +77,7 @@ protected:
SrsHttpParser* parser; SrsHttpParser* parser;
ISrsHttpServeMux* http_mux; ISrsHttpServeMux* http_mux;
SrsHttpCorsMux* cors; SrsHttpCorsMux* cors;
ISrsHttpMessageHandler* handler_; ISrsHttpConnOwner* handler_;
protected: protected:
SrsTcpConnection* skt; SrsTcpConnection* skt;
// Each connection start a green thread, // Each connection start a green thread,
@ -97,7 +97,7 @@ private:
// for current connection to log self create time and calculate the living time. // for current connection to log self create time and calculate the living time.
int64_t create_time; int64_t create_time;
public: public:
SrsHttpConn(ISrsHttpMessageHandler* handler, srs_netfd_t fd, ISrsHttpServeMux* m, std::string cip, int port); SrsHttpConn(ISrsHttpConnOwner* handler, srs_netfd_t fd, ISrsHttpServeMux* m, std::string cip, int port);
virtual ~SrsHttpConn(); virtual ~SrsHttpConn();
// Interface ISrsResource. // Interface ISrsResource.
public: public:
@ -109,7 +109,7 @@ private:
virtual srs_error_t do_cycle(); virtual srs_error_t do_cycle();
public: public:
// Get the HTTP message handler. // Get the HTTP message handler.
virtual ISrsHttpMessageHandler* handler(); virtual ISrsHttpConnOwner* handler();
// Whether the connection coroutine is error or terminated. // Whether the connection coroutine is error or terminated.
virtual srs_error_t pull(); virtual srs_error_t pull();
private: private:
@ -143,7 +143,7 @@ public:
}; };
// Drop body of request, only process the response. // Drop body of request, only process the response.
class SrsResponseOnlyHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsHttpMessageHandler class SrsResponseOnlyHttpConn : virtual public ISrsStartableConneciton, virtual public ISrsHttpConnOwner
{ {
private: private:
// The manager object to manage the connection. // The manager object to manage the connection.
@ -160,7 +160,7 @@ public:
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427 // @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
// @remark Should only used in HTTP-FLV streaming connection. // @remark Should only used in HTTP-FLV streaming connection.
virtual srs_error_t pop_message(ISrsHttpMessage** preq); virtual srs_error_t pop_message(ISrsHttpMessage** preq);
// Interface ISrsHttpMessageHandler. // Interface ISrsHttpConnOwner.
public: public:
virtual srs_error_t on_http_message(ISrsHttpMessage* msg); virtual srs_error_t on_http_message(ISrsHttpMessage* msg);
virtual void on_conn_done(); virtual void on_conn_done();