Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
ChatService
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mohammad.salama
ChatService
Commits
a0b67fd8
Commit
a0b67fd8
authored
Nov 16, 2023
by
mohammad.salama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding GUI
parent
78a53180
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1274 additions
and
97 deletions
+1274
-97
uiDesigner.xml
ChatClient/.idea/uiDesigner.xml
+124
-0
workspace.xml
ChatClient/.idea/workspace.xml
+17
-4
ChatClient.java
ChatClient/src/main/java/ChatClient.java
+35
-26
ClientChatImp.java
ChatClient/src/main/java/ClientChatImp.java
+32
-17
CreatingChatRoom.form
ChatClient/src/main/java/CreatingChatRoom.form
+31
-0
CreatingChatRoom.java
ChatClient/src/main/java/CreatingChatRoom.java
+61
-0
DeletingChatRoom.form
ChatClient/src/main/java/DeletingChatRoom.form
+31
-0
DeletingChatRoom.java
ChatClient/src/main/java/DeletingChatRoom.java
+59
-0
IClientChat.java
ChatClient/src/main/java/IClientChat.java
+3
-1
IServerChat.java
ChatClient/src/main/java/IServerChat.java
+6
-6
JoiningChatRoom.form
ChatClient/src/main/java/JoiningChatRoom.form
+31
-0
JoiningChatRoom.java
ChatClient/src/main/java/JoiningChatRoom.java
+59
-0
LogIN.form
ChatClient/src/main/java/LogIN.form
+31
-0
LogIN.java
ChatClient/src/main/java/LogIN.java
+62
-0
LogOut.form
ChatClient/src/main/java/LogOut.form
+21
-0
LogOut.java
ChatClient/src/main/java/LogOut.java
+41
-0
MainPanel.form
ChatClient/src/main/java/MainPanel.form
+53
-0
MainPanel.java
ChatClient/src/main/java/MainPanel.java
+96
-0
MessagesInChat.form
ChatClient/src/main/java/MessagesInChat.form
+52
-0
MessagesInChat.java
ChatClient/src/main/java/MessagesInChat.java
+75
-0
MyChatRooms.form
ChatClient/src/main/java/MyChatRooms.form
+26
-0
MyChatRooms.java
ChatClient/src/main/java/MyChatRooms.java
+87
-0
Registeration.form
ChatClient/src/main/java/Registeration.form
+61
-0
Registeration.java
ChatClient/src/main/java/Registeration.java
+102
-0
workspace.xml
ChatServer/.idea/workspace.xml
+20
-11
IClientChat.java
ChatServer/src/main/java/IClientChat.java
+1
-1
IServerChat.java
ChatServer/src/main/java/IServerChat.java
+7
-7
ServerChatImp.java
ChatServer/src/main/java/ServerChatImp.java
+50
-24
No files found.
ChatClient/.idea/uiDesigner.xml
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"Palette2"
>
<group
name=
"Swing"
>
<item
class=
"com.intellij.uiDesigner.HSpacer"
tooltip-text=
"Horizontal Spacer"
icon=
"/com/intellij/uiDesigner/icons/hspacer.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"1"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"com.intellij.uiDesigner.VSpacer"
tooltip-text=
"Vertical Spacer"
icon=
"/com/intellij/uiDesigner/icons/vspacer.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"1"
anchor=
"0"
fill=
"2"
/>
</item>
<item
class=
"javax.swing.JPanel"
icon=
"/com/intellij/uiDesigner/icons/panel.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JScrollPane"
icon=
"/com/intellij/uiDesigner/icons/scrollPane.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"7"
hsize-policy=
"7"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JButton"
icon=
"/com/intellij/uiDesigner/icons/button.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"0"
fill=
"1"
/>
<initial-values>
<property
name=
"text"
value=
"Button"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JRadioButton"
icon=
"/com/intellij/uiDesigner/icons/radioButton.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"RadioButton"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JCheckBox"
icon=
"/com/intellij/uiDesigner/icons/checkBox.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"CheckBox"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JLabel"
icon=
"/com/intellij/uiDesigner/icons/label.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"0"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"Label"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JTextField"
icon=
"/com/intellij/uiDesigner/icons/textField.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JPasswordField"
icon=
"/com/intellij/uiDesigner/icons/passwordField.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JFormattedTextField"
icon=
"/com/intellij/uiDesigner/icons/formattedTextField.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTextArea"
icon=
"/com/intellij/uiDesigner/icons/textArea.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTextPane"
icon=
"/com/intellij/uiDesigner/icons/textPane.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JEditorPane"
icon=
"/com/intellij/uiDesigner/icons/editorPane.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JComboBox"
icon=
"/com/intellij/uiDesigner/icons/comboBox.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"2"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JTable"
icon=
"/com/intellij/uiDesigner/icons/table.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JList"
icon=
"/com/intellij/uiDesigner/icons/list.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"2"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTree"
icon=
"/com/intellij/uiDesigner/icons/tree.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTabbedPane"
icon=
"/com/intellij/uiDesigner/icons/tabbedPane.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"200"
height=
"200"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JSplitPane"
icon=
"/com/intellij/uiDesigner/icons/splitPane.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"200"
height=
"200"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JSpinner"
icon=
"/com/intellij/uiDesigner/icons/spinner.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JSlider"
icon=
"/com/intellij/uiDesigner/icons/slider.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JSeparator"
icon=
"/com/intellij/uiDesigner/icons/separator.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JProgressBar"
icon=
"/com/intellij/uiDesigner/icons/progressbar.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JToolBar"
icon=
"/com/intellij/uiDesigner/icons/toolbar.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
>
<preferred-size
width=
"-1"
height=
"20"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JToolBar$Separator"
icon=
"/com/intellij/uiDesigner/icons/toolbarSeparator.svg"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"0"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JScrollBar"
icon=
"/com/intellij/uiDesigner/icons/scrollbar.svg"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"0"
anchor=
"0"
fill=
"2"
/>
</item>
</group>
</component>
</project>
\ No newline at end of file
ChatClient/.idea/workspace.xml
View file @
a0b67fd8
...
...
@@ -5,9 +5,8 @@
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"71bec43c-ef6e-431f-a77c-2b7f124f5fea"
name=
"Changes"
comment=
"printing Done"
>
<change
afterPath=
"$PROJECT_DIR$/../ChatServer/src/main/java/IClientChat.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../ChatServer/.idea/vcs.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../ChatServer/.idea/vcs.xml"
afterDir=
"false"
/>
<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>
...
...
@@ -43,10 +42,11 @@
"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"
"UI_DESIGNER_EDITOR_MODE.PaletteManager.WIDTH": "132",
"last_opened_file_path": "D:/HIAST/FIY/FS/Distributed Systems/Lab/3/HW/ChatClient"
}
}]]>
</component>
<component
name=
"RunManager"
>
<component
name=
"RunManager"
selected=
"Application.Client1"
>
<configuration
name=
"Client1"
type=
"Application"
factoryName=
"Application"
>
<option
name=
"MAIN_CLASS_NAME"
value=
"ChatClient"
/>
<module
name=
"ChatClient"
/>
...
...
@@ -68,11 +68,24 @@
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<configuration
name=
"Registeration"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<option
name=
"MAIN_CLASS_NAME"
value=
"Registeration"
/>
<module
name=
"ChatClient"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<list>
<item
itemvalue=
"Application.Client1"
/>
<item
itemvalue=
"Application.Client2"
/>
<item
itemvalue=
"Application.Client3"
/>
<item
itemvalue=
"Application.Registeration"
/>
</list>
<recent_temporary>
<list>
<item
itemvalue=
"Application.Registeration"
/>
</list>
</recent_temporary>
</component>
<component
name=
"SpellCheckerSettings"
RuntimeDictionaries=
"0"
Folders=
"0"
CustomDictionaries=
"0"
DefaultDictionary=
"application-level"
UseSingleDictionary=
"true"
transferred=
"true"
/>
<component
name=
"TaskManager"
>
...
...
ChatClient/src/main/java/ChatClient.java
View file @
a0b67fd8
import
java.net.MalformedURLException
;
import
java.rmi.Naming
;
import
java.rmi.NotBoundException
;
import
java.rmi.RemoteException
;
import
java.util.Scanner
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
ChatClient
{
public
static
void
main
(
String
[]
args
)
throws
MalformedURLException
,
NotBoundException
,
RemoteException
{
public
static
List
<
ClientChatImp
>
prevTest
()
throws
MalformedURLException
,
NotBoundException
,
RemoteException
{
String
loc
=
"localhost"
;
String
fname
=
"Client"
;
String
lname
=
""
;
...
...
@@ -17,8 +19,8 @@ public class ChatClient
ClientChatImp
clientChatImp
=
new
ClientChatImp
(
fname
,
lname
+
"1"
,
userName
+
"1"
,
password
,
loc
);
ClientChatImp
clientChatImp2
=
new
ClientChatImp
(
fname
,
lname
+
"2"
,
userName
+
"2"
,
password
,
loc
);
clientChatImp
.
Register
(
fname
,
lname
+
"1"
,
userName
+
"1"
,
password
);
clientChatImp2
.
Register
(
fname
,
lname
+
"2"
,
userName
+
"2"
,
password
);
clientChatImp
.
Register
();
clientChatImp2
.
Register
();
clientChatImp
.
createChatRoom
(
"room1"
);
...
...
@@ -29,34 +31,41 @@ public class ChatClient
clientChatImp
.
joinChatRoom
(
"room2"
);
clientChatImp2
.
joinChatRoom
(
"room1"
);
System
.
out
.
println
(
"Hello World"
);
/*
clientChatImp.sendMessage("room1" , "Hello");
clientChatImp2.sendMessage("room2" , "Hello");
clientChatImp2.sendMessage("room1" , "Hello Agan");
/*ClientChatImp[] clientChatImps = new ClientChatImp[3];
for (Integer i=1 ; i<=3 ; i++)
{
clientChatImps[i-1] = new ClientChatImp
(fname , lname+i.toString() , userName+i.toString() , password , loc);
}
Scanner scanner = new Scanner(System.in);
Integer choice = scanner.nextInt();
choice -=1;
clientChatImps[choice].createChatRoom("room"+choice.toString());
Integer x = choice;
while (choice > 0)
MainPanel mainPanel1 = new MainPanel(clientChatImp);
MainPanel mainPanel2 = new MainPanel(clientChatImp2);
System.out.println("+++++++++++++++++++++++++++++++++++++++++");
for (String str : clientChatImp2.getConversation("room1"))
{
clientChatImps[choice].joinChatRoom("room"+x.toString());
x--;
System.out.println(str);
}
int g = scanner.nextInt();
clientChatImps[choice].sendMessage("room"+choice.toString() , "Hello from"+choice.toString());
for (String str : clientChatImps[choice].getChatRooms())
System.out.println("+++++++++++++++++++++++++++++++++++++++++");
System.out.println("/////////////////////////////////////////////////////////////");
for (String str : clientChatImp2.getChatRooms())
{
System.out.println(str);
}*/
}
System.out.println("/////////////////////////////////////////////////////////////");*/
List
<
ClientChatImp
>
clientChatImps
=
new
ArrayList
<>();
clientChatImps
.
add
(
clientChatImp
);
clientChatImps
.
add
(
clientChatImp2
);
return
clientChatImps
;
}
System
.
out
.
println
(
"DONE"
);
public
static
void
main
(
String
[]
args
)
throws
MalformedURLException
,
NotBoundException
,
RemoteException
{
String
loc
=
"localhost"
;
Registeration
registeration
=
new
Registeration
(
loc
);
/* List<ClientChatImp> clientChatImps = prevTest();
ClientChatImp clientChatImp1 = clientChatImps.get(0);
ClientChatImp clientChatImp2 = clientChatImps.get(1);
MainPanel myChatsAndRooms1 = new MainPanel(clientChatImp1);
MainPanel myChatsAndRoom2 = new MainPanel(clientChatImp2);*/
}
}
ChatClient/src/main/java/ClientChatImp.java
View file @
a0b67fd8
...
...
@@ -3,25 +3,38 @@ import java.rmi.Naming;
import
java.rmi.NotBoundException
;
import
java.rmi.RemoteException
;
import
java.rmi.server.UnicastRemoteObject
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ClientChatImp
extends
UnicastRemoteObject
implements
IClientChat
{
private
String
firstName
,
lastName
,
userName
,
password
;
IServerChat
iServerChat
;
public
ClientChatImp
(
String
firstName
,
String
lastName
,
String
userName
,
String
password
,
String
server
)
throws
RemoteException
,
MalformedURLException
,
NotBoundException
{
Map
<
String
,
MessagesInChat
>
messagesInChat
=
new
HashMap
<>();
public
ClientChatImp
(
String
firstName
,
String
lastName
,
String
userName
,
String
password
,
String
server
)
throws
RemoteException
,
MalformedURLException
,
NotBoundException
{
this
.
lastName
=
lastName
;
this
.
userName
=
userName
;
this
.
firstName
=
firstName
;
this
.
password
=
password
;
this
.
iServerChat
=
(
IServerChat
)
Naming
.
lookup
(
"rmi://"
+
server
+
":1099/chat"
);
}
public
void
setMIC
(
MessagesInChat
messagesInChat
,
String
roomName
)
{
this
.
messagesInChat
.
put
(
roomName
,
messagesInChat
);
}
@Override
public
String
receiveMessage
(
String
Message
)
throws
RemoteException
public
String
receiveMessage
(
String
Message
,
String
roomName
)
throws
RemoteException
{
System
.
out
.
println
(
Message
);
//System.out.println(Message);
// this.myChatsAndRooms.receiveMsg(Message , roomName , this);
System
.
out
.
println
(
"RECEIVING"
);
this
.
messagesInChat
.
get
(
roomName
).
receiveMsg
(
Message
);
///System.out.println(Message + " in Room : " + roomName);
return
Message
;
}
...
...
@@ -31,34 +44,35 @@ public class ClientChatImp extends UnicastRemoteObject implements IClientChat
//return this.userName + " ( " + this.firstName+" " + this.lastName+" )";
return
this
.
userName
;
}
public
void
createChatRoom
(
String
roomName
)
throws
RemoteException
public
boolean
createChatRoom
(
String
roomName
)
throws
RemoteException
{
iServerChat
.
createChatRoom
(
roomName
,
this
);
return
iServerChat
.
createChatRoom
(
roomName
,
this
);
}
public
void
joinChatRoom
(
String
roomName
)
throws
RemoteException
public
boolean
joinChatRoom
(
String
roomName
)
throws
RemoteException
{
iServerChat
.
joinChatRoom
(
roomName
,
this
);
return
iServerChat
.
joinChatRoom
(
roomName
,
this
);
}
public
void
deleteChatRoom
(
String
roomName
)
throws
RemoteException
public
boolean
deleteChatRoom
(
String
roomName
)
throws
RemoteException
{
iServerChat
.
deleteChatRoom
(
roomName
,
this
);
return
iServerChat
.
deleteChatRoom
(
roomName
,
this
);
}
public
void
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
)
throws
RemoteException
public
boolean
Register
(
)
throws
RemoteException
{
iServerChat
.
Register
(
fname
,
lname
,
username
,
password
,
this
);
System
.
out
.
println
(
"Registering"
);
return
iServerChat
.
Register
(
firstName
,
lastName
,
userName
,
password
,
this
);
}
public
void
LogIn
(
String
password
)
throws
RemoteException
public
boolean
LogIn
(
String
password
)
throws
RemoteException
{
iServerChat
.
LogIn
(
password
,
this
);
return
iServerChat
.
LogIn
(
password
,
this
);
}
public
void
LogOut
()
throws
RemoteException
public
boolean
LogOut
()
throws
RemoteException
{
iServerChat
.
LogOut
(
this
);
return
iServerChat
.
LogOut
(
this
);
}
public
List
<
String
>
getChatRooms
()
throws
RemoteException
{
...
...
@@ -72,6 +86,7 @@ public class ClientChatImp extends UnicastRemoteObject implements IClientChat
public
void
sendMessage
(
String
roomName
,
String
message
)
throws
RemoteException
{
iServerChat
.
sendMessage
(
roomName
,
message
,
this
);
System
.
out
.
println
(
"Sending MSG"
);
iServerChat
.
sendMessage
(
roomName
,
message
,
this
);
}
}
ChatClient/src/main/java/CreatingChatRoom.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"CreatingChatRoom"
>
<grid
id=
"27dc6"
binding=
"CreateChatRoom"
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=
"96c6f"
class=
"javax.swing.JTextField"
binding=
"ChatRoomName"
>
<constraints>
<grid
row=
"0"
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 chat room name"
/>
</properties>
</component>
<component
id=
"4757a"
class=
"javax.swing.JButton"
binding=
"submit"
>
<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=
"Create"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/CreatingChatRoom.java
0 → 100644
View file @
a0b67fd8
import
org.example.Main
;
import
javax.swing.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.rmi.MarshalledObject
;
import
java.rmi.RemoteException
;
public
class
CreatingChatRoom
extends
JFrame
{
private
JPanel
CreateChatRoom
;
private
JTextField
ChatRoomName
;
private
JButton
submit
;
public
CreatingChatRoom
(
ClientChatImp
clientChatImp
)
{
setSize
(
600
,
600
);
setVisible
(
true
);
try
{
setTitle
(
"Creating Chat Room( "
+
clientChatImp
.
getUserName
()+
" )"
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
setContentPane
(
CreateChatRoom
);
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
ChatRoomName
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
ChatRoomName
.
setText
(
""
);
}
});
submit
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
if
(
ChatRoomName
.
getText
().
isEmpty
())
{
ChatRoomName
.
setText
(
"Can not be empty"
);
}
else
{
try
{
if
(!
clientChatImp
.
createChatRoom
(
ChatRoomName
.
getText
()))
{
ChatRoomName
.
setText
(
"Room already exists"
);
}
else
{
doit
(
clientChatImp
);
}
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
});
}
public
void
doit
(
ClientChatImp
clientChatImp
)
throws
RemoteException
{
MainPanel
myChatRooms
=
new
MainPanel
(
clientChatImp
);
this
.
dispose
();
}
}
ChatClient/src/main/java/DeletingChatRoom.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"DeletingChatRoom"
>
<grid
id=
"27dc6"
binding=
"DeletingChatRoom"
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=
"e68fe"
class=
"javax.swing.JTextField"
binding=
"ChatRoomName"
>
<constraints>
<grid
row=
"0"
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 room name"
/>
</properties>
</component>
<component
id=
"276d5"
class=
"javax.swing.JButton"
binding=
"Delete"
>
<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=
"Delete Room"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/DeletingChatRoom.java
0 → 100644
View file @
a0b67fd8
import
javax.swing.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.rmi.RemoteException
;
public
class
DeletingChatRoom
extends
JFrame
{
private
JTextField
ChatRoomName
;
private
JPanel
DeletingChatRoom
;
private
JButton
Delete
;
public
DeletingChatRoom
(
ClientChatImp
clientChatImp
)
{
setVisible
(
true
);
try
{
setTitle
(
"Deleting Chat Room( "
+
clientChatImp
.
getUserName
()+
" )"
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
setContentPane
(
DeletingChatRoom
);
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
setSize
(
600
,
600
);
ChatRoomName
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
ChatRoomName
.
setText
(
""
);
}
});
Delete
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
if
(
ChatRoomName
.
getText
().
isEmpty
())
{
ChatRoomName
.
setText
(
"Can not be Empty"
);
}
else
{
try
{
if
(!
clientChatImp
.
deleteChatRoom
(
ChatRoomName
.
getText
()))
{
ChatRoomName
.
setText
(
"Error : Either you do not own group or it does not exist"
);
}
else
{
doit
(
clientChatImp
);
}
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
});
}
public
void
doit
(
ClientChatImp
clientChatImp
)
throws
RemoteException
{
MainPanel
mainPanel
=
new
MainPanel
(
clientChatImp
);
this
.
dispose
();
}
}
ChatClient/src/main/java/IClientChat.java
View file @
a0b67fd8
...
...
@@ -3,7 +3,9 @@ import java.rmi.RemoteException;
public
interface
IClientChat
extends
Remote
{
public
String
receiveMessage
(
String
Message
)
throws
RemoteException
;
public
String
receiveMessage
(
String
Message
,
String
roomName
)
throws
RemoteException
;
/// public Boolean checkPassword (String password) throws RemoteException;
public
String
getUserName
()
throws
RemoteException
;
}
ChatClient/src/main/java/IServerChat.java
View file @
a0b67fd8
...
...
@@ -5,15 +5,15 @@ import java.util.List;
public
interface
IServerChat
extends
Remote
{
public
void
createChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
createChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
joinChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
joinChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
deleteChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
deleteChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
LogIn
(
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
LogIn
(
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
List
<
String
>
getChatRooms
(
IClientChat
iClientChat
)
throws
RemoteException
;
...
...
@@ -21,6 +21,6 @@ public interface IServerChat extends Remote
public
void
sendMessage
(
String
roomName
,
String
message
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
LogOut
(
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
LogOut
(
IClientChat
iClientChat
)
throws
RemoteException
;
}
ChatClient/src/main/java/JoiningChatRoom.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"JoiningChatRoom"
>
<grid
id=
"27dc6"
binding=
"JoiningChatRoom"
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=
"5b5c7"
class=
"javax.swing.JTextField"
binding=
"ChatRoomName"
>
<constraints>
<grid
row=
"0"
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 room name"
/>
</properties>
</component>
<component
id=
"c486"
class=
"javax.swing.JButton"
binding=
"Join"
>
<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=
"Join Room"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/JoiningChatRoom.java
0 → 100644
View file @
a0b67fd8
import
javax.swing.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.rmi.RemoteException
;
public
class
JoiningChatRoom
extends
JFrame
{
private
JPanel
JoiningChatRoom
;
private
JTextField
ChatRoomName
;
private
JButton
Join
;
public
JoiningChatRoom
(
ClientChatImp
clientChatImp
)
{
setVisible
(
true
);
try
{
setTitle
(
"Join Chat Room( "
+
clientChatImp
.
getUserName
()+
" )"
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
setContentPane
(
JoiningChatRoom
);
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
setSize
(
600
,
600
);
ChatRoomName
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
ChatRoomName
.
setText
(
""
);
}
});
Join
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
if
(
ChatRoomName
.
getText
().
isEmpty
())
{
ChatRoomName
.
setText
(
"Cannot be Empty"
);
}
else
{
try
{
if
(!
clientChatImp
.
joinChatRoom
(
ChatRoomName
.
getText
()))
{
ChatRoomName
.
setText
(
"No Such Room"
);
}
else
{
goBack
(
clientChatImp
);
}
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
});
}
public
void
goBack
(
ClientChatImp
clientChatImp
)
throws
RemoteException
{
MainPanel
mainPanel
=
new
MainPanel
(
clientChatImp
);
this
.
dispose
();
}
}
ChatClient/src/main/java/LogIN.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"LogIN"
>
<grid
id=
"27dc6"
binding=
"LoggingIN"
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=
"1135b"
class=
"javax.swing.JTextField"
binding=
"Password"
>
<constraints>
<grid
row=
"0"
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 password"
/>
</properties>
</component>
<component
id=
"f1fd2"
class=
"javax.swing.JButton"
binding=
"LogIn"
>
<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=
"Log In"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/LogIN.java
0 → 100644
View file @
a0b67fd8
import
javax.swing.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.rmi.RemoteException
;
public
class
LogIN
extends
JFrame
{
private
JPanel
LoggingIN
;
private
JTextField
Password
;
private
JButton
LogIn
;
public
LogIN
(
ClientChatImp
clientChatImp
)
{
setVisible
(
true
);
try
{
setTitle
(
"Log In( "
+
clientChatImp
.
getUserName
()+
" )"
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
setContentPane
(
LoggingIN
);
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
setSize
(
600
,
600
);
Password
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
Password
.
setText
(
""
);
}
});
LogIn
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
boolean
can
=
(
Password
.
getText
().
isEmpty
());
if
(!
can
)
{
//UserName.setText("Cannot Be Empty");
Password
.
setText
(
"Cannot Be Empty"
);
}
else
{
try
{
if
(
clientChatImp
.
LogIn
(
Password
.
getText
()))
{
doit
(
clientChatImp
);
}
else
{
Password
.
setText
(
"Wrong Password"
);
}
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
});
}
private
void
doit
(
ClientChatImp
clientChatImp
)
throws
RemoteException
{
MainPanel
mainPanel
=
new
MainPanel
(
clientChatImp
);
this
.
dispose
();
}
}
ChatClient/src/main/java/LogOut.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"LogOut"
>
<grid
id=
"27dc6"
binding=
"LoggingOut"
layout-manager=
"GridLayoutManager"
row-count=
"1"
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=
"1528b"
class=
"javax.swing.JButton"
binding=
"LogOut"
>
<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=
"Log Out"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/LogOut.java
0 → 100644
View file @
a0b67fd8
import
javax.swing.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.rmi.RemoteException
;
public
class
LogOut
extends
JFrame
{
private
JPanel
LoggingOut
;
private
JButton
LogOut
;
public
LogOut
(
ClientChatImp
clientChatImp
)
{
setVisible
(
true
);
try
{
setTitle
(
"Log Out( "
+
clientChatImp
.
getUserName
()+
" )"
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
setContentPane
(
LoggingOut
);
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
setSize
(
600
,
600
);
LogOut
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
try
{
if
(
clientChatImp
.
LogOut
())
{
doit
(
clientChatImp
);
}
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
});
}
private
void
doit
(
ClientChatImp
clientChatImp
)
{
LogIN
logIN
=
new
LogIN
(
clientChatImp
);
this
.
dispose
();
}
}
ChatClient/src/main/java/MainPanel.form
0 → 100644
View file @
a0b67fd8
<?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"
>
<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=
"c75d4"
class=
"javax.swing.JButton"
binding=
"CreateRoom"
>
<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=
"+ New Room"
/>
</properties>
</component>
<component
id=
"7bad6"
class=
"javax.swing.JButton"
binding=
"JoinRoom"
>
<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=
"Join Room"
/>
</properties>
</component>
<component
id=
"396f0"
class=
"javax.swing.JButton"
binding=
"DeleteRoom"
>
<constraints>
<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=
"Delete Room"
/>
</properties>
</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"
/>
</constraints>
<properties>
<text
value=
"Log Out"
/>
</properties>
</component>
<component
id=
"398ee"
class=
"javax.swing.JButton"
binding=
"ViewChats"
>
<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=
"View My Chats"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/MainPanel.java
0 → 100644
View file @
a0b67fd8
import
javax.swing.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.rmi.RemoteException
;
public
class
MainPanel
extends
JFrame
{
private
JPanel
MyChats
;
private
JButton
CreateRoom
;
private
JButton
JoinRoom
;
private
JButton
DeleteRoom
;
private
JButton
LogOut
;
private
JButton
ViewChats
;
public
MainPanel
(
ClientChatImp
clientChatImp
)
throws
RemoteException
{
setContentPane
(
MyChats
);
setTitle
(
"My Chats ( "
+
clientChatImp
.
getUserName
()+
" )"
);
setVisible
(
true
);
setDefaultCloseOperation
(
JFrame
.
HIDE_ON_CLOSE
);
setSize
(
600
,
600
);
CreateRoom
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
createChatRoom
(
clientChatImp
);
}
});
JoinRoom
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
joinChatRoom
(
clientChatImp
);
}
});
DeleteRoom
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
deleteChatRoom
(
clientChatImp
);
}
});
LogOut
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
logout
(
clientChatImp
);
}
});
ViewChats
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
viewChatRoom
(
clientChatImp
);
}
});
}
public
void
viewChatRoom
(
ClientChatImp
clientChatImp
)
{
MyChatRooms
myChatRooms
=
new
MyChatRooms
(
clientChatImp
);
this
.
dispose
();
}
public
void
createChatRoom
(
ClientChatImp
clientChatImp
)
{
CreatingChatRoom
creatingChatRoom
=
new
CreatingChatRoom
(
clientChatImp
);
this
.
dispose
();
}
public
void
joinChatRoom
(
ClientChatImp
clientChatImp
)
{
JoiningChatRoom
joiningChatRoom
=
new
JoiningChatRoom
(
clientChatImp
);
this
.
dispose
();
}
public
void
deleteChatRoom
(
ClientChatImp
clientChatImp
)
{
DeletingChatRoom
deletingChatRoom
=
new
DeletingChatRoom
(
clientChatImp
);
this
.
dispose
();
}
public
void
logout
(
ClientChatImp
clientChatImp
)
{
LogOut
logOut
=
new
LogOut
(
clientChatImp
);
this
.
dispose
();
}
public
void
receiveMsg
(
String
Msg
,
String
roomName
,
ClientChatImp
clientChatImp
)
{
try
{
MessagesInChat
messagesInChat
=
new
MessagesInChat
(
clientChatImp
,
roomName
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
ChatClient/src/main/java/MessagesInChat.form
0 → 100644
View file @
a0b67fd8
<?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"
>
<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=
"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"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</grid>
</constraints>
<properties>
<text
value=
"type a message"
/>
</properties>
</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"
/>
</constraints>
<properties>
<text
value=
"Send"
/>
</properties>
</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"
/>
</constraints>
<properties/>
<border
type=
"none"
/>
<children>
<component
id=
"70b9f"
class=
"javax.swing.JTextArea"
binding=
"Texts"
>
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<component
id=
"5afad"
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>
</children>
</grid>
</form>
ChatClient/src/main/java/MessagesInChat.java
0 → 100644
View file @
a0b67fd8
import
javax.swing.*
;
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
;
private
JButton
SendMessage
;
private
JTextArea
Texts
;
private
JPanel
Conversation
;
private
JButton
MainMenu
;
private
String
roomName
=
""
;
public
MessagesInChat
(
ClientChatImp
clientChatImp
,
String
roomname
)
throws
RemoteException
{
setContentPane
(
Conversation
);
setVisible
(
true
);
roomName
=
roomname
;
setTitle
(
"Room : "
+
roomname
+
" ( "
+
clientChatImp
.
getUserName
()+
" )"
);
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
setSize
(
600
,
600
);
List
<
String
>
list
=
clientChatImp
.
getConversation
(
roomName
);
Texts
.
setText
(
""
);
for
(
String
str
:
list
)
{
Texts
.
append
(
str
);
}
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
{
clientChatImp
.
sendMessage
(
roomName
,
msg
);
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
});
clientChatImp
.
setMIC
(
this
,
roomname
);
MainMenu
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
try
{
goMain
(
clientChatImp
);
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
});
}
public
void
receiveMsg
(
String
msg
)
{
Texts
.
append
(
msg
);
}
private
void
goMain
(
ClientChatImp
clientChatImp
)
throws
RemoteException
{
MainPanel
mainPanel
=
new
MainPanel
(
clientChatImp
);
this
.
dispose
();
}
}
ChatClient/src/main/java/MyChatRooms.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"MyChatRooms"
>
<grid
id=
"27dc6"
binding=
"MyChatsPanel"
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=
"b83c"
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=
"2b1ff"
>
<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>
ChatClient/src/main/java/MyChatRooms.java
0 → 100644
View file @
a0b67fd8
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
;
import
java.util.Map
;
public
class
MyChatRooms
extends
JFrame
{
private
JPanel
buttonPanel
;
private
JScrollPane
scrollPane
;
private
JPanel
MyChatsPanel
;
private
JButton
GOBack
;
public
MyChatRooms
(
ClientChatImp
clientChatImp
)
{
try
{
setTitle
(
"My Rooms ( "
+
clientChatImp
.
getUserName
()+
" )"
);
}
catch
(
RemoteException
e
)
{
throw
new
RuntimeException
(
e
);
}
/*setContentPane(MyChatsPanel);
setVisible(true);*/
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
setSize
(
600
,
600
);
// Create a list of strings
List
<
String
>
stringList
=
null
;
try
{
stringList
=
clientChatImp
.
getChatRooms
();
}
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
{
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
();
}
}
ChatClient/src/main/java/Registeration.form
0 → 100644
View file @
a0b67fd8
<?xml version="1.0" encoding="UTF-8"?>
<form
xmlns=
"http://www.intellij.com/uidesigner/form/"
version=
"1"
bind-to-class=
"Registeration"
>
<grid
id=
"27dc6"
binding=
"panelChat"
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"
/>
</constraints>
<properties/>
<border
type=
"none"
/>
<children>
<component
id=
"e9719"
class=
"javax.swing.JTextField"
binding=
"FirstName"
>
<constraints>
<grid
row=
"0"
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 first name"
/>
</properties>
</component>
<component
id=
"ec9c5"
class=
"javax.swing.JTextField"
binding=
"LastName"
>
<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=
"senter last name"
/>
</properties>
</component>
<component
id=
"ad042"
class=
"javax.swing.JTextField"
binding=
"UserName"
>
<constraints>
<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>
<properties>
<text
value=
"enter user name"
/>
</properties>
</component>
<component
id=
"c0d84"
class=
"javax.swing.JTextField"
binding=
"Password"
>
<constraints>
<grid
row=
"3"
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 password"
/>
</properties>
</component>
<component
id=
"d2fb5"
class=
"javax.swing.JButton"
binding=
"register"
>
<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=
"Confirm"
/>
</properties>
</component>
</children>
</grid>
</form>
ChatClient/src/main/java/Registeration.java
0 → 100644
View file @
a0b67fd8
import
sun.java2d.Disposer
;
import
javax.swing.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.net.MalformedURLException
;
import
java.rmi.NotBoundException
;
import
java.rmi.RemoteException
;
public
class
Registeration
extends
JFrame
{
private
ClientChatImp
clientChatImp
;
private
JTextField
FirstName
;
private
JTextField
LastName
;
private
JTextField
UserName
;
private
JTextField
Password
;
private
JButton
register
;
private
JPanel
panelChat
;
private
String
server
=
""
;
public
Registeration
(
String
server
)
{
this
.
server
=
server
;
setContentPane
(
panelChat
);
setVisible
(
true
);
setDefaultCloseOperation
(
JFrame
.
HIDE_ON_CLOSE
);
setSize
(
600
,
600
);
setTitle
(
"Mohammed Salameh Telegram"
);
FirstName
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
FirstName
.
setText
(
""
);
}
});
LastName
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
LastName
.
setText
(
""
);
}
});
UserName
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
UserName
.
setText
(
""
);
}
});
Password
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
super
.
mouseClicked
(
e
);
Password
.
setText
(
""
);
}
});
register
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
boolean
cont
=
checkInputs
();
if
(!
cont
)
{
FirstName
.
setText
(
"Should not be Empty"
);
LastName
.
setText
(
"Should not be Empty"
);
UserName
.
setText
(
"Should not be Empty"
);
Password
.
setText
(
"Should not be Empty"
);
}
else
{
try
{
startAll
();
}
catch
(
RemoteException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
catch
(
MalformedURLException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
catch
(
NotBoundException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
});
}
private
boolean
checkInputs
()
{
if
(
UserName
.
getText
().
isEmpty
()
||
LastName
.
getText
().
isEmpty
()
||
Password
.
getText
().
isEmpty
()
||
FirstName
.
getText
().
isEmpty
())
{
return
false
;
}
return
true
;
}
public
void
startAll
()
throws
RemoteException
,
MalformedURLException
,
NotBoundException
{
this
.
clientChatImp
=
new
ClientChatImp
(
FirstName
.
getText
()
,
LastName
.
getText
()
,
UserName
.
getText
()
,
Password
.
getText
()
,
server
);
this
.
clientChatImp
.
Register
();
MainPanel
mainPanel
=
new
MainPanel
(
this
.
clientChatImp
);
this
.
dispose
();
}
}
ChatServer/.idea/workspace.xml
View file @
a0b67fd8
...
...
@@ -5,11 +5,20 @@
</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/ClientChatImp.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/IClientChat.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../ChatClient/.idea/vcs.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../ChatClient/.idea/vcs.xml"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/LogIN.form"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/LogIN.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/LogOut.form"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/LogOut.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/MainPanel.form"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/MainPanel.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/MessagesInChat.form"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/MessagesInChat.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/MyChatRooms.form"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/../ChatClient/src/main/java/MyChatRooms.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/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"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
...
@@ -39,15 +48,15 @@
<option
name=
"hideEmptyMiddlePackages"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
<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
name=
"PropertiesComponent"
>
{
"
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/ChatClient
"
,
"
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"
/>
...
...
ChatServer/src/main/java/IClientChat.java
View file @
a0b67fd8
...
...
@@ -3,7 +3,7 @@ import java.rmi.RemoteException;
public
interface
IClientChat
extends
Remote
{
public
String
receiveMessage
(
String
Message
)
throws
RemoteException
;
public
String
receiveMessage
(
String
Message
,
String
roomName
)
throws
RemoteException
;
/// public Boolean checkPassword (String password) throws RemoteException;
public
String
getUserName
()
throws
RemoteException
;
}
ChatServer/src/main/java/IServerChat.java
View file @
a0b67fd8
...
...
@@ -5,15 +5,15 @@ import java.util.List;
public
interface
IServerChat
extends
Remote
{
public
void
createChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
createChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
joinChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
joinChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
deleteChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
deleteChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
LogIn
(
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
LogIn
(
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
List
<
String
>
getChatRooms
(
IClientChat
iClientChat
)
throws
RemoteException
;
...
...
@@ -21,7 +21,7 @@ public interface IServerChat extends Remote
public
void
sendMessage
(
String
roomName
,
String
message
,
IClientChat
iClientChat
)
throws
RemoteException
;
public
void
LogOut
(
IClientChat
iClientChat
)
throws
RemoteException
;
public
boolean
LogOut
(
IClientChat
iClientChat
)
throws
RemoteException
;
/// public
void
addListener (String roomName ) throws RemoteException;
/// public
boolean
addListener (String roomName ) throws RemoteException;
}
ChatServer/src/main/java/ServerChatImp.java
View file @
a0b67fd8
...
...
@@ -13,72 +13,89 @@ public class ServerChatImp extends UnicastRemoteObject implements IServerChat
Map
<
String
,
List
<
IClientChat
>>
ChatRoomMembers
=
new
HashMap
<>();
Map
<
String
,
IClientChat
>
ChatRoomsOwners
=
new
HashMap
<>();
protected
ServerChatImp
()
throws
RemoteException
{
}
@Override
public
void
createChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
public
boolean
createChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
{
String
userName
=
iClientChat
.
getUserName
();
if
(!
users
.
containsKey
(
userName
))
return
;
if
(!
users
.
containsKey
(
userName
))
return
false
;
if
(
ChatRoomsOfUser
.
get
(
iClientChat
).
contains
(
roomName
))
return
false
;
if
(
ChatRoomsOwners
.
containsKey
(
roomName
))
return
false
;
ChatRoomsOfUser
.
get
(
iClientChat
).
add
(
roomName
);
ChatRoomsOwners
.
put
(
roomName
,
iClientChat
);
ChatRoomMembers
.
put
(
roomName
,
new
ArrayList
<>());
ChatRoomMembers
.
get
(
roomName
).
add
(
iClientChat
);
ChatRoomMessages
.
put
(
roomName
,
new
ArrayList
<>());
System
.
out
.
println
(
"Created"
);
return
true
;
}
@Override
public
void
joinChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
public
boolean
joinChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
{
if
(!
ChatRoomMembers
.
containsKey
(
roomName
))
return
;
if
(!
ChatRoomMembers
.
containsKey
(
roomName
))
return
false
;
ChatRoomMembers
.
get
(
roomName
).
add
(
iClientChat
);
// System.out.println("Added to " + roomName + " pppp : " + iClientChat.getUserName());
ChatRoomsOfUser
.
get
(
iClientChat
).
add
(
roomName
);
System
.
out
.
println
(
"joined"
);
return
true
;
}
@Override
public
void
deleteChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
public
boolean
deleteChatRoom
(
String
roomName
,
IClientChat
iClientChat
)
throws
RemoteException
{
String
userName
=
iClientChat
.
getUserName
();
if
(!
users
.
containsKey
(
userName
))
{
// System.out.println("No Such User");
return
;
return
false
;
}
if
(
ChatRoomsOfUser
.
get
(
iClientChat
).
contains
(
roomName
))
if
(
ChatRoomsOwners
.
containsKey
(
roomName
)
&&
ChatRoomsOwners
.
get
(
roomName
).
equals
(
iClientChat
))
{
ChatRoomsOfUser
.
get
(
iClientChat
).
remove
(
roomName
);
ChatRoomMembers
.
remove
(
roomName
);
ChatRoomMessages
.
remove
(
roomName
);
System
.
out
.
println
(
"Deleted"
);
return
true
;
}
else
System
.
out
.
println
(
"No Such Room for "
+
userName
);
//else System.out.println("No Such Room for " + userName);
return
false
;
}
@Override
public
void
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
public
boolean
Register
(
String
fname
,
String
lname
,
String
username
,
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
{
if
(
users
.
containsKey
(
username
))
{
return
false
;
}
users
.
put
(
username
,
iClientChat
);
ChatRoomsOfUser
.
put
(
iClientChat
,
new
ArrayList
<>());
UsersPasswords
.
put
(
iClientChat
,
password
);
ActiveUsers
.
put
(
iClientChat
,
true
);
/// System.out.println("User " + iClientChat.getUserName() + "Logged in");
return
true
;
//System.out.println("RRRRRR");
}
@Override
public
void
LogIn
(
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
public
boolean
LogIn
(
String
password
,
IClientChat
iClientChat
)
throws
RemoteException
{
String
username
=
iClientChat
.
getUserName
();
if
(!
users
.
containsKey
(
username
))
{
iClientChat
.
receiveMessage
(
"You do not have an account"
);
return
;
//
iClientChat.receiveMessage("You do not have an account");
return
false
;
}
/*
validation and authentication for later
* */
if
(
UsersPasswords
.
get
(
iClientChat
).
equals
(
password
))
ActiveUsers
.
put
(
iClientChat
,
true
);
else
iClientChat
.
receiveMessage
(
"Wrong pass
"
);
//else iClientChat.receiveMessage("Wrong password
");
return
true
;
}
@Override
...
...
@@ -86,9 +103,14 @@ public class ServerChatImp extends UnicastRemoteObject implements IServerChat
{
if
(
ChatRoomsOfUser
.
get
(
iClientChat
).
size
()
==
0
)
{
//System.out.println("Here");
return
new
ArrayList
<>();
}
else
return
ChatRoomsOfUser
.
get
(
iClientChat
);
else
{
/// System.out.println("ChatRoomsLoist");
return
ChatRoomsOfUser
.
get
(
iClientChat
);
}
}
@Override
...
...
@@ -99,6 +121,7 @@ public class ServerChatImp extends UnicastRemoteObject implements IServerChat
return
new
ArrayList
<>();
}
System
.
out
.
println
(
"Convs"
);
return
ChatRoomMessages
.
get
(
roomName
);
}
...
...
@@ -110,6 +133,7 @@ public class ServerChatImp extends UnicastRemoteObject implements IServerChat
Message
=
iClientChat
.
getUserName
()
+
" : "
+
Message
;
Message
=
Message
+
"\n"
+
"************************************************\n"
;
String
finalMessage
=
Message
;
ChatRoomMessages
.
get
(
roomName
).
add
(
Message
);
ChatRoomMembers
.
get
(
roomName
).
stream
().
forEach
(
client
->
...
...
@@ -118,7 +142,7 @@ public class ServerChatImp extends UnicastRemoteObject implements IServerChat
try
{
System
.
out
.
println
(
"Can send to "
+
client
.
getUserName
());
client
.
receiveMessage
(
finalMessage
);
client
.
receiveMessage
(
finalMessage
,
roomName
);
}
catch
(
RemoteException
e
)
{
...
...
@@ -127,13 +151,15 @@ public class ServerChatImp extends UnicastRemoteObject implements IServerChat
}
);
}
///else System.out.println("NO USERS !!");
}
@Override
public
void
LogOut
(
IClientChat
iClientChat
)
throws
RemoteException
public
boolean
LogOut
(
IClientChat
iClientChat
)
throws
RemoteException
{
String
username
=
iClientChat
.
getUserName
();
if
(!
users
.
containsKey
(
username
))
return
;
if
(!
users
.
containsKey
(
username
))
return
false
;
ActiveUsers
.
put
(
iClientChat
,
false
);
return
true
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment