Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register eventhandler in Poco:Net:SocketConnector subclass #161

Closed
hydrasim opened this issue Apr 26, 2013 · 4 comments
Closed

Register eventhandler in Poco:Net:SocketConnector subclass #161

hydrasim opened this issue Apr 26, 2013 · 4 comments

Comments

@hydrasim
Copy link

There is a problem when trying to register eventhandlers in an override of the SocketConnector::registerConnector method in a SocketConnector subclass.

SocketConnector::registerConnector is called from the SocketConnector class constructor and since the object is not yet an instance of the derived class, it is still an instance of the base class, the registerConnector method in the derived class is not called.

@aleks-f
Copy link
Member

aleks-f commented Apr 26, 2013

the registerConnector method in the derived class is not called.

If you need to register additional event handlers, you can create SocketConnector (without reactor) first and then explicitly call registerConnector on it. If you really, really insist on doing it at construction time - since you already have the reactor, why not call addEventHandler() on it directly for your desired additional handlers?

@hydrasim
Copy link
Author

Thank's for the suggestions, there is always another way to get there. Since I'm just playing around it really doesn't matter for me right now but for someone else maybe.

I read the comment in the code, included below, and thought it would work to override and register an eventhandler but the "The overriding method must call the baseclass implementation first." does not work for the case I tried because of how object instantiation works.

    /// Registers the SocketConnector with a SocketReactor.
    ///
    /// A subclass can override this and, for example, also register
    /// an event handler for a timeout event.
    ///
    /// The overriding method must call the baseclass implementation first.

@hydrasim
Copy link
Author

Why is this labeled as a question and not bug? It's not working as it's supposed to.

@obiltschnig
Copy link
Member

@aleks-f can you look into this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants