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

fix some point not conforming to SIP specification #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ peers-demo/src/main/java/net/sourceforge/peers/demo/MyConfig.java
\#*#
bin/
logs/
.idea
*.iml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.sourceforge.peers.sip.transaction.ClientTransaction;
import net.sourceforge.peers.sip.transaction.ClientTransactionUser;
import net.sourceforge.peers.sip.transaction.NonInviteClientTransaction;
import net.sourceforge.peers.sip.transaction.NonInviteServerTransaction;
import net.sourceforge.peers.sip.transaction.ServerTransaction;
import net.sourceforge.peers.sip.transaction.ServerTransactionUser;
import net.sourceforge.peers.sip.transaction.Transaction;
Expand Down Expand Up @@ -103,7 +104,11 @@ public void handleBye(SipRequest sipRequest, Dialog dialog) {

serverTransaction.sendReponse(sipResponse);

dialogManager.removeDialog(dialog.getId());
// repeat with line 78.
// reply ACK to server, when get BYE signal
if (serverTransaction instanceof NonInviteServerTransaction) {
((NonInviteServerTransaction)serverTransaction).sendLastResponse();
}

SipListener sipListener = userAgent.getSipListener();
if (sipListener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public InviteClientTransactionStateTerminated(String id,
super(id, inviteClientTransaction, logger);
}

@Override
public void received2xx() {
// when receive 2xx, reply ACK to server, In case some server think this call not succeed, and terminate this call
logger.info("received 2xx on terminated.");
inviteClientTransaction.createAndSendAck();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void sendReponse(SipResponse sipResponse) {
}
}

void sendLastResponse() {
public void sendLastResponse() {
//sipServerTransport.sendResponse(responses.get(responses.size() - 1));
int nbOfResponses = responses.size();
if (nbOfResponses > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public abstract class MessageReceiver implements Runnable {
private Config config;
protected Logger logger;

protected long stopTime = -1L;

public MessageReceiver(int port, TransactionManager transactionManager,
TransportManager transportManager, Config config, Logger logger) {
super();
Expand All @@ -64,7 +66,8 @@ public MessageReceiver(int port, TransactionManager transactionManager,
}

public void run() {
while (isListening) {
// delay to hang up the call when send CANCEL, the server will answer 487, then hang up, in case the server constantly answer 487 with no response
while (isListening || (stopTime > 0 && System.currentTimeMillis() - stopTime < 100)) {
try {
listen();
} catch (IOException e) {
Expand Down Expand Up @@ -187,7 +190,12 @@ protected void processMessage(byte[] message, InetAddress sourceIp,
}

public synchronized void setListening(boolean isListening) {
logger.info("execute stop listen ...");
this.isListening = isListening;

if(!isListening){
this.stopTime = System.currentTimeMillis();
}
}

public synchronized boolean isListening() {
Expand Down