-
Notifications
You must be signed in to change notification settings - Fork 1
/
presence.cpp
33 lines (29 loc) · 1008 Bytes
/
presence.cpp
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
29
30
31
32
33
/*
Copyright (c) 2012-2017 The icomet Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
#include "presence.h"
#include "server.h"
#include "util/log.h"
#include "server_config.h"
#include <http-internal.h>
static void connection_closecb(struct evhttp_connection *evcon, void *arg){
log_info("presence subscriber disconnected");
PresenceSubscriber *psub = (PresenceSubscriber *)arg;
psub->close();
}
void PresenceSubscriber::start(){
log_info("%s:%d psub, psubs: %d", req->remote_host, req->remote_port, serv->psubs.size);
bufferevent_enable(req->evcon->bufev, EV_READ);
evhttp_connection_set_closecb(req->evcon, connection_closecb, this);
evhttp_send_reply_start(req, HTTP_OK, "OK");
}
void PresenceSubscriber::close(){
log_info("%s:%d psub_end", req->remote_host, req->remote_port);
if(req->evcon){
evhttp_connection_set_closecb(req->evcon, NULL, NULL);
}
evhttp_send_reply_end(req);
serv->psub_end(this);
}