Fix sequence checking logic
- Sequence checking logic is currently broken.
- When getNextSequence() is called, it returns ascii character equivalent to this.sequence-1.
- This sequence character is used in the request sent to library ACS.
- When StrictSequenceChecking is enabled, response sequence number character should be same as
the request sequence number character.
- Current implementation checks the response sequence character against the incremented
sequence number character (to be used for next request) and results in exception.
SIP2 Error Handling using Sequence Number:
- the sequence number field’s value of the response should match the sequence number value from the message being responded to.
- Increment and return the incremented sequence number character.
- Now equality holds for sequence number characters of request and subsequent response.
- use StringBuilder; recommended for single threaded operations.
- do not convert string buffer to String every time to check the lastIndexOf, use the method provided
by StringBuffer/StringBuilder class.
- Make SocketConnection autoclosable, so that it could be closed automatically when used with try-with-resource block.