1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

[SMACK-223] - Added Window Listener to handle Session Closes

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@8215 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Thiago Camargo 2007-05-08 20:50:18 +00:00 committed by thiago
parent 925bd389c2
commit 904379fd52
3 changed files with 22 additions and 1 deletions

View file

@ -31,6 +31,9 @@ import org.jivesoftware.smackx.jingle.IncomingJingleSession;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
@ -81,7 +84,11 @@ public class ScreenShareSession extends JingleMediaSession {
window.setLocation(0, 0);
window.setSize(600, 600);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.addWindowListener(new WindowAdapter(){
public void windowClosed(WindowEvent e) {
receiver.stop();
}
});
try {
receiver = new ImageReceiver(InetAddress.getByName("0.0.0.0"), getRemote().getPort(), getLocal().getPort(), width, height);

View file

@ -142,4 +142,9 @@ public class ImageReceiver extends Canvas {
public void setDecoder(ImageDecoder decoder) {
this.decoder = decoder;
}
public void stop(){
this.on=false;
socket.close();
}
}

View file

@ -177,4 +177,13 @@ public class ImageTransmitter implements Runnable {
public void setEncoder(ImageEncoder encoder) {
this.encoder = encoder;
}
/**
* Stops Transmitter
*/
public void stop(){
this.transmit=false;
this.on=false;
socket.close();
}
}