Modify drogon_ctl
This commit is contained in:
parent
aa8170ff18
commit
c0acf347a3
|
@ -122,7 +122,7 @@ void create_controller::handleCommand(std::vector<std::string> ¶meters)
|
|||
}
|
||||
|
||||
}
|
||||
createSimpleController(parameters,namespaceName);
|
||||
createWebsockController(parameters,namespaceName);
|
||||
}
|
||||
else
|
||||
createApiController(parameters);
|
||||
|
@ -241,7 +241,7 @@ void create_controller::newSimpleControllerSourceFile(std::ofstream &file,const
|
|||
void create_controller::newWebsockControllerHeaderFile(std::ofstream &file,const std::string &ctlName,const std::string &namespaceName)
|
||||
{
|
||||
file<<"#pragma once\n";
|
||||
file<<"#include <drogon/HttpWebsocketController.h>\n";
|
||||
file<<"#include <drogon/WebsocketController.h>\n";
|
||||
file<<"using namespace drogon;\n";
|
||||
std::string indent="";
|
||||
auto namespace_name=namespaceName;
|
||||
|
@ -263,7 +263,7 @@ void create_controller::newWebsockControllerHeaderFile(std::ofstream &file,const
|
|||
indent.append(" ");
|
||||
}
|
||||
}
|
||||
file<<indent<<"class "<<ctlName<<":public drogon::HttpWebsocketController<"<<ctlName<<">\n";
|
||||
file<<indent<<"class "<<ctlName<<":public drogon::WebSocketController<"<<ctlName<<">\n";
|
||||
file<<indent<<"{\n";
|
||||
file<<indent<<"public:\n";
|
||||
//TestController(){}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include "WebSocketTest.h"
|
||||
using namespace example;
|
||||
void WebSocketTest::handleNewMessage(const WebSocketConnectionPtr& wsConnPtr,trantor::MsgBuffer* buffer)
|
||||
{
|
||||
//write your application logic here
|
||||
}void WebSocketTest::handleConnection(const WebSocketConnectionPtr& wsConnPtr)
|
||||
{
|
||||
//write your application logic here
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include <drogon/WebSocketController.h>
|
||||
using namespace drogon;
|
||||
namespace example
|
||||
{
|
||||
class WebSocketTest:public drogon::WebSocketController<WebSocketTest>
|
||||
{
|
||||
public:
|
||||
virtual void handleNewMessage(const WebSocketConnectionPtr&,
|
||||
trantor::MsgBuffer*)override;
|
||||
virtual void handleConnection(const WebSocketConnectionPtr&)override;
|
||||
WS_PATH_LIST_BEGIN
|
||||
//list path definations here;
|
||||
WS_PATH_ADD("/chat");
|
||||
WS_PATH_LIST_END
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue