Commit a5614d43 authored by mohammad.salama's avatar mohammad.salama

Sumbission Edition

parent 93f4628c
......@@ -6,6 +6,9 @@
<component name="ChangeListManager">
<list default="true" id="71bec43c-ef6e-431f-a77c-2b7f124f5fea" name="Changes" comment="printing Done">
<change beforePath="$PROJECT_DIR$/../ChatServer/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatServer/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatServer/src/main/java/IClientChat.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatServer/src/main/java/IClientChat.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatServer/src/main/java/IServerChat.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatServer/src/main/java/IServerChat.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatServer/src/main/java/ServerChatImp.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatServer/src/main/java/ServerChatImp.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -34,15 +37,18 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;UI_DESIGNER_EDITOR_MODE.PaletteManager.WIDTH&quot;: &quot;132&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/HIAST/FIY/FS/Distributed Systems/Lab/3/HW/ChatClient&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"UI_DESIGNER_EDITOR_MODE.PaletteManager.WIDTH": "132",
"last_opened_file_path": "D:/HIAST/FIY/FS/Distributed Systems/Lab/3/HW/ChatServer",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0"
}
}</component>
}]]></component>
<component name="RunManager" selected="Application.Client2">
<configuration name="Client1" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="ChatClient" />
......
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="AllChatRooms">
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="7927a" class="javax.swing.JButton" binding="GOBack">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Return To Main Menu"/>
</properties>
</component>
<vspacer id="c252f">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.rmi.RemoteException;
import java.util.List;
public class AllChatRooms extends JFrame {
private JButton GOBack;
private JPanel buttonPanel;
private JScrollPane scrollPane;
public AllChatRooms(ClientChatImp clientChatImp)
{
try {
setTitle("All Chat Rooms ( " + clientChatImp.getUserName()+" )");
} catch (RemoteException e) {
throw new RuntimeException(e);
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(600 , 600);
// Create a list of strings
List<String> stringList = null;
try {
stringList = clientChatImp.getAllChatRooms();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
// Create a panel to hold the buttons
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(0, 1));
// Create buttons for each string in the list
for (String str : stringList) {
JButton button = new JButton(str);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try
{
int choice = JOptionPane.showConfirmDialog(null , "Do You Want to join Room " + button.getText() + " ?");
if (choice == 0)
{
clientChatImp.joinChatRoom(button.getText());
doit(clientChatImp , button.getText());
}
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
buttonPanel.add(button);
}
buttonPanel.add(GOBack);
// Create a scroll pane for the button panel
scrollPane = new JScrollPane(buttonPanel);
// Add the scroll pane to the main frame
add(scrollPane, BorderLayout.CENTER);
pack();
setVisible(true);
GOBack.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
try {
gotoMain(clientChatImp);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
}
private void doit(ClientChatImp clientChatImp ,String roomname) throws RemoteException
{
MessagesInChat conversationInChat = new MessagesInChat(clientChatImp , roomname);
this.dispose();
}
private void gotoMain(ClientChatImp clientChatImp) throws RemoteException {
MainPanel mainPanel = new MainPanel(clientChatImp);
this.dispose();
}
}
import javax.swing.*;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
......@@ -59,7 +60,8 @@ public class ChatClient
return clientChatImps;
}
public static void main(String[] args) throws MalformedURLException, NotBoundException, RemoteException {
public static void main(String[] args) throws MalformedURLException, NotBoundException, RemoteException
{
String loc = "localhost";
Registeration registeration = new Registeration(loc);
/* List<ClientChatImp> clientChatImps = prevTest();
......
......@@ -3,6 +3,7 @@ import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -13,6 +14,9 @@ public class ClientChatImp extends UnicastRemoteObject implements IClientChat
IServerChat iServerChat;
Map<String,MessagesInChat> messagesInChat = new HashMap<>();
Map<IClientChat , PersonalChats> personalChat= new HashMap<>();
Map<IClientChat , List<String>> texts = new HashMap<>();
public ClientChatImp(String firstName , String lastName , String userName ,
String password , String server)
......@@ -23,6 +27,11 @@ public class ClientChatImp extends UnicastRemoteObject implements IClientChat
this.password = password;
this.iServerChat = (IServerChat) Naming.lookup("rmi://"+server+":1099/chat");
}
public void setPC( IClientChat other , PersonalChats personalChats)
{
personalChat.put(other , personalChats);
texts.put(other , new ArrayList<>());
}
public void setMIC(MessagesInChat messagesInChat , String roomName)
{
this.messagesInChat.put(roomName , messagesInChat);
......@@ -37,7 +46,32 @@ public class ClientChatImp extends UnicastRemoteObject implements IClientChat
///System.out.println(Message + " in Room : " + roomName);
return Message;
}
public void multiCastMessage(String message , List<IClientChat> iClientChats ) throws RemoteException
{
iServerChat.multiCastMessage(message , this , iClientChats);
}
public String receiveMessage(String Message , IClientChat iClientChat) throws RemoteException
{
System.out.println("RECEIVING");
if (this.personalChat.containsKey(iClientChat))
{
texts.get(iClientChat).add(Message);
this.personalChat.get(iClientChat).receiveMsg(Message);
}
else
{
this.personalChat.put(iClientChat , new PersonalChats(iClientChat , this));
this.personalChat.get(iClientChat).receiveMsg(Message);
}
return Message;
}
public List<IClientChat> getAllUsersInRoom(String roomName) throws RemoteException
{
return iServerChat.getAllUsersInRoom(this , roomName);
}
@Override
public String getUserName() throws RemoteException
{
......@@ -89,4 +123,8 @@ public class ClientChatImp extends UnicastRemoteObject implements IClientChat
System.out.println("Sending MSG");
iServerChat.sendMessage(roomName , message , this);
}
public List<String> getAllChatRooms() throws RemoteException
{
return iServerChat.getAllChatRooms(this);
}
}
......@@ -5,7 +5,7 @@ public interface IClientChat extends Remote
{
public String receiveMessage(String Message, String roomName) throws RemoteException;
public String receiveMessage(String Message , IClientChat iClientChat) throws RemoteException;
/// public Boolean checkPassword (String password) throws RemoteException;
public String getUserName () throws RemoteException;
}
......@@ -21,6 +21,12 @@ public interface IServerChat extends Remote
public void sendMessage(String roomName, String message , IClientChat iClientChat ) throws RemoteException;
public void multiCastMessage(String message ,IClientChat iClientChat , List<IClientChat> iClientChats ) throws RemoteException;
public boolean LogOut(IClientChat iClientChat) throws RemoteException;
public List<String> getAllChatRooms(IClientChat iClientChat) throws RemoteException;
public List<IClientChat> getAllUsersInRoom(IClientChat iClientChat , String roomName) throws RemoteException;
}
......@@ -2,6 +2,7 @@ import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.rmi.RemoteException;
import java.util.Optional;
public class JoiningChatRoom extends JFrame{
private JPanel JoiningChatRoom;
......@@ -68,4 +69,5 @@ public class JoiningChatRoom extends JFrame{
MainPanel mainPanel = new MainPanel(clientChatImp);
this.dispose();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="MainPanel">
<grid id="27dc6" binding="MyChats" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="MyChats" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
......@@ -34,7 +34,7 @@
</component>
<component id="32a91" class="javax.swing.JButton" binding="LogOut">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Log Out"/>
......@@ -48,6 +48,14 @@
<text value="View My Chats"/>
</properties>
</component>
<component id="398d4" class="javax.swing.JButton" binding="AllChatRroms">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="View All Chat Rooms"/>
</properties>
</component>
</children>
</grid>
</form>
......@@ -10,6 +10,7 @@ public class MainPanel extends JFrame{
private JButton DeleteRoom;
private JButton LogOut;
private JButton ViewChats;
private JButton AllChatRroms;
public MainPanel(ClientChatImp clientChatImp) throws RemoteException {
setContentPane(MyChats);
......@@ -54,8 +55,20 @@ public class MainPanel extends JFrame{
viewChatRoom(clientChatImp);
}
});
AllChatRroms.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
seeAllRooms(clientChatImp);
}
});
}
public void seeAllRooms(ClientChatImp clientChatImp)
{
AllChatRooms allChatRooms = new AllChatRooms(clientChatImp);
this.dispose();
}
public void viewChatRoom(ClientChatImp clientChatImp)
{
MyChatRooms myChatRooms = new MyChatRooms(clientChatImp);
......
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="MessagesInChat">
<grid id="27dc6" binding="Conversation" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="Conversation" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
......@@ -10,7 +10,7 @@
<children>
<component id="c00f6" class="javax.swing.JTextField" binding="Message">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
......@@ -20,7 +20,7 @@
</component>
<component id="d460b" class="javax.swing.JButton" binding="SendMessage">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Send"/>
......@@ -28,7 +28,7 @@
</component>
<scrollpane id="a440e">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
......@@ -47,6 +47,14 @@
<text value="Return to main menu"/>
</properties>
</component>
<component id="e23c0" class="javax.swing.JButton" binding="viewUsersButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="View Users"/>
</properties>
</component>
</children>
</grid>
</form>
......@@ -3,7 +3,6 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.rmi.RemoteException;
import java.util.List;
import java.util.Map;
public class MessagesInChat extends JFrame {
private JTextField Message;
......@@ -11,6 +10,7 @@ public class MessagesInChat extends JFrame {
private JTextArea Texts;
private JPanel Conversation;
private JButton MainMenu;
private JButton viewUsersButton;
private String roomName= "";
public MessagesInChat(ClientChatImp clientChatImp , String roomname) throws RemoteException {
......@@ -63,6 +63,14 @@ public class MessagesInChat extends JFrame {
}
}
});
viewUsersButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
System.out.println("FDDFs");
UsersInChat usersInChat = new UsersInChat(clientChatImp , roomname);
}
});
}
public void receiveMsg(String msg)
{
......
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="PersonalChats">
<grid id="27dc6" binding="Conversation" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3c46a" class="javax.swing.JButton" binding="MainMenu">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Return to main menu"/>
</properties>
</component>
<component id="e8b0a" class="javax.swing.JTextField" binding="Message">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="type a message"/>
</properties>
</component>
<component id="12a1d" class="javax.swing.JButton" binding="SendMessage">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Send"/>
</properties>
</component>
<component id="8dd05" class="javax.swing.JTextArea" binding="Texts">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
import javax.swing.*;
import javax.swing.plaf.ListUI;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.rmi.RemoteException;
import java.util.List;
public class PersonalChats extends JFrame {
private JButton MainMenu;
private JTextField Message;
private JButton SendMessage;
private JTextArea Texts;
private JPanel Conversation;
public PersonalChats(IClientChat senderClientChatImp , ClientChatImp me)
{
setContentPane(Conversation);
setVisible(true);
try {
setTitle("Chat with : " + senderClientChatImp.getUserName());
} catch (RemoteException e) {
throw new RuntimeException(e);
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(600 , 600);
Texts.setText("");
List<String> list = me.texts.get(senderClientChatImp);
if (list != null)
{
for (String str : list)
{
Texts.append(str);
}
}
else if (list ==null) Texts.setText("");
MainMenu.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
try {
goMain(me);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
Message.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Message.setText("");
}
});
SendMessage.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
if (!Message.getText().isEmpty())
{
String msg = Message.getText();
try {
msg = me.getUserName() + " : " + msg;
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
msg = msg + "\n" + "************************************************\n";
try {
Texts.append(msg);
senderClientChatImp.receiveMessage(msg , me);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
}
});
me.setPC(senderClientChatImp , this);
}
private void goMain(ClientChatImp clientChatImp) throws RemoteException {
MainPanel mainPanel= new MainPanel(clientChatImp);
this.dispose();
}
public void receiveMsg(String msg)
{
Texts.append(msg);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="UsersInChat">
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="f3f81">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="2cceb" class="javax.swing.JTextField" binding="Message">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="enter message"/>
</properties>
</component>
<component id="c22a1" class="javax.swing.JButton" binding="MultiCast">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="send to selected users"/>
</properties>
</component>
<component id="fa648" class="javax.swing.JButton" binding="GOBACK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Return to main menu"/>
</properties>
</component>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class UsersInChat extends JFrame{
private JButton GOBACK;
private JTextField Message;
private JButton MultiCast;
private JPanel buttonPanel;
private JScrollPane scrollPane;
List<IClientChat> selected = new ArrayList<>();
public UsersInChat(ClientChatImp me , String room)
{
System.out.println("CCCCCCCC");
try {
setTitle(me.getUserName());
} catch (RemoteException e) {
throw new RuntimeException(e);
}
/*setContentPane(MyChatsPanel);
setVisible(true);*/
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(600 , 600);
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(0, 1));
List<IClientChat> list = null;
try {
list = me.getAllUsersInRoom(room);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
for (IClientChat str : list) {
JButton button = null;
String nme = "";
try {
button = new JButton(str.getUserName());
nme = button.getText();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
String finalNme = nme;
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
int choice = JOptionPane.showConfirmDialog(null , "Select "+ finalNme + " as receiver ?");
if (choice == 0)
{
if (!selected.contains(str)) selected.add(str);
}
}
});
buttonPanel.add(button);
}
GOBACK.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
try {
goMain(me);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
buttonPanel.add(GOBACK);
Message.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Message.setText("");
}
});
buttonPanel.add(Message);
MultiCast.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
if (!Message.getText().isEmpty())
{
try {
me.multiCastMessage(Message.getText() , selected);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
}
});
buttonPanel.add(MultiCast);
scrollPane = new JScrollPane(buttonPanel);
// Add the scroll pane to the main frame
add(scrollPane, BorderLayout.CENTER);
pack();
setVisible(true);
}
private void goMain(ClientChatImp clientChatImp) throws RemoteException {
MainPanel mainPanel= new MainPanel(clientChatImp);
this.dispose();
}
}
......@@ -5,8 +5,22 @@
</component>
<component name="ChangeListManager">
<list default="true" id="23a09f69-45e8-4607-a94c-253a284a386d" name="Changes" comment="ChatServiceFirst5">
<change afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/AllChatRooms.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/AllChatRooms.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/PersonalChats.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/PersonalChats.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/UsersInChat.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/UsersInChat.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/Registeration.form" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/Registeration.form" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/ChatClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/ChatClient.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/ClientChatImp.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/ClientChatImp.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/IClientChat.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/IClientChat.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/IServerChat.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/IServerChat.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/JoiningChatRoom.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/JoiningChatRoom.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/MainPanel.form" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/MainPanel.form" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/MainPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/MainPanel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/MessagesInChat.form" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/MessagesInChat.form" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../ChatClient/src/main/java/MessagesInChat.java" beforeDir="false" afterPath="$PROJECT_DIR$/../ChatClient/src/main/java/MessagesInChat.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -35,15 +49,15 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/HIAST/FIY/FS/Distributed Systems/Lab/3/HW/ChatClient&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;project.propVCSSupport.DirectoryMappings&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"last_opened_file_path": "D:/HIAST/FIY/FS/Distributed Systems/Lab/3/HW/ChatServer",
"settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings"
}
}</component>
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\HIAST\FIY\FS\Distributed Systems\Lab\3\ChatServer" />
......
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;
public interface IClientChat extends Remote
{
public String receiveMessage (String Message , String roomName) throws RemoteException;
public String receiveMessage(String Message , IClientChat iClientChat) throws RemoteException;
/// public Boolean checkPassword (String password) throws RemoteException;
public String getUserName () throws RemoteException;
}
......@@ -23,5 +23,10 @@ public interface IServerChat extends Remote
public boolean LogOut(IClientChat iClientChat) throws RemoteException;
/// public boolean addListener (String roomName ) throws RemoteException;
public List<String> getAllChatRooms(IClientChat iClientChat) throws RemoteException;
public List<IClientChat> getAllUsersInRoom(IClientChat iClientChat , String roomName) throws RemoteException;
public void multiCastMessage (String message,IClientChat iClientChat, List<IClientChat> iClientChats) throws RemoteException;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment