opentelecoms-org / jsmpp

SMPP implemented in Java
Apache License 2.0
232 stars 164 forks source link

Can we attach listeners after bind? #140

Open javadevmtl opened 4 years ago

javadevmtl commented 4 years ago

Hi, in the server example you attach the session listeners after the server has accepted the connection.

Is it ok to attach the listener after session.waitForBind() and we verified the password?

For example:

BindRequest bindRequest = serverSession.waitForBind(5000);

// Get some configs from DB based on getSystemId and getPassword here

if (systemId.equals(bindRequest.getSystemId())) {
    if (password.equals(bindRequest.getPassword())) {
        serverSession.setMessageReceiverListener(new MyMessageListener(CONFIG_FROM_DB_HERE)));
    }
}
pmoerenhout commented 3 years ago

I think that is possible. Did you try it ? If you only want 1 instance of the listener, I would instantiate it earlier and just set it whenever appropriate. Otherwise you have a separate listener object for each bind.