bool SBController::initDataStore(DataStoreConfig& config) { OSS_ASSERT(!_pDataStore); _pDataStore = new SBCDataStore(config.redisHost, config.redisPort); _pDataStore->registerDataStoreFunctions(*this); // // Connect RTP Proxy to redis // std::vector<RedisClient::ConnectionInfo> connectionInfo; RedisClient::ConnectionInfo conn; conn.host = config.redisHost; conn.port = config.redisPort; connectionInfo.push_back(conn); dynamic_cast<SIPB2BScriptableHandler*>(this)->rtpProxy().redisConnect(connectionInfo); }
bool ClassType::load(const boost::filesystem::path& file) { if (!boost::filesystem::exists(file)) { std::ostringstream errorMsg; errorMsg << "Persistent::ClassType::load ** File does not exist ** " << file; OSS_LOG_ERROR(errorMsg.str()); return false; } // _csFileMutex.lock(); _currentFile = file; OSS_ASSERT(!_isLoaded); try { static_cast<libconfig::Config*>(_persistentClass->_config)->readFile(OSS::boost_path(file).c_str()); } catch(libconfig::ParseException e) { std::ostringstream errorMsg; errorMsg << "Persistent::ClassType::load Error reading " << file << " at line " << e.getLine() << " with error " << e.getError(); OSS_LOG_ERROR(errorMsg.str()); return false; } catch(OSS::Exception e) { //_csFileMutex.unlock(); std::ostringstream errorMsg; errorMsg << "Persistent::ClassType::load Error reading " << file << " - " << e.message(); OSS_LOG_ERROR(errorMsg.str()); return false; } catch(...) { std::ostringstream errorMsg; errorMsg << "Persistent::ClassType::load Error reading " << file; OSS_LOG_ERROR(errorMsg.str()); return false; } _isLoaded = true; return true; }
void SIPWebSocketConnection::clientConnect(const OSS::IPAddress& target) /// Connect to a remote host { OSS_ASSERT(false); }
void SIPWebSocketConnection::clientBind(const OSS::IPAddress& ip, unsigned short portBase, unsigned short portMax) /// Bind the local client { OSS_ASSERT(false); }
void SIPWebSocketConnection::handleHandshake(const boost::system::error_code& error) { // this is only significant for TLS OSS_ASSERT(false); }
void SIPWebSocketConnection::handleConnect(const boost::system::error_code& e, boost::asio::ip::tcp::resolver::iterator endPointIter) { // Client side not implemented yet OSS_ASSERT(false); }
void SIPWebSocketConnection::handleResolve(boost::asio::ip::tcp::resolver::iterator endPointIter) { // Client side not implemented yet OSS_ASSERT(false); }
bool SIPWebSocketConnection::writeKeepAlive(const std::string& ip, const std::string& port) { // Not implemented for ws OSS_ASSERT(false); }
void SIPWebSocketConnection::handleWrite(const boost::system::error_code& e) /// Handle completion of a write operation. { // Not implemented for ws OSS_ASSERT(false); }
void SIPWebSocketConnection::handleRead(const boost::system::error_code& e, std::size_t bytes_transferred, OSS_HANDLE userData) /// Handle completion of a read operation. { if (e || bytes_transferred <=0) { OSS_LOG_DEBUG("SIPWebSocketConnection::handleRead Exception " << e.message()); if (++_readExceptionCount >= 5) { OSS_LOG_ERROR("SIPWebSocketConnection::handleRead has reached maximum exception count. Bailing out."); boost::system::error_code ignored_ec; _connectionManager.stop(shared_from_this()); } } OSS_LOG_DEBUG("SIPWebSocketConnection::handleRead STARTING new connection"); std::string* buffer = reinterpret_cast<std::string*>(userData); // // set the last read address // if (!_lastReadAddress.isValid()) { boost::system::error_code ec; EndPoint ep = _pServerConnection->get_raw_socket().remote_endpoint(ec); if (!ec) { boost::asio::ip::address ip = ep.address(); _lastReadAddress = OSS::IPAddress(ip.to_string(), ep.port()); } else { OSS_LOG_WARNING("SIPWebSocketConnection::handleRead() Exception " << ec.message()); } } // // Reset the read exception count // _readExceptionCount = 0; _bytesRead = bytes_transferred; if (!_pRequest) { _pRequest = SIPMessage::Ptr(new SIPMessage()); } boost::tribool result; const char* begin = buffer->data(); const char* end = buffer->data() + bytes_transferred; boost::tuple<boost::tribool, const char*> ret = _pRequest->consume(begin, end); result = ret.get<0>(); const char* tail = ret.get<1>(); if (result) { // // Message has been read in full // _pDispatch->onReceivedMessage(_pRequest->shared_from_this(), shared_from_this()); if (tail >= end) { // // The end of the SIPMessage is reached so we can simply reset the // request buffer and start the read operation all over again // _pRequest.reset(); // // We are done // return; } else { // // This should not happen as there is one full message per read. // The tail is within the range of the end of the read buffer. // OSS_ASSERT(false); } } else if (!result) { _pRequest.reset(); } else { // // This should not happen as there is one full message per read. // Partial message? // OSS_ASSERT(false); } }
void SIPB2BTransactionManager::registerDomainRouter(const std::string& domain, SIPB2BHandler::Ptr handler) { OSS_ASSERT(handler); handler->initialize(); _domainRouters[domain] = handler; }
void SIPB2BTransactionManager::registerHandler(SIPB2BHandler::Ptr handler) { OSS_ASSERT(handler); handler->initialize(); _handlers[handler->getType()] = handler; }