SMPPServerSessionListener sessionListener = new SMPPServerSessionListener(8056);
// set all default ServerMessageReceiverListener for all accepted SMPPServerSessionListener
sessionListener.setMessageReceiverListener(messageReceiverListener);
// accepting connection, session still in OPEN state
SMPPServerSession session = sessionListener.accept();
// or we can set for each accepted session session.setMessageReceiverListener(messageReceiverListener)
System.out.println("Accept connection");
try {
BindRequest request = session.waitForBind(5000);
System.out.println("Receive bind request");
if (request.getSystemId().equals("test") &&
request.getPassword().equals("test")) {
// accepting request and send bind response immediately
System.out.println("Accepting bind request");
request.accept("sys");
try { Thread.sleep(20000); } catch (InterruptedException e) {}
} else {
System.out.println("Rejecting bind request");
request.reject(SMPPConstant.STAT_ESME_RINVPASWD);
}
} catch (TimeoutException e) {
System.out.println("No binding request made after 5000 millisecond");
e.printStackTrace();
}
System.out.println("Closing session");
session.unbindAndClose();
System.out.println("Closing session listener");
sessionListener.close();
} catch (PDUStringException e) {
e.printStackTrace();
} catch (IOException e) {