mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-15 09:20:52 +08:00
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
|
#pragma once
|
|||
|
|
|||
|
class WebsocketServlet_impl : public acl::WebSocketServlet
|
|||
|
{
|
|||
|
public:
|
|||
|
WebsocketServlet_impl(acl::redis_client_cluster& cluster, size_t max_conns);
|
|||
|
~WebsocketServlet_impl();
|
|||
|
|
|||
|
acl::session& get_session() const
|
|||
|
{
|
|||
|
return *session_;
|
|||
|
}
|
|||
|
|
|||
|
protected:
|
|||
|
virtual bool doUnknown(acl::HttpServletRequest&,
|
|||
|
acl::HttpServletResponse& res);
|
|||
|
virtual bool doGet(acl::HttpServletRequest& req,
|
|||
|
acl::HttpServletResponse& res);
|
|||
|
virtual bool doPost(acl::HttpServletRequest& req,
|
|||
|
acl::HttpServletResponse& res);
|
|||
|
|
|||
|
|
|||
|
//for websocket
|
|||
|
/**
|
|||
|
* websocket <EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ص<EFBFBD>
|
|||
|
* @return {void}
|
|||
|
*/
|
|||
|
virtual void on_close()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
/**
|
|||
|
* websocket ping <EFBFBD><EFBFBD>Ϣ<EFBFBD>ص<EFBFBD>.
|
|||
|
* @param {const char *} buf <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param {int} len <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return {bool} false <EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>
|
|||
|
*/
|
|||
|
virtual bool on_ping(const char *buf, unsigned long long len);
|
|||
|
/**
|
|||
|
* websocket pong <EFBFBD><EFBFBD>Ϣ<EFBFBD>ص<EFBFBD>.
|
|||
|
* @param {const char *} buf <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param {int} len <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return {bool} false <EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>
|
|||
|
*/
|
|||
|
virtual bool on_pong(const char *buf, unsigned long long len);
|
|||
|
|
|||
|
/**
|
|||
|
* websocket ping <EFBFBD><EFBFBD>Ϣ<EFBFBD>ص<EFBFBD>.
|
|||
|
* @param data{char *} <EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param len{unsigned long long}<EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>
|
|||
|
* @param text{bool } true Ϊ<EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
|||
|
* @return {bool} false <EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>
|
|||
|
*/
|
|||
|
virtual bool on_message(char *data, unsigned long long len, bool text);
|
|||
|
|
|||
|
private:
|
|||
|
acl::session* session_;
|
|||
|
|
|||
|
int step_;
|
|||
|
|
|||
|
acl::string filename_;
|
|||
|
|
|||
|
acl::ofstream *file_;
|
|||
|
|
|||
|
int filesize_;
|
|||
|
|
|||
|
int current_filesize_;
|
|||
|
};
|