void sendmailTransport::send (const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { // If no recipient/expeditor was found, throw an exception if (recipients.isEmpty()) throw exceptions::no_recipient(); else if (expeditor.isEmpty()) throw exceptions::no_expeditor(); // Construct the argument list std::vector <string> args; args.push_back("-i"); args.push_back("-f"); args.push_back(expeditor.getEmail()); args.push_back("--"); for (int i = 0 ; i < recipients.getMailboxCount() ; ++i) args.push_back(recipients.getMailboxAt(i)->getEmail()); // Call sendmail try { internalSend(args, is, size, progress); } catch (vmime::exception& e) { throw exceptions::command_error("SEND", "", "sendmail failed", e); } }
bool Connection::send(OutputMessage_ptr msg) { m_connectionLock.lock(); if(m_closeState == CLOSE_STATE_CLOSING || m_writeError) { m_connectionLock.unlock(); return false; } msg->getProtocol()->onSendMessage(msg); if(m_pendingWrite == 0) { #ifdef __DEBUG_NET_DETAIL__ std::clog << "Connection::send " << msg->getMessageLength() << std::endl; #endif internalSend(msg); } else { #ifdef __DEBUG_NET__ std::clog << "Connection::send Adding to queue " << msg->getMessageLength() << std::endl; #endif m_outputQueue.push_back(msg); } m_connectionLock.unlock(); return true; }
bool Connection::send(OutputMessage_ptr msg) { LOGt("Connection::send()"); boost::recursive_mutex::scoped_lock lock(m_connectionLock); if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError) { return false; } TRACK_MESSAGE(msg); if(!m_pendingWrite) { if(msg->getProtocol()) msg->getProtocol()->onSendMessage(msg); internalSend(msg); } else if(m_pendingWrite > 100 && server.configManager().getBool(ConfigManager::FORCE_CLOSE_SLOW_CONNECTION)) { LOGd("Forcing slow connection to disconnect!"); close(); } else { OutputMessagePool::getInstance()->autoSend(msg); } return true; }
// if length is greater than 32 bytes, then buff will be splitted into 32-bytes long packets TransmitResult send(const uint8_t *buff, const size_t &length, bool requestAck) { if (getMode() != MODE_PTX) { setModeTX(); } return internalSend(buff, length, requestAck); }
void Connection::send(const OutputMessage_ptr& msg) { std::lock_guard<std::recursive_mutex> lockClass(connectionLock); if (connectionState != CONNECTION_STATE_OPEN) { return; } bool noPendingWrite = messageQueue.empty(); messageQueue.emplace_back(msg); if (noPendingWrite) { internalSend(msg); } }
// if length is greater than 32 bytes, then buff will be splitted into 32-bytes long packets TransmitResult send(const uint32_t &targetAddress, const uint8_t *buff, const size_t &length, bool requestAck) { if (getMode() != MODE_PTX) { setModeTX(); } uint8_t adr[5]; memcpy(adr, &targetAddress, 4); adr[4] = 0; configTxPipe(adr, TX_DPL); return internalSend(buff, length, requestAck); }
void Connection::onWriteOperation(OutputMessage_ptr msg, const boost::system::error_code& error) { #ifdef __DEBUG_NET_DETAIL__ std::clog << "onWriteOperation" << std::endl; #endif msg.reset(); m_connectionLock.lock(); if(!error) { if(m_pendingWrite > 0) { if(!m_outputQueue.empty()) { OutputMessage_ptr msg = m_outputQueue.front(); m_outputQueue.pop_front(); internalSend(msg); #ifdef __DEBUG_NET_DETAIL__ std::clog << "Connection::onWriteOperation send " << msg->getMessageLength() << std::endl; #endif } m_pendingWrite--; } else { std::clog << "Error: [Connection::onWriteOperation] Getting unexpected notification!" << std::endl; // Error. Pending operations counter is 0, but we are getting a // notification!! } } else { m_pendingWrite--; handleWriteError(error); } if(m_closeState == CLOSE_STATE_CLOSING) { if(!closingConnection()) m_connectionLock.lock(); return; } m_connectionLock.unlock(); }
bool Connection::send(OutputMessage_ptr msg) { std::lock_guard<std::recursive_mutex> lockClass(m_connectionLock); if (m_connectionState != CONNECTION_STATE_OPEN || m_writeError) { return false; } if (m_pendingWrite == 0) { msg->getProtocol()->onSendMessage(msg); internalSend(msg); } else { OutputMessagePool::getInstance()->addToAutoSend(msg); } return true; }
void Connection::onWriteOperation(const boost::system::error_code& error) { std::lock_guard<std::recursive_mutex> lockClass(connectionLock); writeTimer.cancel(); messageQueue.pop_front(); if (error) { messageQueue.clear(); close(FORCE_CLOSE); return; } if (!messageQueue.empty()) { internalSend(messageQueue.front()); } else if (connectionState == CONNECTION_STATE_CLOSED) { closeSocket(); } }
bool Connection::send(OutputMessage_ptr msg) { m_connectionLock.lock(); if (m_connectionState != CONNECTION_STATE_OPEN || m_writeError) { m_connectionLock.unlock(); return false; } if (m_pendingWrite == 0) { msg->getProtocol()->onSendMessage(msg); internalSend(msg); } else { OutputMessagePool::getInstance()->addToAutoSend(msg); } m_connectionLock.unlock(); return true; }
bool Connection::send(OutputMessage_ptr msg) { #ifdef __DEBUG_NET_DETAIL__ std::clog << "Connection::send init" << std::endl; #endif m_connectionLock.lock(); if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError) { m_connectionLock.unlock(); return false; } TRACK_MESSAGE(msg); if(!m_pendingWrite) { if(msg->getProtocol()) msg->getProtocol()->onSendMessage(msg); #ifdef __DEBUG_NET_DETAIL__ std::clog << "Connection::send " << msg->size() << std::endl; #endif internalSend(msg); } else if(m_pendingWrite > 100 && g_config.getBool(ConfigManager::FORCE_CLOSE_SLOW_CONNECTION)) { std::clog << "NOTICE: Forcing slow connection to disconnect!" << std::endl; close(); } else { #ifdef __DEBUG_NET__ std::clog << "Connection::send Adding to queue " << msg->size() << std::endl; #endif OutputMessagePool::getInstance()->autoSend(msg); } m_connectionLock.unlock(); return true; }
bool Connection::send(OutputMessage_ptr msg) { #ifdef __DEBUG_NET_DETAIL__ std::cout << "Connection::send init" << std::endl; #endif m_connectionLock.lock(); if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError){ m_connectionLock.unlock(); return false; } if(m_pendingWrite == 0){ msg->getProtocol()->onSendMessage(msg); TRACK_MESSAGE(msg); #ifdef __DEBUG_NET_DETAIL__ std::cout << "Connection::send " << msg->getMessageLength() << std::endl; #endif internalSend(msg); } else{ #ifdef __DEBUG_NET__ std::cout << "Connection::send Adding to queue " << msg->getMessageLength() << std::endl; #endif TRACK_MESSAGE(msg); OutputMessagePool* outputPool = OutputMessagePool::getInstance(); outputPool->addToAutoSend(msg); } m_connectionLock.unlock(); return true; }
bool ESP8266proConnection::send(const __FlashStringHelper* data) { return internalSend(data, NULL); }
bool ESP8266proConnection::send(String data) { return internalSend(NULL, data.c_str()); }