mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 18:48:00 +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:
parent
925bd389c2
commit
904379fd52
3 changed files with 22 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue