66
77namespace SL {
88 namespace WS_LITE {
9+ template <typename T, typename Meaning>
10+ struct Explicit
11+ {
12+ Explicit () { }
13+ Explicit (T value) : value(value) { }
14+ inline operator T () const { return value; }
15+ T value;
16+ };
17+ namespace INTERNAL {
18+ struct PorNumbertTag { };
19+ struct ThreadCountTag { };
20+ }
21+
22+ typedef Explicit<unsigned short , INTERNAL::PorNumbertTag> PortNumber;
23+ typedef Explicit<unsigned short , INTERNAL::ThreadCountTag> ThreadCount;
924
1025 const auto HTTP_METHOD = " Method" ;
1126 const auto HTTP_PATH = " Path" ;
@@ -47,7 +62,8 @@ namespace SL {
4762 struct WSocketImpl ;
4863 struct WSocket {
4964 std::shared_ptr<WSocketImpl> WSocketImpl_;
50-
65+ WSocket (const std::shared_ptr<WSocketImpl>& s) :WSocketImpl_(s){}
66+ WSocket () {}
5167 // can be used to compare two WSocket objects
5268 bool operator =(const WSocket& s) { return s.WSocketImpl_ == WSocketImpl_; }
5369 bool is_open ();
@@ -57,8 +73,7 @@ namespace SL {
5773 bool is_v6 ();
5874 bool is_loopback ();
5975 operator bool () const { return WSocketImpl_.operator bool (); }
60- friend WSListener;
61- friend WSClient;
76+
6277 };
6378 class WSListenerImpl ;
6479 class WSListener {
@@ -107,10 +122,11 @@ namespace SL {
107122 // start the process to listen for clients. This is non-blocking and will return immediatly
108123 void startlistening ();
109124 // factory to create listeners. Use this if you ARE NOT using TLS
110- static WSListener CreateListener (unsigned short port);
125+ static WSListener CreateListener (ThreadCount threadcount, PortNumber port);
111126 // factory to create listeners. Use this if you ARE using TLS
112127 static WSListener CreateListener (
113- unsigned short port,
128+ ThreadCount threadcount,
129+ PortNumber port,
114130 std::string Password,
115131 std::string Privatekey_File,
116132 std::string Publiccertificate_File,
@@ -161,11 +177,11 @@ namespace SL {
161177 // send a close message and close the socket
162178 void close (const WSocket& s, unsigned short code = 1000 , const std::string& msg = " " );
163179 // connect to an endpoint. This is non-blocking and will return immediatly. If the library is unable to establish a connection, ondisconnection will be called.
164- void connect (const char * host, unsigned short port);
180+ void connect (const char * host, PortNumber port);
165181 // factory to create clients. Use this if you ARE NOT using TLS
166- static WSClient CreateClient ();
182+ static WSClient CreateClient (ThreadCount threadcount );
167183 // factory to create clients. Use this if you ARE using TLS
168- static WSClient CreateClient (std::string Publiccertificate_File);
184+ static WSClient CreateClient (ThreadCount threadcount, std::string Publiccertificate_File);
169185 };
170186 }
171187}
0 commit comments