summaryrefslogtreecommitdiffstats
path: root/src/uscxml/server/Socket.h
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-08-13 11:48:26 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-08-13 11:48:26 (GMT)
commit02f52d15e7df2500c0c6e96660a43a985add16e8 (patch)
treed4ccfdd7d1070201f39a9589b35e02a39ec179c8 /src/uscxml/server/Socket.h
parentc30b602cdb5ede809b960e35fc7e702b7f1f76e2 (diff)
downloaduscxml-02f52d15e7df2500c0c6e96660a43a985add16e8.zip
uscxml-02f52d15e7df2500c0c6e96660a43a985add16e8.tar.gz
uscxml-02f52d15e7df2500c0c6e96660a43a985add16e8.tar.bz2
Builds for Raspberry and
started VoiceXML HTTP integration
Diffstat (limited to 'src/uscxml/server/Socket.h')
-rw-r--r--src/uscxml/server/Socket.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/uscxml/server/Socket.h b/src/uscxml/server/Socket.h
index 5854a46..9330c4b 100644
--- a/src/uscxml/server/Socket.h
+++ b/src/uscxml/server/Socket.h
@@ -23,6 +23,7 @@
#include "uscxml/Common.h" // for USCXML_API
#include "uscxml/concurrency/EventBase.h"
#include <string>
+#include <sstream>
#include <map>
#include <set>
@@ -49,6 +50,7 @@ public:
virtual ~Socket();
void setBlockSizeRead(size_t size);
+ static void parseAddress(const std::string& address, std::string& protocol, std::string& hostName, uint16_t& port);
protected:
@@ -67,6 +69,10 @@ class USCXML_API ServerSocket : public Socket {
public:
class Connection {
public:
+ bool operator<(const Connection& other) const {
+ return bufferEvent < other.bufferEvent;
+ }
+
struct bufferevent* bufferEvent;
int fd;
@@ -77,6 +83,7 @@ public:
virtual ~ServerSocket();
void listen(const std::string& address, int port);
+ void listen(const std::string& address);
virtual void readCallback(const char* data, size_t size, Connection& conn) {};
@@ -93,6 +100,19 @@ protected:
};
+class USCXML_API PacketServerSocket : public ServerSocket {
+public:
+ PacketServerSocket(int domain, int type, int protocol, const std::string& sep) : ServerSocket(domain, type, protocol), _sep(sep) {}
+ virtual ~PacketServerSocket() {}
+
+ void readCallback(const char* data, size_t size, Connection& conn);
+ virtual void readCallback(const std::string& packet, Connection& conn) = 0;
+
+protected:
+ std::string _sep;
+ std::map<Connection, std::stringstream> _fragments;
+};
+
class USCXML_API ClientSocket : public Socket {
public:
ClientSocket(int domain, int type, int protocol);
@@ -100,6 +120,8 @@ public:
virtual void readCallback(const char* data, size_t size) {};
void connect(const std::string& address, int port);
+ void connect(const std::string& address);
+ int write(const std::string& data);
int write(const char* data, size_t size);