Re: [reSIProcate] Request for symbols definition (WS and WSS)
On 17/09/13 18:20, Scott Godin wrote:
> I think having those symbols in there is good. They don't necessarily
> need to be used by an application. The stack itself should be using
> these symbols (this part needs work). It provides a slight footprint
> optimization over using static "WS" strings throughout the code.
I agree with having symbols shared like that, just not keeping them all
in one header file and without representing the context in which they
should be used.
E.g. we also have this in TransportType.cxx:
static const Data transportNames[MAX_TRANSPORT] =
{
Data("UNKNOWN_TRANSPORT"),
Data("TLS"),
Data("TCP"),
Data("UDP"),
Data("SCTP"),
Data("DCCP"),
Data("DTLS"),
Data("WS"),
Data("WSS")
};
We could go further, making TransportType into a class instead of an enum:
class TransportType
{
public:
TransportType(const char* name, bool secure, bool reliable);
const char* name() { return mName; };
bool isSecure() { return mSecure; };
....
....
and then create some singletons TransportType::TLS, TransportType::WS,
etc (just like Java enum types). A pointer to a TransportType instance
would be about as efficient as a pointer to a string, but it would
always be clear whether we are working with a TransportType or a URI
prefix or whatever type of symbol.