mirror of https://github.com/sipwise/sems.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.8 KiB
85 lines
1.8 KiB
|
|
#ifndef __BRPCCTRLINTERFACE_H__
|
|
#define __BRPCCTRLINTERFACE_H__
|
|
|
|
#include <time.h>
|
|
#include <binrpc.h>
|
|
|
|
#include "AmApi.h"
|
|
#include "AmSipDispatcher.h"
|
|
#include "ConnPool.h"
|
|
#include "CtrlServer.h"
|
|
|
|
|
|
#define ASI_VERSION 0x2
|
|
|
|
|
|
class BrpcCtrlInterfaceFactory : public AmCtrlInterfaceFactory
|
|
{
|
|
string semsUri, serUri;
|
|
|
|
public:
|
|
BrpcCtrlInterfaceFactory(const string &name);
|
|
~BrpcCtrlInterfaceFactory();
|
|
|
|
AmCtrlInterface *instance();
|
|
|
|
// AmPluginFactory
|
|
int onLoad();
|
|
};
|
|
|
|
class BrpcCtrlInterface: public AmCtrlInterface
|
|
{
|
|
/* static */ time_t serial;
|
|
/* static */ brpc_int_t as_id;
|
|
|
|
// handler of requests (SIP request | reply) received from SER
|
|
AmSipDispatcher *sipDispatcher;
|
|
|
|
ConnPool *serConn;
|
|
CtrlServer *ctrlSrv;
|
|
|
|
inline void handleSipMsg(AmSipRequest &req)
|
|
{
|
|
AmSipDispatcher::instance()->handleSipMsg(req);
|
|
}
|
|
|
|
inline void handleSipMsg(AmSipReply &rpl)
|
|
{
|
|
AmSipDispatcher::instance()->handleSipMsg(rpl);
|
|
}
|
|
|
|
brpc_t *rpcExecute(brpc_t *req);
|
|
bool rpcCheck();
|
|
void serResync();
|
|
|
|
static brpc_t *asiSync(brpc_t *req, void *iface);
|
|
static brpc_t *methods(brpc_t *req, void *iface);
|
|
static brpc_t *digests(brpc_t *req, void *iface);
|
|
static brpc_t *req_handler(brpc_t *req, void *iface);
|
|
|
|
bool initCallbacks();
|
|
|
|
public:
|
|
BrpcCtrlInterface();
|
|
~BrpcCtrlInterface();
|
|
|
|
int init(const string& semsUri, const string& serUri);
|
|
|
|
// AmThread
|
|
void run();
|
|
void on_stop();
|
|
|
|
// AmCtrlInterface
|
|
int send(const AmSipRequest &, char *, unsigned int &);
|
|
int send(const AmSipReply &);
|
|
|
|
string getContact(const string &displayName,
|
|
const string &userName, const string &hostName,
|
|
const string &uriParams, const string &hdrParams);
|
|
|
|
|
|
};
|
|
|
|
#endif /* __BRPCCTRLINTERFACE_H__ */
|