]> git.stg.codes - stg.git/blob - stglibs/sgcp.lib/transport.cpp
1e94fa58da5ac5b91a6a3769931c12a3bca336dd
[stg.git] / stglibs / sgcp.lib / transport.cpp
1 #include "stg/sgcp_transport.h"
2
3 #include "crypto.h"
4 #include "unix.h"
5 #include "udp.h"
6 #include "tcp.h"
7
8 using STG::SGCP::TransportProto;
9
10 TransportProto* TransportProto::create(TransportType transport, const std::string& key)
11 {
12     TransportProto* underlying = create(transport);
13     if (key.empty())
14         return underlying;
15     else
16         return new CryptoProto(key, underlying);
17 }
18
19 TransportProto* TransportProto::create(TransportType transport)
20 {
21     switch (transport) {
22         case UNIX: return new UnixProto;
23         case UDP: return new UDPProto;
24         case TCP: return new TCPProto;
25     };
26     return NULL;
27 }