-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler_example.cpp
More file actions
28 lines (24 loc) · 913 Bytes
/
Copy pathhandler_example.cpp
File metadata and controls
28 lines (24 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// Created by Jangit Lau on 2018/2/12.
//
#include "websocket/websocket_base_handler.h"
#include "websocket/definition/http_attr_struct.h"
class handler_example:public websocket_base_handler{
public:
virtual void on_open(handshake_inf& inf){
std::cout<<"in function on_open"<<std::endl;
inf.http_param_list.push_back(http_attr("debug1","in function on_open"));
}
virtual void on_close(websocket_header& header,websocket_payload& payload){
std::cout<<"in function on_close"<<std::endl;
}
virtual int on_message(websocket_header& header,websocket_payload& payload){
std::cout<<"in function on_message: "<<payload.get_payload()<<std::endl;
send("aaaaa",1);
this->shutdown();
return 0;
}
virtual void on_error(websocket_header& header,websocket_payload& payload){
std::cout<<"in function on_error"<<std::endl;
}
};