Commit 0b574f34 authored by abdullh.alsoleman's avatar abdullh.alsoleman

RMI

parent ff297eb3
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?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
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="9916a8b1-66b5-48c3-81ce-c9abf42151f9" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/RmiPolicy.policy" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Addroom.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Addroom.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Chat.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Chat.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ChatClient.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Chat_room.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Chat_room.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ClientChatImp.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/IClientChat.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/IServerChat.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/LoginForm.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/LoginForm.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/RegisterForm.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/RegisterForm.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/RemoveRoom.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/RemoveRoom.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Services.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Services.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Services_Room.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Services_Room.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ShowMyRoom.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ShowMyRoom.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ShowRooms.form" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ShowRooms.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/org/example/Main.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2XvM3tvLPpu36LfxtW75G0vQqsU" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<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",
"UI_DESIGNER_EDITOR_MODE.PaletteManager.WIDTH": "99",
"UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH": "313",
"last_opened_file_path": "C:/Users/Abdullah/Desktop/spring-boot-first-app"
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Abdullah\IdeaProjects\RMI_ChatClient\src\main\java" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="" />
</key>
</component>
<component name="RunManager" selected="Application.ChatClient (1)">
<configuration name="ChatClient (1)" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="ChatClient" />
<module name="RMI_ChatClient" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="ChatClient (2)" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="ChatClient" />
<module name="RMI_ChatClient" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="ChatClient" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="ChatClient" />
<module name="RMI_ChatClient" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Application.ChatClient (1)" />
<item itemvalue="Application.ChatClient (2)" />
<item itemvalue="Application.ChatClient" />
</list>
<recent_temporary>
<list>
<item itemvalue="Application.ChatClient" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="9916a8b1-66b5-48c3-81ce-c9abf42151f9" name="Changes" comment="" />
<created>1699504907247</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1699504907247</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>
\ No newline at end of file
grant{
permission java.security.AllPermission;
};
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>RMI_ChatClient</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Addroom">
<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>
<grid id="eded2" binding="Create" layout-manager="GridLayoutManager" row-count="10" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14107876"/>
</properties>
<border type="none"/>
<children>
<hspacer id="e174d">
<constraints>
<grid row="2" column="4" row-span="8" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="75594" class="javax.swing.JButton" binding="createButton" default-binding="true">
<constraints>
<grid row="8" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-4516330"/>
<font size="14" style="1"/>
<foreground color="-134412"/>
<text value="Create"/>
</properties>
</component>
<component id="b9c33" class="javax.swing.JButton" binding="closeButton" default-binding="true">
<constraints>
<grid row="8" column="3" 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="Close"/>
</properties>
</component>
<vspacer id="d0398">
<constraints>
<grid row="0" column="2" 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="e83c1" class="javax.swing.JTextField" binding="roomName">
<constraints>
<grid row="1" column="2" row-span="1" col-span="2" 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/>
</component>
<component id="16492" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="12" style="1"/>
<foreground color="-4516330"/>
<text value="Name of Room"/>
</properties>
</component>
</children>
</grid>
<vspacer id="b65dd">
<constraints>
<grid row="1" 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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
public class Addroom extends JFrame{
private JTextField roomName;
private JButton createButton;
private JPanel Create;
private JButton closeButton;
public Addroom(IServerChat serverChat, IClientChat clientChat) {
setContentPane(Create);
setSize(800,700);
setTitle("Register");
setVisible(true);
createButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if(serverChat.addRoom(roomName.getText())){
JOptionPane.showMessageDialog(Create, "Mission Complete", "Message", JOptionPane.INFORMATION_MESSAGE); };
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
Services s = new Services(serverChat,clientChat);
}
});
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Chat">
<grid id="27dc6" row-count="1" column-count="1" layout-manager="GridLayoutManager">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>
import javax.swing.*;
public abstract class Chat extends JDialog {
public abstract void setTextArea(String msg);
}
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
public class ChatClient {
public static void main(String[] args) throws MalformedURLException, NotBoundException, RemoteException {
String serverName= "localhost";
IServerChat iServerChat= (IServerChat) Naming.lookup("rmi://"+serverName+":5099/chat");
LoginForm loginForm=new LoginForm(iServerChat);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Chat_room">
<grid id="27dc6" binding="chatRoom" layout-manager="GridLayoutManager" row-count="3" column-count="2" 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="16edd" class="javax.swing.JTextArea" binding="allMessages">
<constraints>
<grid row="0" 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>
<background color="-134412"/>
<foreground color="-16382458"/>
</properties>
</component>
<component id="d088e" 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/>
</component>
<component id="f3d67" class="javax.swing.JButton" binding="send">
<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="e141d" class="javax.swing.JButton" binding="Cancel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-134412"/>
<foreground color="-16382458"/>
<text value="Cancel"/>
</properties>
</component>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
public class Chat_room extends Chat{
private JPanel chatRoom;
private JTextArea allMessages;
private JTextField message;
private JButton send;
private JButton Cancel;
public Chat_room(IServerChat serverChat,String user,String room) {
setContentPane(chatRoom);
setSize(800, 700);
setTitle("Login");
allMessages.setEditable(false);
send.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
serverChat.sendRoom(user,room,message.getText());
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
Cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
IClientChat clientChat= null;
try {
clientChat = serverChat.getClient(user);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
Services_Room services_room = new Services_Room(serverChat,clientChat,room);
}
});
setVisible(true);
}
@Override
public void setTextArea(String msg) {
allMessages.append("\n"+msg);
}
}
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class ClientChatImp extends UnicastRemoteObject implements IClientChat, Serializable {
private String name;
private char[] password;
private String firstName;
private String lastName;
private Chat chat;
public void setChat(ClientChatImp clientChatImp) {
this.chat = clientChatImp.chat;
}
protected ClientChatImp(String name, char[] password, String firstName, String lastName, Chat chat) throws RemoteException {
this.name=name;
this.password=password;
this.firstName=firstName;
this.lastName=lastName;
this.chat=chat;
}
protected ClientChatImp(String name, char[] password, String firstName, String lastName) throws RemoteException {
this.name=name;
this.password=password;
this.firstName=firstName;
this.lastName=lastName;
this.chat=null;
}
public ClientChatImp(String name, char[] password) throws RemoteException {
this.name = name;
this.password = password;
}
@Override
public String receiveMsg(String msg, String userName) throws RemoteException {
try {
this.chat.setTextArea(userName+": "+msg);
}catch (Exception e){
}
return null;
}
@Override
public String getName() throws RemoteException {
return name;
}
public ClientChatImp() throws RemoteException {
}
@Override
public char[] getPassword() throws RemoteException {
return password;
}
@Override
public String getFirstName() throws RemoteException {
return firstName;
}
@Override
public String getLastName() throws RemoteException {
return lastName;
}
@Override
public void setFirstName(String firstName) {
this.firstName=firstName;
}
}
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface IClientChat extends Remote {
String receiveMsg(String msg, String user) throws RemoteException;
String getName() throws RemoteException;
char[] getPassword() throws RemoteException;
String getFirstName() throws RemoteException;
String getLastName() throws RemoteException;
void setFirstName(String firstName) throws RemoteException;
}
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;
public interface IServerChat extends Remote {
boolean addRoom(String roomName) throws RemoteException;
boolean removeRoom(String roomName) throws RemoteException;
boolean signUp(IClientChat clientChat) throws RemoteException;
boolean signIn(IClientChat client, String room) throws RemoteException;
boolean signInSystem(String username, char[] password) throws RemoteException;
boolean signOut(IClientChat client, String room) throws RemoteException;
List<String> showAllRoom() throws RemoteException;
List<String> showMyRoom(IClientChat clientChat) throws RemoteException;
void sendRoom(String user,String room, String message ) throws RemoteException;
void sendChatRoom(IClientChat clientChat) throws RemoteException;
IClientChat getClient(String user) throws RemoteException;
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="LoginForm">
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="GridLayoutManager" row-count="17" column-count="4" 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="553" height="425"/>
</constraints>
<properties>
<background color="-7882053"/>
<foreground color="-16382458"/>
</properties>
<border type="none"/>
<children>
<grid id="6c26d" 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>
<grid row="0" column="0" row-span="17" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<hspacer id="97b61">
<constraints>
<grid row="16" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="c76a5">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="18c96">
<constraints>
<grid row="9" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="27649" class="javax.swing.JButton" binding="signUpButton" default-binding="true">
<constraints>
<grid row="14" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-12973247"/>
<enabled value="true"/>
<font name="Arial Black" size="14" style="1"/>
<foreground color="-134412"/>
<text value="Sign Up"/>
</properties>
</component>
<component id="f98e2" class="javax.swing.JPasswordField" binding="password">
<constraints>
<grid row="7" column="2" 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>
<background color="-9538440"/>
<font name="Arial Black" size="16" style="1"/>
</properties>
</component>
<component id="4303f" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Arial Black" size="16" style="1"/>
<foreground color="-16382458"/>
<text value="Password"/>
</properties>
</component>
<component id="b5496" class="javax.swing.JTextField" binding="name">
<constraints>
<grid row="4" column="2" 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>
<background color="-9538440"/>
<font name="Arial Black" size="16" style="1"/>
<text value=""/>
</properties>
</component>
<component id="21ec5" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-9538440"/>
<font name="Arial Black" size="14" style="1"/>
<foreground color="-16382458"/>
<text value="Name"/>
</properties>
</component>
<component id="f453" class="javax.swing.JButton" binding="signInButton" default-binding="true">
<constraints>
<grid row="11" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14873791"/>
<enabled value="true"/>
<font name="Arial Black" size="14" style="1"/>
<foreground color="-134412"/>
<text value="Sign In"/>
</properties>
</component>
<component id="2baef" class="javax.swing.JLabel">
<constraints>
<grid row="13" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Arial Black" size="14" style="1"/>
<foreground color="-4516330"/>
<text value="If you don't have an account, You can Sign Up"/>
</properties>
</component>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
public class LoginForm extends JFrame{
private JPanel panel1;
private JTextField name;
private JPasswordField password;
private JButton signInButton;
private JButton signUpButton;
public LoginForm(IServerChat serverChat) {
setContentPane(panel1);
setSize(800,700);
setTitle("Login");
setVisible(true);
signInButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if (serverChat.signInSystem(name.getText(),password.getPassword())) {
dispose();
IClientChat clientChat = new ClientChatImp(name.getText(), password.getPassword());
Services services = new Services(serverChat,clientChat);
}
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
signUpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
RegisterForm registerForm =new RegisterForm(serverChat);
}
});
;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="RegisterForm">
<grid id="27dc6" binding="SsignUp" layout-manager="GridLayoutManager" row-count="14" column-count="6" 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="652" height="559"/>
</constraints>
<properties>
<background color="-15880962"/>
</properties>
<border type="none"/>
<children>
<component id="cc8b1" class="javax.swing.JTextField" binding="firstName">
<constraints>
<grid row="8" column="1" row-span="1" col-span="4" 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>
<font name="Arial Black" size="16" style="1"/>
<foreground color="-15222000"/>
</properties>
</component>
<component id="76d35" class="javax.swing.JTextField" binding="lastName">
<constraints>
<grid row="11" column="1" row-span="1" col-span="4" 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>
<font name="Arial Black" size="16" style="1"/>
<foreground color="-13976821"/>
</properties>
</component>
<vspacer id="2ff59">
<constraints>
<grid row="0" column="1" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="11" height="39"/>
</grid>
</constraints>
</vspacer>
<vspacer id="a5f71">
<constraints>
<grid row="9" column="1" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<hspacer id="1136f">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="283e5" class="javax.swing.JButton" binding="signUpButton" default-binding="true">
<constraints>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-5456983"/>
<enabled value="true"/>
<font size="16" style="1"/>
<foreground color="-16382458"/>
<text value="Sign Up"/>
</properties>
</component>
<vspacer id="112c5">
<constraints>
<grid row="12" column="1" 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="f52ce" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="JetBrains Mono ExtraBold" size="22" style="1"/>
<foreground color="-4516330"/>
<text value="Password"/>
</properties>
</component>
<component id="d5be8" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="JetBrains Mono ExtraBold" size="22" style="1"/>
<foreground color="-4516330"/>
<text value="User Name"/>
</properties>
</component>
<component id="c49c8" class="javax.swing.JTextField" binding="name">
<constraints>
<grid row="2" column="1" row-span="1" col-span="4" 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>
<font name="Arial Black" size="16" style="1"/>
<foreground color="-14042338"/>
<text value=""/>
</properties>
</component>
<hspacer id="e0461">
<constraints>
<grid row="7" column="5" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="b02ea" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="JetBrains Mono ExtraBold" size="22" style="1"/>
<foreground color="-4516330"/>
<text value="First Name"/>
</properties>
</component>
<vspacer id="3acf">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="7a10b">
<constraints>
<grid row="3" column="1" 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="3a503" class="javax.swing.JPasswordField" binding="passwordField1" default-binding="true">
<constraints>
<grid row="5" column="1" row-span="1" col-span="4" 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>
<font name="Arial Black" size="16" style="1"/>
<foreground color="-12010721"/>
</properties>
</component>
<component id="b3450" class="javax.swing.JLabel">
<constraints>
<grid row="10" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="JetBrains Mono ExtraBold" size="22" style="1"/>
<foreground color="-4516330"/>
<text value="Last Name"/>
</properties>
</component>
<component id="99b74" class="javax.swing.JButton" binding="cancelButton" default-binding="true">
<constraints>
<grid row="13" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-5456983"/>
<enabled value="true"/>
<font size="16" style="1"/>
<foreground color="-16382458"/>
<text value="Cancel "/>
</properties>
</component>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import java.rmi.RemoteException;
public class RegisterForm extends JFrame {
private JPanel SsignUp;
private JTextField firstName;
private JTextField lastName;
private JButton signUpButton;
private JTextField name;
private JPasswordField passwordField1;
private JButton cancelButton;
public RegisterForm(IServerChat serverChat) {
setContentPane(SsignUp);
setSize(800,700);
setTitle("Register");
setVisible(true);
signUpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
IClientChat clientChat = new ClientChatImp(name.getText(),passwordField1.getPassword(),firstName.getText(),lastName.getText());
if (serverChat.signUp(clientChat));
JOptionPane.showMessageDialog(SsignUp, "Mission Complete", "Message", JOptionPane.INFORMATION_MESSAGE);
dispose();
LoginForm login =new LoginForm(serverChat);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
LoginForm login =new LoginForm(serverChat);
}
});
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="RemoveRoom">
<grid id="27dc6" binding="Remove" layout-manager="GridLayoutManager" row-count="6" column-count="3" 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>
<background color="-14107876"/>
</properties>
<border type="none"/>
<children>
<hspacer id="7e927">
<constraints>
<grid row="0" column="0" row-span="6" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="51fa0">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="f0558">
<constraints>
<grid row="0" column="2" row-span="6" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="a0c13" class="javax.swing.JTextField" binding="roomName">
<constraints>
<grid row="2" column="1" 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/>
</component>
<component id="e3e5" class="javax.swing.JButton" binding="removeButton" default-binding="true">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-4516330"/>
<font size="14" style="1"/>
<text value="Remove"/>
</properties>
</component>
<component id="1d267" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="12" style="1"/>
<foreground color="-4516330"/>
<text value="Room Name"/>
</properties>
</component>
<vspacer id="ca8a6">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="46215">
<constraints>
<grid row="3" column="1" 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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
public class RemoveRoom extends JFrame {
private JPanel Remove;
private JTextField roomName;
private JButton removeButton;
public RemoveRoom(IServerChat serverChat, IClientChat clientChat) {
removeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if(serverChat.removeRoom(roomName.getText()))
JOptionPane.showMessageDialog(Remove, "Mission Complete", "Message", JOptionPane.INFORMATION_MESSAGE);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Services">
<grid id="27dc6" 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>
<grid id="68507" binding="Services" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-13628095"/>
</properties>
<border type="none"/>
<children>
<component id="5941a" class="javax.swing.JButton" binding="createRoomButton" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14107876"/>
<enabled value="true"/>
<font style="1"/>
<text value="Create room"/>
</properties>
</component>
<component id="b8072" class="javax.swing.JButton" binding="showAllRoomButton" default-binding="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14107876"/>
<font style="1"/>
<text value="Show all room"/>
</properties>
</component>
<component id="74985" class="javax.swing.JButton" binding="removeRoomButton" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14107876"/>
<enabled value="true"/>
<font style="1"/>
<text value="Remove room"/>
</properties>
</component>
<hspacer id="3c00a">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="98a4d">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="c08eb" class="javax.swing.JButton" binding="showMyRoomButton" default-binding="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14107876"/>
<font style="1"/>
<text value="Show my room"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
public class Services extends JFrame {
private JPanel Services;
private JButton createRoomButton;
private JButton showAllRoomButton;
private JButton removeRoomButton;
private JButton showMyRoomButton;
public Services(IServerChat serverChat,IClientChat clientChat) {
setContentPane(Services);
setSize(800,700);
setTitle("Register");
setVisible(true);
createRoomButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
Addroom addroom= new Addroom(serverChat,clientChat);
}
});
removeRoomButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
RemoveRoom removeRoom = new RemoveRoom(serverChat,clientChat);
}
});
showMyRoomButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
ShowMyRoom showMyRoom = new ShowMyRoom(serverChat,clientChat);
}
});
showAllRoomButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
ShowRooms showRooms =new ShowRooms(serverChat,clientChat);
}
});
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Services_Room">
<grid id="27dc6" binding="services_room" layout-manager="GridLayoutManager" row-count="5" column-count="3" 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>
<background color="-14107876"/>
</properties>
<border type="none"/>
<children>
<component id="7b657" class="javax.swing.JButton" binding="joinButton" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-4516330"/>
<font size="14" style="1"/>
<text value="Join"/>
</properties>
</component>
<component id="f3b4f" class="javax.swing.JButton" binding="cancelButton" default-binding="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-4516330"/>
<font size="14" style="1"/>
<text value="Cancel"/>
</properties>
</component>
<vspacer id="d3969">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="69b68">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="4d004">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<hspacer id="e806b">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="587e2">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
public class Services_Room extends JFrame {
private JPanel services_room;
private JButton joinButton;
private JButton cancelButton;
public Services_Room(IServerChat serverChat,IClientChat clientChat,String room) {
setContentPane(services_room);
setSize(800,700);
setTitle("Join");
joinButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
if(serverChat.signIn(clientChat,room))
JOptionPane.showMessageDialog(services_room, "Mission Complete", "Message", JOptionPane.INFORMATION_MESSAGE);
dispose();
Chat_room chat_room = new Chat_room(serverChat,clientChat.getName(),room);
ClientChatImp clientChatImp = new ClientChatImp(clientChat.getName(),clientChat.getPassword(),clientChat.getFirstName()
,clientChat.getLastName(), chat_room);
serverChat.sendChatRoom(clientChatImp);
} catch (RemoteException ex) {
throw new RuntimeException(ex);
}
}
});
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
Services s = new Services(serverChat,clientChat);
}
});
setVisible(true);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ShowMyRoom">
<grid id="27dc6" binding="rooms" layout-manager="GridLayoutManager" row-count="1" column-count="5" 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="481" height="400"/>
</constraints>
<properties>
<background color="-134412"/>
<font name="Arial Black" size="14" style="1"/>
</properties>
<border type="none"/>
<children>
<component id="1f23c" class="javax.swing.JList" binding="roomList">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties>
<background color="-9538440"/>
<font name="Arial Black" size="14" style="1"/>
<foreground color="-16382458"/>
</properties>
</component>
<scrollpane id="af0e7" binding="scroll">
<constraints>
<grid row="0" column="4" 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/>
</scrollpane>
<hspacer id="3eaea">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="de842">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="be4ec">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</form>
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.rmi.RemoteException;
public class ShowMyRoom extends JFrame implements ListSelectionListener {
private JPanel rooms;
private JList roomList;
private JScrollPane scroll;
public ShowMyRoom(IServerChat serverChat, IClientChat clientChat) {
setContentPane(rooms);
setSize(800,700);
setTitle("All rooms");
try {
roomList=new JList<>((ListModel) serverChat.showMyRoom(clientChat));
roomList.addListSelectionListener(this);
scroll = new JScrollPane(roomList);
// Set up the main layout
setLayout(new BorderLayout());
add(scroll, BorderLayout.CENTER);
// Display the window
pack();
setLocationRelativeTo(null);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
setVisible(true);
}
@Override
public void valueChanged(ListSelectionEvent e) {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ShowRooms">
<grid id="27dc6" binding="rooms" layout-manager="GridLayoutManager" row-count="1" column-count="5" 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>
<background color="-134412"/>
</properties>
<border type="none"/>
<children>
<component id="5dfbf" class="javax.swing.JList" binding="roomList">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties>
<background color="-9538440"/>
<font name="Arial Black" size="14" style="1"/>
<foreground color="-16382458"/>
</properties>
</component>
<scrollpane id="18c97" binding="scroll">
<constraints>
<grid row="0" column="4" 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/>
</scrollpane>
<hspacer id="b52c4">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="a59e6">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="cfe05">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</form>
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
public class ShowRooms extends JFrame{
private JPanel rooms;
private JList roomList;
private JScrollPane scroll;
public ShowRooms(IServerChat serverChat, IClientChat clientChat) {
setContentPane(rooms);
setSize(800,700);
setTitle("My room");
try {
String [] s= new String[1000];
List<String> st= new ArrayList<>();
st.addAll(serverChat.showAllRoom());
for(int i=0; i< st.size(); i++){
s[i]=st.get(i);
}
roomList=new JList<>(s);
roomList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
// Get the selected item from the list
String selectedRoom = (String) roomList.getSelectedValue();
// Perform your action here
performAction(selectedRoom,serverChat,clientChat);
}
}
});
scroll = new JScrollPane(roomList);
// Set up the main layout
setLayout(new BorderLayout());
add(scroll, BorderLayout.CENTER);
// Display the window
pack();
setLocationRelativeTo(null);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
setVisible(true);
}
private void performAction(String selectedRoom, IServerChat serverChat,IClientChat clientChat) {
dispose();
Services_Room s = new Services_Room(serverChat,clientChat,selectedRoom);
}
}
package org.example;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
\ No newline at end of file
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?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
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="d9dd8877-fa22-4f7a-ba29-142c60f34096" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/RmiPolicy.policy" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ChatServer.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/ChatServiceImpl.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/IClientChat.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/IServerChat.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/Room.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2XrJRBXbbxy2kqPQV6pHToxbN0G" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<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": "C:/Users/Abdullah/IdeaProjects/RMI_ChatServer"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d9dd8877-fa22-4f7a-ba29-142c60f34096" name="Changes" comment="" />
<created>1699381258242</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1699381258242</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>
\ No newline at end of file
grant{
permission java.security.AllPermission;
};
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>RMI_ChatServer</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class ChatServer {
public static void main(String[] args) throws RemoteException {
System.setProperty("java.security.policy", "./RmiPolicy.policy");
System.setSecurityManager(new SecurityManager());
Registry reg = LocateRegistry.createRegistry(5099);
ChatServiceImpl serverChatImp = new ChatServiceImpl();
reg.rebind("chat",serverChatImp);
System.out.println("running");
}
}
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.List;
public class ChatServiceImpl extends UnicastRemoteObject implements IServerChat {
static final private List<IClientChat> registerClients = new ArrayList<>();
static final private List<IClientChat> loginClients = new ArrayList<>();
static final private List<Room> rooms = new ArrayList<>();
public ChatServiceImpl() throws RemoteException {
super();
}
@Override
public boolean addRoom(String roomName) throws RemoteException {
Room room = new Room(roomName);
rooms.add(room);
return true;
}
@Override
public boolean removeRoom(String roomName) throws RemoteException {
for (Room room : rooms
) {
if (room.getName().equals(roomName)) {
rooms.remove(room);
return true;
}
}
return false;
}
@Override
public boolean signUp(IClientChat clientChat) throws RemoteException {
registerClients.add(clientChat);
return true;
}
@Override
public boolean signInSystem(String username, char[] password) throws RemoteException {
for ( int i =0 ; i<registerClients.size(); i++) {
String s =registerClients.get(i).getName();
boolean b =registerClients.get(i).getName().equals(username);
if (b) {
char[] ss = registerClients.get(i).getPassword();
boolean bb = true;
for(int j =0 ; j<password.length;j++){
if(password[j]!=ss[j]){
bb=false;
break;
}
}
if (bb) {
for (IClientChat c: loginClients
) {
if(c.getName()==registerClients.get(i).getName()){
loginClients.remove(registerClients.get(i));
loginClients.add(registerClients.get(i));
}
}
loginClients.add(registerClients.get(i));
return true;
}
}
}
return false;
}
@Override
public boolean signIn(IClientChat client, String room) throws RemoteException {
for (Room r : rooms) {
if (r.getName().equals(room)) {
r.getClients().add(client);
return true;
}
}
return false;
}
@Override
public boolean signOut(IClientChat client, String room) throws RemoteException {
for (Room r : rooms) {
if (r.getName().equals(room)) {
r.getClients().remove(client);
return true;
}
}
return false;
}
@Override
public List<String> showAllRoom() throws RemoteException {
List<String> room =new ArrayList<>();
for (Room r:rooms
) {
room.add(r.getName());
}
return room;
}
@Override
public List<String> showMyRoom(IClientChat clientChat) throws RemoteException {
List<String> room = new ArrayList<>();
for (Room r:rooms
) {
for (IClientChat c: r.getClients()
) {
if(c.getName().equals(clientChat.getName()))
room.add(c.getName());
}
}
return room;
}
@Override
public void sendRoom(String user, String room, String message) throws RemoteException {
for (Room r: rooms
) {
if (r.getName().equals(room)) {
for (int i=0; i< r.getClients().size(); i++){
r.getClients().get(i).receiveMsg(message,user);
}
}
}
}
@Override
public void sendChatRoom(IClientChat clientChat) {
for(int i=0; i<loginClients.size();i++){
try {
boolean b=clientChat.getName().equals(loginClients.get(i).getName());
if(b){
clientChat.setFirstName(loginClients.get(i).getFirstName());
loginClients.remove(loginClients.get(i));
loginClients.add(clientChat);
break;
}
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
}
@Override
public IClientChat getClient(String user) {
for (IClientChat c : registerClients) {
try {
if(user.equals(c.getName())){
return c;
}
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
return null;
}
}
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface IClientChat extends Remote {
String receiveMsg(String msg, String user) throws RemoteException;
String getName() throws RemoteException;
char[] getPassword() throws RemoteException;
String getFirstName() throws RemoteException;
String getLastName() throws RemoteException;
void setFirstName(String firstName);
}
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;
public interface IServerChat extends Remote {
boolean addRoom(String roomName) throws RemoteException;
boolean removeRoom(String roomName) throws RemoteException;
boolean signUp(IClientChat clientChat) throws RemoteException;
boolean signIn(IClientChat client, String room) throws RemoteException;
boolean signInSystem(String username, char[] password) throws RemoteException;
boolean signOut(IClientChat client, String room) throws RemoteException;
List<String> showAllRoom() throws RemoteException;
List<String> showMyRoom(IClientChat clientChat) throws RemoteException;
void sendRoom(String user,String room, String message ) throws RemoteException;
void sendChatRoom(IClientChat clientChat) throws RemoteException;
IClientChat getClient(String user) throws RemoteException;
}
\ No newline at end of file
import java.util.ArrayList;
import java.util.List;
public class Room {
private String Name;
private List <IClientChat> clientChats = new ArrayList<>();
public Room(String name) {
Name = name;
}
public String getName() {
return Name;
}
public List<IClientChat> getClients() {
return clientChats;
}
}
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