Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2c155a2fa | ||
|
|
eff5fd2f12 | ||
|
|
076b4fcb43 | ||
|
|
d22b95e74f | ||
|
|
c89061db2e |
No files matched your search
@@ -1,7 +0,0 @@
|
||||
/pitiupi/build/
|
||||
/pitiupi/dist/
|
||||
/pitiupi.chat/build/
|
||||
/pitiupi.chat/dist/
|
||||
/pitiupi.chat/nbproject/private/
|
||||
/pitiupi.screenCast/build/
|
||||
/pitiupi.screenCast/dist/
|
||||
@@ -1,6 +1,6 @@
|
||||
#Fri, 17 Jul 2026 17:31:55 -0300
|
||||
#Thu, 16 Jul 2026 15:21:36 -0300
|
||||
|
||||
|
||||
/home/perolanegra/facul/pitiupi/pitiupi.chat=
|
||||
/home/flavio/NetBeansProjects/pitiupi.chat=
|
||||
|
||||
/home/perolanegra/facul/pitiupi/pitiupi=
|
||||
/home/flavio/NetBeansProjects/pitiupi=
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -47,8 +47,8 @@ javac.modulepath=
|
||||
javac.processormodulepath=
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=21
|
||||
javac.target=21
|
||||
javac.source=25
|
||||
javac.target=25
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
||||
@@ -5,16 +5,18 @@
|
||||
*/
|
||||
package pitiupi.chat.GUI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import pitiupi.chat.net.ChatMessage;
|
||||
import pitiupi.plugin.PitiupiFacade;
|
||||
import pitiupi.GUI.MainWindow;
|
||||
import pitiupi.net.Message;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author flavio
|
||||
* @author tony
|
||||
*/
|
||||
public class ChatWindow extends javax.swing.JDialog {
|
||||
|
||||
@@ -27,10 +29,10 @@ public class ChatWindow extends javax.swing.JDialog {
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JTextArea jTextArea1;
|
||||
|
||||
private final PitiupiFacade pitiupi;
|
||||
private final MainWindow mainWindow;
|
||||
|
||||
public ChatWindow(PitiupiFacade pitiupi) {
|
||||
this.pitiupi = pitiupi;
|
||||
public ChatWindow(MainWindow mainWindow) {
|
||||
this.mainWindow = mainWindow;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -92,13 +94,17 @@ public class ChatWindow extends javax.swing.JDialog {
|
||||
if (jTextArea1.getText().trim().length() == 0) {
|
||||
return;
|
||||
}
|
||||
ChatMessage message = new ChatMessage(pitiupi.getUserName(), jTextArea1.getText());
|
||||
ChatMessage message = new ChatMessage(mainWindow.getName(), jTextArea1.getText());
|
||||
this.sendChatMessage(message);
|
||||
jTextArea1.setText("");
|
||||
}
|
||||
|
||||
public void sendChatMessage(Message message) {
|
||||
pitiupi.send(message);
|
||||
try {
|
||||
mainWindow.getSocket().send(message.toByteArray());
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void receiveChatMessage(ChatMessage message) {
|
||||
|
||||
@@ -7,7 +7,7 @@ package pitiupi.chat.plugin;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import pitiupi.plugin.PitiupiFacade;
|
||||
import pitiupi.GUI.MainWindow;
|
||||
import pitiupi.chat.GUI.ChatMenu;
|
||||
import pitiupi.chat.GUI.ChatWindow;
|
||||
import pitiupi.chat.net.ChatMessage;
|
||||
@@ -17,18 +17,20 @@ import pitiupi.plugin.Plugin;
|
||||
/**
|
||||
*
|
||||
* @author flavio
|
||||
* @author tony
|
||||
*/
|
||||
public class ChatPlugin implements Plugin {
|
||||
|
||||
private ChatWindow chatWindow;
|
||||
private PitiupiFacade pitiupi;
|
||||
private MainWindow mainWindow;
|
||||
|
||||
public ChatPlugin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPlugin(PitiupiFacade pitiupi) {
|
||||
this.pitiupi = pitiupi;
|
||||
this.chatWindow = new ChatWindow(pitiupi);
|
||||
this.pitiupi.addMenu(new ChatMenu(chatWindow));
|
||||
public void createPlugin(MainWindow mainWindow) {
|
||||
this.mainWindow = mainWindow;
|
||||
this.chatWindow = new ChatWindow(mainWindow);
|
||||
this.mainWindow.addMenu(new ChatMenu(chatWindow));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Thu, 16 Jul 2026 17:43:45 -0300
|
||||
#Thu, 16 Jul 2026 15:21:39 -0300
|
||||
|
||||
|
||||
/home/perolanegra/facul/2.26/fls/pitiupi/pitiupi.screenCast=
|
||||
/home/flavio/NetBeansProjects/pitiupi.screenCast=
|
||||
|
||||
/home/perolanegra/facul/2.26/fls/pitiupi/pitiupi=
|
||||
/home/flavio/NetBeansProjects/pitiupi=
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,7 @@ JAR files manifest file (MANIFEST.MF).
|
||||
To run the project from the command line, go to the dist folder and
|
||||
type the following:
|
||||
|
||||
java -jar "pitiupi.jar"
|
||||
java -jar "pitiupi.screenCast.jar"
|
||||
|
||||
To distribute this project, zip up the dist folder (including the lib folder)
|
||||
and distribute the ZIP file.
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -45,8 +45,8 @@ javac.modulepath=
|
||||
javac.processormodulepath=
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=21
|
||||
javac.target=21
|
||||
javac.source=25
|
||||
javac.target=25
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# NetBeans
|
||||
/build/
|
||||
/dist/
|
||||
/nbproject/private/
|
||||
|
||||
# Java compilado
|
||||
*.class
|
||||
|
||||
# JARs gerados
|
||||
*.jar
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -5,4 +5,4 @@ do.jlink=false
|
||||
javac.debug=true
|
||||
javadoc.preview=true
|
||||
jlink.strip=false
|
||||
user.properties.file=/home/perolanegra/snap/netbeans/145/build.properties
|
||||
user.properties.file=/home/flavio/snap/netbeans/145/build.properties
|
||||
@@ -2,6 +2,9 @@
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
<group>
|
||||
<file>file:/home/flavio/NetBeansProjects/pitiupi/src/pitiupi/control/PluginManager.java</file>
|
||||
<file>file:/home/flavio/NetBeansProjects/pitiupi/src/pitiupi/control/ImageTransformation.java</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
@@ -46,8 +46,8 @@ javac.modulepath=
|
||||
javac.processormodulepath=
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=21
|
||||
javac.target=21
|
||||
javac.source=25
|
||||
javac.target=25
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../pitiupi.screenCast/dist/pitiupi.screenCast.jar
|
||||
@@ -16,6 +16,7 @@ import pitiupi.control.HeartbeatManager;
|
||||
/**
|
||||
*
|
||||
* @author flavio
|
||||
* @author tony
|
||||
*/
|
||||
public class MainWindow extends javax.swing.JFrame {
|
||||
|
||||
@@ -24,9 +25,11 @@ public class MainWindow extends javax.swing.JFrame {
|
||||
private javax.swing.JLabel status;
|
||||
private javax.swing.JPanel statusPanel;
|
||||
private javax.swing.JTabbedPane tabbedPane;
|
||||
|
||||
private HeartbeatManager heartbeatManager;
|
||||
private OnlineUsersPanel onlineUsersPanel;
|
||||
|
||||
|
||||
private Socket socket;
|
||||
|
||||
private final String userName;
|
||||
@@ -66,7 +69,7 @@ public class MainWindow extends javax.swing.JFrame {
|
||||
|
||||
this.socket = new Socket(this);
|
||||
this.socket.start();
|
||||
|
||||
|
||||
this.heartbeatManager = new HeartbeatManager(this);
|
||||
this.onlineUsersPanel = new OnlineUsersPanel();
|
||||
this.heartbeatManager.addPeerListener(this.onlineUsersPanel);
|
||||
|
||||
@@ -11,7 +11,10 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import pitiupi.control.PeerInfo;
|
||||
import pitiupi.control.PeerListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tony
|
||||
*/
|
||||
public class OnlineUsersPanel extends JPanel implements PeerListener {
|
||||
|
||||
private final DefaultListModel<String> listModel;
|
||||
|
||||
@@ -14,7 +14,10 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import pitiupi.GUI.MainWindow;
|
||||
import pitiupi.net.HeartbeatMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tony
|
||||
*/
|
||||
public class HeartbeatManager {
|
||||
|
||||
private static final long HEARTBEAT_INTERVAL_MS = 5000;
|
||||
@@ -52,7 +55,7 @@ public class HeartbeatManager {
|
||||
|
||||
// Chamado pelo Socket quando um pacote é identificado como heartbeat
|
||||
public void receiveHeartbeat(HeartbeatMessage msg, InetAddress from) {
|
||||
// ignora o próprio heartbeat (multicast normalmente ecoa pro remetente)
|
||||
// ignora o próprio heartbeat
|
||||
if (msg.getUserName().equals(mainWindow.getUserName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package pitiupi.control;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tony
|
||||
*/
|
||||
public class PeerInfo {
|
||||
|
||||
private final String userName;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package pitiupi.control;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tony
|
||||
*/
|
||||
public interface PeerListener {
|
||||
void onPeersChanged(List<PeerInfo> peers);
|
||||
}
|
||||
@@ -15,11 +15,10 @@ import java.util.Vector;
|
||||
import pitiupi.GUI.MainWindow;
|
||||
import pitiupi.Main;
|
||||
import pitiupi.plugin.Plugin;
|
||||
import pitiupi.plugin.PitiupiFacade;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author flavio
|
||||
* @author tony
|
||||
*/
|
||||
public class PluginLoader {
|
||||
|
||||
@@ -56,14 +55,12 @@ public class PluginLoader {
|
||||
// 4. Locate and instantiate all classes implementing the Plugin interface
|
||||
ServiceLoader<Plugin> serviceLoader = ServiceLoader.load(Plugin.class, pluginClassLoader);
|
||||
|
||||
PitiupiFacade facade = new PitiupiFacade(this.mainWindow);
|
||||
|
||||
System.out.println("\n--- Executing Discovered Plugins ---" + serviceLoader.findFirst());
|
||||
for (Plugin plugin : serviceLoader) {
|
||||
System.out.println("Loading: " + plugin.getName());
|
||||
plugin.createPlugin(facade);
|
||||
this.mainWindow.getPlugins().add(plugin);
|
||||
}
|
||||
System.out.println("\n--- Executing Discovered Plugins ---" + serviceLoader.findFirst());
|
||||
for (Plugin plugin : serviceLoader) {
|
||||
System.out.println("Loading: " + plugin.getName());
|
||||
plugin.createPlugin(this.mainWindow);
|
||||
this.mainWindow.getPlugins().add(plugin);
|
||||
}
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println(e.toString());
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package pitiupi.net;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tony
|
||||
*/
|
||||
public class HeartbeatMessage extends Message {
|
||||
|
||||
private final String userName;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Line truncated
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
|
||||
@@ -17,9 +17,8 @@ import java.net.UnknownHostException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import pitiupi.plugin.Plugin;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.InetSocketAddress;
|
||||
import pitiupi.net.HeartbeatMessage; // lib
|
||||
import pitiupi.net.HeartbeatMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author flavio
|
||||
@@ -44,45 +43,7 @@ public class Socket extends Thread {
|
||||
multicastSocket.setSendBufferSize(256000);
|
||||
multicastSocket.setReceiveBufferSize(256000);
|
||||
multicastSocket.setReuseAddress(true);
|
||||
System.out.println("Endereço local: " + multicastSocket.getLocalAddress());
|
||||
System.out.println("Interface: " + multicastSocket.getNetworkInterface());
|
||||
//InetAddress local = InetAddress.getLocalHost();
|
||||
|
||||
NetworkInterface nif = null;
|
||||
|
||||
for (NetworkInterface ni : java.util.Collections.list(
|
||||
NetworkInterface.getNetworkInterfaces())) {
|
||||
|
||||
if (ni.isUp()
|
||||
&& ni.supportsMulticast()
|
||||
&& !ni.isLoopback()) {
|
||||
|
||||
nif = ni;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nif != null) {
|
||||
System.out.println("Interface escolhida:");
|
||||
System.out.println("Nome: " + nif.getName());
|
||||
System.out.println("Descrição: " + nif.getDisplayName());
|
||||
System.out.println("Ativa: " + nif.isUp());
|
||||
System.out.println("Multicast: " + nif.supportsMulticast());
|
||||
|
||||
System.out.println("Endereços IP:");
|
||||
|
||||
for (InetAddress ip : java.util.Collections.list(nif.getInetAddresses())) {
|
||||
System.out.println(" " + ip.getHostAddress());
|
||||
}
|
||||
} else {
|
||||
System.out.println("Nenhuma interface multicast encontrada");
|
||||
}
|
||||
multicastSocket.joinGroup(
|
||||
new InetSocketAddress(address, main.getPort()),
|
||||
nif
|
||||
);
|
||||
System.out.println("nif: " + nif);
|
||||
|
||||
// multicastSocket.joinGroup(address);
|
||||
multicastSocket.joinGroup(address);
|
||||
} catch (IOException ex) {
|
||||
System.out.println("There is no socket connection. Sorry.");
|
||||
System.out.println(ex.toString());
|
||||
@@ -92,15 +53,9 @@ public class Socket extends Thread {
|
||||
public void send(byte[] msg) throws IOException {
|
||||
DatagramPacket msgPacket;
|
||||
msgPacket = new DatagramPacket(msg, msg.length, this.address, this.main.getPort());
|
||||
|
||||
System.out.println("Enviando pacote");
|
||||
System.out.println("Destino: " + address);
|
||||
System.out.println("Porta: " + this.main.getPort());
|
||||
System.out.println("Bytes: " + msg.length);
|
||||
|
||||
multicastSocket.send(msgPacket);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
public void receive() throws UnknownHostException, IOException, ClassNotFoundException {
|
||||
byte[] buf = new byte[256000];
|
||||
while (true) {
|
||||
@@ -119,7 +74,7 @@ public class Socket extends Thread {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private HeartbeatMessage tryParseHeartbeat(byte[] data) {
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||
@@ -130,7 +85,7 @@ public class Socket extends Thread {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package pitiupi.plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.swing.JMenu;
|
||||
import pitiupi.GUI.MainWindow;
|
||||
import pitiupi.net.Message;
|
||||
|
||||
public class PitiupiFacade {
|
||||
|
||||
private final MainWindow mainWindow;
|
||||
|
||||
public PitiupiFacade(MainWindow mainWindow) {
|
||||
this.mainWindow = mainWindow;
|
||||
}
|
||||
|
||||
public void addMenu(JMenu menu) {
|
||||
mainWindow.addMenu(menu);
|
||||
}
|
||||
|
||||
public void send(Message message) {
|
||||
try {
|
||||
mainWindow.getSocket().send(message.toByteArray());
|
||||
} catch (IOException ex) {
|
||||
System.out.println("Falha ao enviar mensagem: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return mainWindow.getUserName();
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return mainWindow.getPort();
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,20 @@
|
||||
*/
|
||||
package pitiupi.plugin;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import pitiupi.GUI.MainWindow;
|
||||
import pitiupi.net.Message;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author flavio
|
||||
* @author tony
|
||||
*/
|
||||
public interface Plugin {
|
||||
|
||||
public String getName();
|
||||
public String getAuthor();
|
||||
public String getVersion();
|
||||
public void createPlugin(PitiupiFacade pitiupi);
|
||||
public void createPlugin(MainWindow window);
|
||||
public Message getMessage();
|
||||
public void receiveMessage(byte[] message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user