Skip to content

Commit

Permalink
add cname in error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
ideawu committed May 15, 2014
1 parent d34dfd8 commit 262b24d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/comet/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,18 @@ int Server::sub(struct evhttp_request *req, Subscriber::Type sub_type){
channel = this->new_channel(cname);
if(!channel){
//evhttp_send_reply(req, 429, "Too many channels", NULL);
Subscriber::send_error_reply(sub_type, req, cb, "429", "Too many channels");
Subscriber::send_error_reply(sub_type, req, cb, cname, "429", "Too many channels");
return 0;
}
}
if(!channel || (this->auth == AUTH_TOKEN && channel->token != token)){
//evhttp_send_reply(req, 401, "Token error", NULL);
Subscriber::send_error_reply(sub_type, req, cb, "401", "Token error");
Subscriber::send_error_reply(sub_type, req, cb, cname, "401", "Token error");
return 0;
}
if(channel->subs.size >= ServerConfig::max_subscribers_per_channel){
//evhttp_send_reply(req, 429, "Too many subscribers", NULL);
Subscriber::send_error_reply(sub_type, req, cb, "429", "Too many subscribers");
Subscriber::send_error_reply(sub_type, req, cb, cname, "429", "Too many subscribers");
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/comet/subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void Subscriber::send_chunk(int seq, const char *type, const char *content){
}
}

void Subscriber::send_error_reply(int sub_type, struct evhttp_request *req, const char *cb, const char *type, const char *content){
void Subscriber::send_error_reply(int sub_type, struct evhttp_request *req, const char *cb, const std::string &cname, const char *type, const char *content){
struct evbuffer *buf = evbuffer_new();

if(sub_type == POLL){
Expand All @@ -147,7 +147,7 @@ void Subscriber::send_error_reply(int sub_type, struct evhttp_request *req, cons

evbuffer_add_printf(buf,
"{\"type\":\"%s\",\"cname\":\"%s\",\"seq\":%d,\"content\":\"%s\"}",
type, "", 0, content);
type, cname.c_str(), 0, content);

if(sub_type == POLL){
evbuffer_add_printf(buf, ");");
Expand Down
2 changes: 1 addition & 1 deletion src/comet/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Subscriber{
void noop();
void send_old_msgs();

static void send_error_reply(int sub_type, struct evhttp_request *req, const char *cb, const char *type, const char *content);
static void send_error_reply(int sub_type, struct evhttp_request *req, const char *cb, const std::string &cname, const char *type, const char *content);
};

#endif

0 comments on commit 262b24d

Please sign in to comment.