From d62c870ffb1bf02e4be65183f3ae4bbe2229fbb2 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Tue, 16 Oct 2018 14:53:27 +0100 Subject: Store the type of a StreamSocket within itself. Similar to with IOHooks this allows you to convert StreamSocket to a UserIOHandler quickly. --- include/inspsocket.h | 14 +++++++++++++- include/users.h | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/inspsocket.h b/include/inspsocket.h index d88c350ba..e432f9c16 100644 --- a/include/inspsocket.h +++ b/include/inspsocket.h @@ -219,6 +219,13 @@ class CoreExport StreamSocket : public EventHandler size_t nbytes; }; + /** The type of socket this IOHook represents. */ + enum Type + { + SS_UNKNOWN, + SS_USER + }; + private: /** The IOHook that handles raw I/O for this socket, or NULL */ IOHook* iohook; @@ -264,7 +271,12 @@ class CoreExport StreamSocket : public EventHandler protected: std::string recvq; public: - StreamSocket() : iohook(NULL) { } + const Type type; + StreamSocket(Type sstype = SS_UNKNOWN) + : iohook(NULL) + , type(sstype) + { + } IOHook* GetIOHook() const; void AddIOHook(IOHook* hook); void DelIOHook(); diff --git a/include/users.h b/include/users.h index 4aed944ee..28b370725 100644 --- a/include/users.h +++ b/include/users.h @@ -683,7 +683,11 @@ class CoreExport UserIOHandler : public StreamSocket { public: LocalUser* const user; - UserIOHandler(LocalUser* me) : user(me) {} + UserIOHandler(LocalUser* me) + : StreamSocket(StreamSocket::SS_USER) + , user(me) + { + } void OnDataReady() CXX11_OVERRIDE; void OnSetEndPoint(const irc::sockets::sockaddrs& local, const irc::sockets::sockaddrs& remote) CXX11_OVERRIDE; void OnError(BufferedSocketError error) CXX11_OVERRIDE; -- cgit v1.3.1-10-gc9f91