diff --git a/Application/.metadata/.lock b/Application/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.log b/Application/.metadata/.log new file mode 100644 index 0000000..642b3c6 --- /dev/null +++ b/Application/.metadata/.log @@ -0,0 +1,329 @@ +!SESSION 2020-11-23 15:30:50.238 ----------------------------------------------- +eclipse.buildId=4.7.3.M20180330-0640 +java.version=1.8.0_201 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR +Framework arguments: -product org.eclipse.epp.package.jee.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product + +!ENTRY org.eclipse.egit.ui 2 0 2020-11-23 15:31:12.822 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Alexandre'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.epp.logging.aeri.ide 2 17 2020-11-23 15:31:14.799 +!MESSAGE Server ‘org.eclipse.epp.logging.aeri.ide.server’ failed with exception: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $. ; version: 2.0.7.v20170906-1327 +!STACK 0 +com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ + at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) + at com.google.gson.Gson.fromJson(Gson.java:887) + at com.google.gson.Gson.fromJson(Gson.java:852) + at com.google.gson.Gson.fromJson(Gson.java:801) + at org.eclipse.epp.internal.logging.aeri.ide.server.json.Json.deserialize(Json.java:91) + at org.eclipse.epp.internal.logging.aeri.ide.server.mars.IO.refreshConfiguration(IO.java:66) + at org.eclipse.epp.internal.logging.aeri.ide.server.mars.ServerConnection.startUp(ServerConnection.java:124) + at com.google.common.util.concurrent.AbstractIdleService$DelegateService$1.run(AbstractIdleService.java:62) + at com.google.common.util.concurrent.Callables$4.run(Callables.java:122) + at java.lang.Thread.run(Unknown Source) +Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ + at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385) + at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213) + ... 9 more + +!ENTRY org.eclipse.jface.text 2 0 2020-11-23 15:34:54.016 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.number' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-23 15:34:54.022 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.round' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-23 15:34:54.151 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.number' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-23 15:34:54.160 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.round' + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2020-11-23 15:36:20.577 +!MESSAGE Failed to download org.eclipse.recommenders:index::zip:0.0.0 +!STACK 0 +org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) + at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) + at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) + at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) + at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) + at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) +Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) + at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:76) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:590) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:258) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:529) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) + ... 8 more + +!ENTRY org.eclipse.recommenders.models.rcp 1 0 2020-11-23 15:36:20.588 +!MESSAGE org.eclipse.recommenders:index::zip:0.0.0 could not be resolved from the model repositories. Are you offline? +!SESSION 2020-11-26 08:07:45.698 ----------------------------------------------- +eclipse.buildId=4.7.3.M20180330-0640 +java.version=1.8.0_201 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR +Framework arguments: -product org.eclipse.epp.package.jee.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product + +!ENTRY org.eclipse.egit.ui 2 0 2020-11-26 08:08:01.925 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Alexandre'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.epp.logging.aeri.ide 2 17 2020-11-26 08:08:03.910 +!MESSAGE Server ‘org.eclipse.epp.logging.aeri.ide.server’ failed with exception: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $. ; version: 2.0.7.v20170906-1327 +!STACK 0 +com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ + at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) + at com.google.gson.Gson.fromJson(Gson.java:887) + at com.google.gson.Gson.fromJson(Gson.java:852) + at com.google.gson.Gson.fromJson(Gson.java:801) + at org.eclipse.epp.internal.logging.aeri.ide.server.json.Json.deserialize(Json.java:91) + at org.eclipse.epp.internal.logging.aeri.ide.server.mars.IO.refreshConfiguration(IO.java:66) + at org.eclipse.epp.internal.logging.aeri.ide.server.mars.ServerConnection.startUp(ServerConnection.java:124) + at com.google.common.util.concurrent.AbstractIdleService$DelegateService$1.run(AbstractIdleService.java:62) + at com.google.common.util.concurrent.Callables$4.run(Callables.java:122) + at java.lang.Thread.run(Unknown Source) +Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ + at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385) + at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213) + ... 9 more + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 08:15:21.045 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.number' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 08:15:21.051 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.round' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 08:21:08.999 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.number' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 08:21:09.006 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.round' + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2020-11-26 08:21:09.779 +!MESSAGE Failed to download org.eclipse.recommenders:index::zip:0.0.0 +!STACK 0 +org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) + at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) + at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) + at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) + at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) + at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) +Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) + at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:76) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:590) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:258) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:529) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) + ... 8 more + +!ENTRY org.eclipse.recommenders.models.rcp 1 0 2020-11-26 08:21:09.787 +!MESSAGE org.eclipse.recommenders:index::zip:0.0.0 could not be resolved from the model repositories. Are you offline? +!SESSION 2020-11-26 09:56:55.412 ----------------------------------------------- +eclipse.buildId=4.7.3.M20180330-0640 +java.version=1.8.0_201 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR +Framework arguments: -product org.eclipse.epp.package.jee.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product + +!ENTRY org.eclipse.core.resources 2 10035 2020-11-26 09:56:59.183 +!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. + +!ENTRY org.eclipse.egit.ui 2 0 2020-11-26 09:57:08.337 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Alexandre'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.epp.logging.aeri.ide 2 17 2020-11-26 09:57:10.263 +!MESSAGE Server ‘org.eclipse.epp.logging.aeri.ide.server’ failed with exception: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $. ; version: 2.0.7.v20170906-1327 +!STACK 0 +com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ + at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) + at com.google.gson.Gson.fromJson(Gson.java:887) + at com.google.gson.Gson.fromJson(Gson.java:852) + at com.google.gson.Gson.fromJson(Gson.java:801) + at org.eclipse.epp.internal.logging.aeri.ide.server.json.Json.deserialize(Json.java:91) + at org.eclipse.epp.internal.logging.aeri.ide.server.mars.IO.refreshConfiguration(IO.java:66) + at org.eclipse.epp.internal.logging.aeri.ide.server.mars.ServerConnection.startUp(ServerConnection.java:124) + at com.google.common.util.concurrent.AbstractIdleService$DelegateService$1.run(AbstractIdleService.java:62) + at com.google.common.util.concurrent.Callables$4.run(Callables.java:122) + at java.lang.Thread.run(Unknown Source) +Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ + at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385) + at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213) + ... 9 more + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 10:04:24.217 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.number' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 10:04:24.225 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.round' + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2020-11-26 10:04:24.997 +!MESSAGE Failed to download org.eclipse.recommenders:index::zip:0.0.0 +!STACK 0 +org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) + at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) + at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) + at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) + at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) + at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) +Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) + at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:76) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:590) + at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:258) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:529) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) + ... 8 more + +!ENTRY org.eclipse.recommenders.models.rcp 1 0 2020-11-26 10:04:25.004 +!MESSAGE org.eclipse.recommenders:index::zip:0.0.0 could not be resolved from the model repositories. Are you offline? + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 10:07:22.777 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.number' + +!ENTRY org.eclipse.jface.text 2 0 2020-11-26 10:07:22.785 +!MESSAGE Duplicate template id: 'org.eclipse.wst.xslt.templates.xpath.round' + +!ENTRY org.eclipse.ui.ide 4 4 2020-11-26 11:26:25.254 +!MESSAGE Problems saving workspace + +!ENTRY org.eclipse.ui.ide 2 1 2020-11-26 11:26:25.280 +!MESSAGE Problems occurred while trying to save the state of the workbench. +!SUBENTRY 1 org.eclipse.core.resources 2 234 2020-11-26 11:26:25.280 +!MESSAGE The project description file (.project) for 'RemoteSystemsTempFiles' was missing. This file contains important information about the project. A new project description file has been created, but some information about the project may have been lost. + +!ENTRY org.eclipse.recommenders.coordinates.rcp 4 9 2020-11-26 11:26:25.296 +!MESSAGE Failed to write manual mappings to file ‘C:\Users\Alexandre\Downloads\src-20201006T193227Z-001\.recommenders\caches\manual-mappings.json’. +!STACK 0 +java.io.FileNotFoundException: C:\Users\Alexandre\Downloads\src-20201006T193227Z-001\.recommenders\caches\manual-mappings.json (Le chemin d’accès spécifié est introuvable) + at java.io.FileOutputStream.open0(Native Method) + at java.io.FileOutputStream.open(Unknown Source) + at java.io.FileOutputStream.(Unknown Source) + at com.google.common.io.Files$FileByteSink.openStream(Files.java:245) + at com.google.common.io.Files$FileByteSink.openStream(Files.java:233) + at com.google.common.io.ByteSink$AsCharSink.openStream(ByteSink.java:158) + at com.google.common.io.CharSink.write(CharSink.java:105) + at com.google.common.io.Files.write(Files.java:489) + at org.eclipse.recommenders.internal.coordinates.rcp.ManualProjectCoordinateAdvisor.close(ManualProjectCoordinateAdvisor.java:102) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) + at java.lang.reflect.Method.invoke(Unknown Source) + at org.eclipse.recommenders.internal.rcp.RcpModule$Listener$1.executeMethod(RcpModule.java:292) + at org.eclipse.recommenders.internal.rcp.RcpModule$Listener$1.access$0(RcpModule.java:289) + at org.eclipse.recommenders.internal.rcp.RcpModule$Listener$1$1.postShutdown(RcpModule.java:308) + at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:984) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) + at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:44) + at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173) + at org.eclipse.ui.internal.Workbench.firePostShutdown(Workbench.java:981) + at org.eclipse.ui.internal.Workbench.shutdown(Workbench.java:3028) + at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1174) + at org.eclipse.ui.internal.Workbench.lambda$4(Workbench.java:1424) + at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) + at org.eclipse.ui.internal.Workbench.close(Workbench.java:1424) + at org.eclipse.ui.internal.Workbench.close(Workbench.java:1397) + at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:1606) + at org.eclipse.ui.internal.WorkbenchWindow.access$18(WorkbenchWindow.java:1552) + at org.eclipse.ui.internal.WorkbenchWindow$11.run(WorkbenchWindow.java:1638) + at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) + at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1635) + at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1649) + at org.eclipse.ui.internal.WorkbenchWindow$6.close(WorkbenchWindow.java:530) + at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer$3.shellClosed(WBWRenderer.java:615) + at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:99) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088) + at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:316) + at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decorations.java:1729) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4845) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:359) + at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1657) + at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2199) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5178) + at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) + at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2555) + at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:506) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4941) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:359) + at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1657) + at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2199) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5178) + at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method) + at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3152) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3812) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) + at java.lang.reflect.Method.invoke(Unknown Source) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590) + at org.eclipse.equinox.launcher.Main.run(Main.java:1499) + +!ENTRY org.eclipse.recommenders.coordinates.rcp 4 8 2020-11-26 11:26:25.303 +!MESSAGE Failed to write cached coordinates to file ‘C:\Users\Alexandre\Downloads\src-20201006T193227Z-001\.recommenders\caches\identified-project-coordinates.json’. +!STACK 0 +java.io.FileNotFoundException: C:\Users\Alexandre\Downloads\src-20201006T193227Z-001\.recommenders\caches\identified-project-coordinates.json (Le chemin d’accès spécifié est introuvable) + at java.io.FileOutputStream.open0(Native Method) + at java.io.FileOutputStream.open(Unknown Source) + at java.io.FileOutputStream.(Unknown Source) + at com.google.common.io.Files$FileByteSink.openStream(Files.java:245) + at com.google.common.io.Files$FileByteSink.openStream(Files.java:233) + at com.google.common.io.ByteSink$AsCharSink.openStream(ByteSink.java:158) + at com.google.common.io.CharSink.write(CharSink.java:105) + at com.google.common.io.Files.write(Files.java:489) + at org.eclipse.recommenders.coordinates.rcp.EclipseProjectCoordinateAdvisorService.shutDown(EclipseProjectCoordinateAdvisorService.java:220) + at com.google.common.util.concurrent.AbstractIdleService$2$2.run(AbstractIdleService.java:69) + at com.google.common.util.concurrent.Callables$3.run(Callables.java:93) + at java.lang.Thread.run(Unknown Source) + +!ENTRY org.eclipse.core.resources 2 10035 2020-11-26 11:26:26.962 +!MESSAGE The workspace will exit with unsaved changes in this session. diff --git a/Application/.metadata/.mylyn/.taskListIndex/segments_1 b/Application/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000..1a24121 Binary files /dev/null and b/Application/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/Application/.metadata/.mylyn/.taskListIndex/write.lock b/Application/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.mylyn/.tasks.xml.zip b/Application/.metadata/.mylyn/.tasks.xml.zip new file mode 100644 index 0000000..52b3bd7 Binary files /dev/null and b/Application/.metadata/.mylyn/.tasks.xml.zip differ diff --git a/Application/.metadata/.mylyn/repositories.xml.zip b/Application/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000..b28d9da Binary files /dev/null and b/Application/.metadata/.mylyn/repositories.xml.zip differ diff --git a/Application/.metadata/.mylyn/tasks.xml.zip b/Application/.metadata/.mylyn/tasks.xml.zip new file mode 100644 index 0000000..a551df7 Binary files /dev/null and b/Application/.metadata/.mylyn/tasks.xml.zip differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1/00a796ffc82f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1/00a796ffc82f001b1e93f29abc467978 new file mode 100644 index 0000000..9d8708d --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1/00a796ffc82f001b1e93f29abc467978 @@ -0,0 +1,167 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + } + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1/b00bc677c62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1/b00bc677c62f001b1e93f29abc467978 new file mode 100644 index 0000000..b93f0f0 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1/b00bc677c62f001b1e93f29abc467978 @@ -0,0 +1,162 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.setSoTimeout(1000); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/10/009d1accbe2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/10/009d1accbe2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..55e2e36 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/10/009d1accbe2f001b1e3d9e6aa3539da2 @@ -0,0 +1,147 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/11/9068c7d9c12f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/11/9068c7d9c12f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..509f690 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/11/9068c7d9c12f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5001,"Mike"); + + User usr1 = new User(5001); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/11/d0da6602c52f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/11/d0da6602c52f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1094ac3 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/11/d0da6602c52f001b1e3d9e6aa3539da2 @@ -0,0 +1,156 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/15/7048afa7c42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/15/7048afa7c42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..a6a286f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/15/7048afa7c42f001b1e3d9e6aa3539da2 @@ -0,0 +1,156 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1d/503ad34ac22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1d/503ad34ac22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..a82c123 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/1d/503ad34ac22f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12459); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/20/00748f8fc82f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/20/00748f8fc82f001b1e93f29abc467978 new file mode 100644 index 0000000..78c09b2 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/20/00748f8fc82f001b1e93f29abc467978 @@ -0,0 +1,168 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + buffer = 0; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/20/90d9db00bb2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/20/90d9db00bb2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..fd901f4 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/20/90d9db00bb2f001b1e3d9e6aa3539da2 @@ -0,0 +1,138 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this +); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/21/c020b9b5ca2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/21/c020b9b5ca2f001b1e93f29abc467978 new file mode 100644 index 0000000..9101dcc --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/21/c020b9b5ca2f001b1e93f29abc467978 @@ -0,0 +1,177 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="") { + System.out.println("Reponse : "+response); + } + lstresponse = response.split(":"); + System.out.println(lstresponse[0]); + + System.out.println(lstresponse[1]); + + System.out.println(lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/22/00e0f90fcc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/22/00e0f90fcc2f001b1e93f29abc467978 new file mode 100644 index 0000000..19c425c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/22/00e0f90fcc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid= (tmpPseudo.compareTo(lstresponse[2])!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/26/c0a6d335c82f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/26/c0a6d335c82f001b1e93f29abc467978 new file mode 100644 index 0000000..0f97cdd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/26/c0a6d335c82f001b1e93f29abc467978 @@ -0,0 +1,167 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/29/703901daa12d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/29/703901daa12d001b1caedccf60ced923 new file mode 100644 index 0000000..ecc78f0 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/29/703901daa12d001b1caedccf60ced923 @@ -0,0 +1,132 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String isPseudo = new String(buffer); + System.out.println(isPseudo); + valid = isPseudo!=tmpPseudo; + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2a/80d73a57cc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2a/80d73a57cc2f001b1e93f29abc467978 new file mode 100644 index 0000000..1a25c81 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2a/80d73a57cc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= (lstresponse[2].compareTo("Mike")!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2a/f0036b44cc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2a/f0036b44cc2f001b1e93f29abc467978 new file mode 100644 index 0000000..e508f56 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2a/f0036b44cc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= ("Mike".compareTo("Mike")!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2b/50a6a663c92f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2b/50a6a663c92f001b1e93f29abc467978 new file mode 100644 index 0000000..213f2ae --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2b/50a6a663c92f001b1e93f29abc467978 @@ -0,0 +1,168 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2c/501d4aafb82f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2c/501d4aafb82f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1f188b8 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/2c/501d4aafb82f001b1e3d9e6aa3539da2 @@ -0,0 +1,10 @@ + +public class UserListeningThread extends Thread{ + public UserListeningThread(String s){ + super(s); + } + + public void run(){ + + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/30/f09ee97fc22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/30/f09ee97fc22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..cf6dd24 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/30/f09ee97fc22f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/33/1002494aca2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/33/1002494aca2f001b1e93f29abc467978 new file mode 100644 index 0000000..0d13db1 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/33/1002494aca2f001b1e93f29abc467978 @@ -0,0 +1,178 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="") { + System.out.println("Reponse non normalisé : "+response); + } + lstresponse = response.split(":"); + System.out.println(lstresponse[0]); + + System.out.println(lstresponse[1]); + + System.out.println(lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/37/b01832d0cc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/37/b01832d0cc2f001b1e93f29abc467978 new file mode 100644 index 0000000..8f5ba02 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/37/b01832d0cc2f001b1e93f29abc467978 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= null; + try { + dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo()+":testS"; + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/38/d0627f489f2d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/38/d0627f489f2d001b1caedccf60ced923 new file mode 100644 index 0000000..430c095 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/38/d0627f489f2d001b1caedccf60ced923 @@ -0,0 +1,106 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(not(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) { + int nbResponseMin = 2; + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(1001,addIP); + byte[] buffer = new byte[256]; + + DatagramPacket outPacket1= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1001); + DatagramPacket outPacket2= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1002); + + dgramSocket.send(outPacket1); + dgramSocket.send(outPacket2); + + + + + + Socket link = new Socket(addIP,2); + + return + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3c/204678ddc22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3c/204678ddc22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..0a75992 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3c/204678ddc22f001b1e3d9e6aa3539da2 @@ -0,0 +1,147 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3c/d0f0480dcc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3c/d0f0480dcc2f001b1e93f29abc467978 new file mode 100644 index 0000000..7805cbb --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3c/d0f0480dcc2f001b1e93f29abc467978 @@ -0,0 +1,187 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(sameString(lstresponse[2],tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3f/40ce913acc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3f/40ce913acc2f001b1e93f29abc467978 new file mode 100644 index 0000000..1a25c81 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/3f/40ce913acc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= (lstresponse[2].compareTo("Mike")!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/43/70827ba3c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/43/70827ba3c72f001b1e93f29abc467978 new file mode 100644 index 0000000..5a0ea46 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/43/70827ba3c72f001b1e93f29abc467978 @@ -0,0 +1,53 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + try { + DatagramSocket dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/44/00b7170fc42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/44/00b7170fc42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..0095d27 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/44/00b7170fc42f001b1e3d9e6aa3539da2 @@ -0,0 +1,149 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + activeUsr1.threadInterrupt(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/45/90aa0325b72f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/45/90aa0325b72f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/46/f00a805ec32f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/46/f00a805ec32f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..e595c9b --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/46/f00a805ec32f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 14); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/4b/903ef0f7c22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/4b/903ef0f7c22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..417da3e --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/4b/903ef0f7c22f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=12459;//inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, itsPort); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/4b/a0d8b0e3c62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/4b/a0d8b0e3c62f001b1e93f29abc467978 new file mode 100644 index 0000000..8d2c8fc --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/4b/a0d8b0e3c62f001b1e93f29abc467978 @@ -0,0 +1,60 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (Exception e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/5/0017de3ba02d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/5/0017de3ba02d001b1caedccf60ced923 new file mode 100644 index 0000000..e63f8dd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/5/0017de3ba02d001b1caedccf60ced923 @@ -0,0 +1,119 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(not(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 2; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(1001,addIP); + byte[] buffer = new byte[256]; + + DatagramPacket outPacket1= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1001); + DatagramPacket outPacket2= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1002); + + dgramSocket.send(outPacket1); + dgramSocket.send(outPacket2); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + System.out.println(inPacket); + //valid = inPacket.toString().equals(tmpPseudo); + nbResponseMin--; + } + + dgramSocket.close(); + + + + + + Socket link = new Socket(addIP,2); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/5/8081d21aa12d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/5/8081d21aa12d001b1caedccf60ced923 new file mode 100644 index 0000000..49299a2 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/5/8081d21aa12d001b1caedccf60ced923 @@ -0,0 +1,119 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(not(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 2; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(1001,addIP); + byte[] buffer = new byte[256]; + + DatagramPacket outPacket1= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1001); + DatagramPacket outPacket2= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1002); + + dgramSocket.send(outPacket1); + dgramSocket.send(outPacket2); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + System.out.println(inPacket); + //valid = inPacket!=tmpPseudo; + nbResponseMin--; + } + + dgramSocket.close(); + + + + + + Socket link = new Socket(addIP,2); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/53/4099256ec62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/53/4099256ec62f001b1e93f29abc467978 new file mode 100644 index 0000000..e4b10e7 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/53/4099256ec62f001b1e93f29abc467978 @@ -0,0 +1,162 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.setSoTimeout() + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/53/c046f8a6bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/53/c046f8a6bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..03fed86 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/53/c046f8a6bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/55/50811256a12d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/55/50811256a12d001b1caedccf60ced923 new file mode 100644 index 0000000..b4c7038 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/55/50811256a12d001b1caedccf60ced923 @@ -0,0 +1,129 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String isPseudo = new String(buffer); + System.out.println(isPseudo); + valid = isPseudo!=tmpPseudo; + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/55/602eab9bc22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/55/602eab9bc22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1824d91 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/55/602eab9bc22f001b1e3d9e6aa3539da2 @@ -0,0 +1,148 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/56/306904c3be2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/56/306904c3be2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1fdf737 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/56/306904c3be2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/56/805386efc62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/56/805386efc62f001b1e93f29abc467978 new file mode 100644 index 0000000..18798cd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/56/805386efc62f001b1e93f29abc467978 @@ -0,0 +1,167 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + try{ + response = new String(buffer); + }catch (IOException e) { + e.printStackTrace(); + } + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/57/40b949bdba2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/57/40b949bdba2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..8afa4e4 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/57/40b949bdba2f001b1e3d9e6aa3539da2 @@ -0,0 +1,136 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String listPseudo = new String(buffer); + System.out.println(listPseudo); + String[] lstPseudo = listPseudo.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstPseudo)); + valid=stringList.contains(tmpPseudo); + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/60/e097411fc42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/60/e097411fc42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..edde3bf --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/60/e097411fc42f001b1e3d9e6aa3539da2 @@ -0,0 +1,57 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + while(this.myUser.haveToStopThread) { + + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12459); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/62/f0b1b920a02d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/62/f0b1b920a02d001b1caedccf60ced923 new file mode 100644 index 0000000..f8ac1b7 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/62/f0b1b920a02d001b1caedccf60ced923 @@ -0,0 +1,108 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(not(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) { + int nbResponseMin = 2; + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(1001,addIP); + byte[] buffer = new byte[256]; + + DatagramPacket outPacket1= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1001); + DatagramPacket outPacket2= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1002); + + dgramSocket.send(outPacket1); + dgramSocket.send(outPacket2); + + + + + + + + Socket link = new Socket(addIP,2); + + return + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/c0ad1fcdba2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/c0ad1fcdba2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..186f941 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/c0ad1fcdba2f001b1e3d9e6aa3539da2 @@ -0,0 +1,137 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this.nport,this.remoteUserList); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/e07c4da8c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/e07c4da8c72f001b1e93f29abc467978 new file mode 100644 index 0000000..e44a2bb --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/e07c4da8c72f001b1e93f29abc467978 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= null; + try { + dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/f04c8dcbc52f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/f04c8dcbc52f001b1e93f29abc467978 new file mode 100644 index 0000000..dcb2f10 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/63/f04c8dcbc52f001b1e93f29abc467978 @@ -0,0 +1,161 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/65/e01fa7a6c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/65/e01fa7a6c72f001b1e93f29abc467978 new file mode 100644 index 0000000..4215de2 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/65/e01fa7a6c72f001b1e93f29abc467978 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= null; + try { + DatagramSocket dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/66/908c07dac62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/66/908c07dac62f001b1e93f29abc467978 new file mode 100644 index 0000000..4d962b7 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/66/908c07dac62f001b1e93f29abc467978 @@ -0,0 +1,163 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/66/c0a3c9bbcc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/66/c0a3c9bbcc2f001b1e93f29abc467978 new file mode 100644 index 0000000..c13d6ba --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/66/c0a3c9bbcc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= (tmpPseudo.compareTo(lstresponse[2])!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/69/30de8c57c32f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/69/30de8c57c32f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..c0644dd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/69/30de8c57c32f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, itsPort); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/6b/307e0f77cc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/6b/307e0f77cc2f001b1e93f29abc467978 new file mode 100644 index 0000000..8b6d464 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/6b/307e0f77cc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= (tmpPseudo.compareTo("Mike")!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/6b/e02aee09bd2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/6b/e02aee09bd2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..fef3dfa --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/6b/e02aee09bd2f001b1e3d9e6aa3539da2 @@ -0,0 +1,137 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7c/a00fdbd7c62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7c/a00fdbd7c62f001b1e93f29abc467978 new file mode 100644 index 0000000..6478aac --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7c/a00fdbd7c62f001b1e93f29abc467978 @@ -0,0 +1,59 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (SocketTimeoutException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e0d02c25cc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e0d02c25cc2f001b1e93f29abc467978 new file mode 100644 index 0000000..c13d6ba --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e0d02c25cc2f001b1e93f29abc467978 @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= (tmpPseudo.compareTo(lstresponse[2])!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7f/f047b309c12f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7f/f047b309c12f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..8e21856 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/7f/f047b309c12f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,5002); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(5001); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/80/803d365bcb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/80/803d365bcb2f001b1e93f29abc467978 new file mode 100644 index 0000000..5a5077c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/80/803d365bcb2f001b1e93f29abc467978 @@ -0,0 +1,181 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu=true; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/81/00df846ec02f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/81/00df846ec02f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..303cdb6 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/81/00df846ec02f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/84/90beaf1bc42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/84/90beaf1bc42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..e58339a --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/84/90beaf1bc42f001b1e3d9e6aa3539da2 @@ -0,0 +1,150 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + activeUsr1.haveToStopThread=true; + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/88/1092d329cb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/88/1092d329cb2f001b1e93f29abc467978 new file mode 100644 index 0000000..dcd1063 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/88/1092d329cb2f001b1e93f29abc467978 @@ -0,0 +1,182 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("IP : "+lstresponse[0]); + + System.out.println("nPort : "+lstresponse[1]); + + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/88/c06e62f7c82f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/88/c06e62f7c82f001b1e93f29abc467978 new file mode 100644 index 0000000..b9baa3c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/88/c06e62f7c82f001b1e93f29abc467978 @@ -0,0 +1,168 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/8b/a01367bfbd2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/8b/a01367bfbd2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..b083b4c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/8b/a01367bfbd2f001b1e3d9e6aa3539da2 @@ -0,0 +1,37 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + try { + + }catch IOException{ + + } + InetAddress addIP = InetAddress.getLocalHost(); // change to broadcast + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String listPseudo = new String(buffer); + System.out.println(listPseudo); + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/8f/c0d77bf19e2d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/8f/c0d77bf19e2d001b1caedccf60ced923 new file mode 100644 index 0000000..80a7856 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/8f/c0d77bf19e2d001b1caedccf60ced923 @@ -0,0 +1,77 @@ +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + System.out.println(tmpPseudo); + + + this.pseudo = pseudo; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/91/c0f5233bc42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/91/c0f5233bc42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..3b59e18 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/91/c0f5233bc42f001b1e3d9e6aa3539da2 @@ -0,0 +1,150 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + activeUsr1.haveToStopThread=true; + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/99/f0bfb2b0b62f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/99/f0bfb2b0b62f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..398ffc3 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/99/f0bfb2b0b62f001b1e3d9e6aa3539da2 @@ -0,0 +1,136 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String listPseudo = new String(buffer); + System.out.println(listPseudo); + String[] lstPseudo = listPseudo.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstPseudo)); + valid=stringList.contains(tmpPseudo); + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9a/50159042bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9a/50159042bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..ca1320f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9a/50159042bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2050,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9b/d0a79069c62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9b/d0a79069c62f001b1e93f29abc467978 new file mode 100644 index 0000000..aae2e7f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9b/d0a79069c62f001b1e93f29abc467978 @@ -0,0 +1,161 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9d/00b932fbba2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9d/00b932fbba2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..39087ef --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/9d/00b932fbba2f001b1e3d9e6aa3539da2 @@ -0,0 +1,14 @@ + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User User) throws IOException{ + super(s); + + } + + public void run(){ + + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a/302fdd02b82f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a/302fdd02b82f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..4647312 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a/302fdd02b82f001b1e3d9e6aa3539da2 @@ -0,0 +1,4 @@ + +public class UserListeningThread { + +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a2/a0aabda3be2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a2/a0aabda3be2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1a6cd98 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a2/a0aabda3be2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (oldDate.getTime()-newDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a6/d06f4ffc9a2d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a6/d06f4ffc9a2d001b1caedccf60ced923 new file mode 100644 index 0000000..aac1769 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a6/d06f4ffc9a2d001b1caedccf60ced923 @@ -0,0 +1,73 @@ +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo(String pseudo) { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + + this.pseudo = pseudo; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e0b2f3379f2d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e0b2f3379f2d001b1caedccf60ced923 new file mode 100644 index 0000000..d4bef6a --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e0b2f3379f2d001b1caedccf60ced923 @@ -0,0 +1,100 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(not(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) { + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(1001,addIP); + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= newDatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 1001); + + + + + Socket link = new Socket(addIP,2); + + return + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ad/50a16611ca2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ad/50a16611ca2f001b1e93f29abc467978 new file mode 100644 index 0000000..aa3a952 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ad/50a16611ca2f001b1e93f29abc467978 @@ -0,0 +1,174 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="") { + System.out.println("Reponse non normalisé : "+response); + } + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + System.out.println(stringList); + valid=!(stringList.contains(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ae/d0a0c78aca2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ae/d0a0c78aca2f001b1e93f29abc467978 new file mode 100644 index 0000000..f96aef3 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ae/d0a0c78aca2f001b1e93f29abc467978 @@ -0,0 +1,178 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="") { + System.out.println("Reponse : "+response); + } + lstresponse = response.split(":"); + System.out.println(lstresponse[0]); + + System.out.println(lstresponse[1]); + + System.out.println(lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b/90629688c22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b/90629688c22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..afc416f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b/90629688c22f001b1e3d9e6aa3539da2 @@ -0,0 +1,147 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b0/e0e0e7f5c12f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b0/e0e0e7f5c12f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..fc75268 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b0/e0e0e7f5c12f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b2/f0a42f53cb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b2/f0a42f53cb2f001b1e93f29abc467978 new file mode 100644 index 0000000..ed67b9e --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b2/f0a42f53cb2f001b1e93f29abc467978 @@ -0,0 +1,181 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b7/4039fe85c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b7/4039fe85c72f001b1e93f29abc467978 new file mode 100644 index 0000000..5239219 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/b7/4039fe85c72f001b1e93f29abc467978 @@ -0,0 +1,50 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket=null; + + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bc/e02b2835c52f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bc/e02b2835c52f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..817a658 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bc/e02b2835c52f001b1e3d9e6aa3539da2 @@ -0,0 +1,161 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage :"+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bd/70d48685c92f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bd/70d48685c92f001b1e93f29abc467978 new file mode 100644 index 0000000..9fb7535 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bd/70d48685c92f001b1e93f29abc467978 @@ -0,0 +1,171 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="") { + System.out.println("Reponse non normalisé : "+response); + } + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + System.out.println(stringList); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bd/b016a5bbca2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bd/b016a5bbca2f001b1e93f29abc467978 new file mode 100644 index 0000000..f59af94 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/bd/b016a5bbca2f001b1e93f29abc467978 @@ -0,0 +1,178 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="\0") { + System.out.println("Reponse : "+response); + } + lstresponse = response.split(":"); + System.out.println(lstresponse[0]); + + System.out.println(lstresponse[1]); + + System.out.println(lstresponse[2]); + + System.out.println(tmpPseudo); + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/be/b0a80827bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/be/b0a80827bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1884d8c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/be/b0a80827bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6078c2a9c12f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6078c2a9c12f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..2623ee1 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6078c2a9c12f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(5001); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c1/3064b449bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c1/3064b449bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..cba805f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c1/3064b449bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + system.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2050,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/50a42b3aca2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/50a42b3aca2f001b1e93f29abc467978 new file mode 100644 index 0000000..5767e17 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/50a42b3aca2f001b1e93f29abc467978 @@ -0,0 +1,174 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="") { + System.out.println("Reponse non normalisé : "+response); + } + lstresponse = response.split(":"); + System.out.println(lstresponse); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80e5e345a12d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80e5e345a12d001b1caedccf60ced923 new file mode 100644 index 0000000..035e806 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/80e5e345a12d001b1caedccf60ced923 @@ -0,0 +1,129 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String isPseudo = new String(buffer); + System.out.println(isPseudo); + valid = isPseudo!=tmpPseudo; + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e0c5f01ccb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e0c5f01ccb2f001b1e93f29abc467978 new file mode 100644 index 0000000..3943997 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e0c5f01ccb2f001b1e93f29abc467978 @@ -0,0 +1,181 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + if(response!="\0") { + System.out.println("Reponse : "+response); + } + lstresponse = response.split(":"); + System.out.println(lstresponse[0]); + + System.out.println(lstresponse[1]); + + System.out.println(lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c5/004eb002a32d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c5/004eb002a32d001b1caedccf60ced923 new file mode 100644 index 0000000..7714bcd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c5/004eb002a32d001b1caedccf60ced923 @@ -0,0 +1,131 @@ +import java.io.IOException; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] userList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String isPseudo = new String(buffer); + System.out.println(isPseudo); + valid = isPseudo!=tmpPseudo; + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b07b5b04c12f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b07b5b04c12f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..2623ee1 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b07b5b04c12f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(5001); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c6/f007d173bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c6/f007d173bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..1785b35 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c6/f007d173bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5001,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c8/6035fd42c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c8/6035fd42c72f001b1e93f29abc467978 new file mode 100644 index 0000000..7415dfd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c8/6035fd42c72f001b1e93f29abc467978 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c9/90b350f2c52f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c9/90b350f2c52f001b1e93f29abc467978 new file mode 100644 index 0000000..0a81593 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/c9/90b350f2c52f001b1e93f29abc467978 @@ -0,0 +1,57 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + while(!this.myUser.haveToStopThread) { + + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ca/f099b9c5c52f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ca/f099b9c5c52f001b1e93f29abc467978 new file mode 100644 index 0000000..f9faf12 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ca/f099b9c5c52f001b1e93f29abc467978 @@ -0,0 +1,161 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ce/90124903c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ce/90124903c72f001b1e93f29abc467978 new file mode 100644 index 0000000..6a8186e --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ce/90124903c72f001b1e93f29abc467978 @@ -0,0 +1,167 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + try{ + response = new String(buffer); + }catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/cf/50c9842dc22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/cf/50c9842dc22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..79711ee --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/cf/50c9842dc22f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=5001;//inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, itsPort); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d1/6015966dc42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d1/6015966dc42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..f37c502 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d1/6015966dc42f001b1e3d9e6aa3539da2 @@ -0,0 +1,150 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + activeUsr1.haveToStopThread=true; + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d2/20dc59c6c62f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d2/20dc59c6c62f001b1e93f29abc467978 new file mode 100644 index 0000000..def7550 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d2/20dc59c6c62f001b1e93f29abc467978 @@ -0,0 +1,59 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d6/80013596be2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d6/80013596be2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..e68e765 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d6/80013596be2f001b1e3d9e6aa3539da2 @@ -0,0 +1,44 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + String listPseudo = new String(buffer); + System.out.println(listPseudo); + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d8/30a1b32cc32f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d8/30a1b32cc32f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..ed5df23 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/d8/30a1b32cc32f001b1e3d9e6aa3539da2 @@ -0,0 +1,147 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12459); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/da/a0207944bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/da/a0207944bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..677b18f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/da/a0207944bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + system.out.println("Fin") + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2050,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/db/e0a174b5c32f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/db/e0a174b5c32f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..0a75992 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/db/e0a174b5c32f001b1e3d9e6aa3539da2 @@ -0,0 +1,147 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/df/200320f1c22f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/df/200320f1c22f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..25ffcc2 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/df/200320f1c22f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=12458;//inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, itsPort); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e006f555a42d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e006f555a42d001b1caedccf60ced923 new file mode 100644 index 0000000..ab0150e --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e006f555a42d001b1caedccf60ced923 @@ -0,0 +1,136 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String listPseudo = new String(buffer); + System.out.println(listPseudo); + String[] lstPseudo = listPseudo.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstPseudo)); + valid=stringList.contains(tmpPseudo); + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e3/c0fd5305c72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e3/c0fd5305c72f001b1e93f29abc467978 new file mode 100644 index 0000000..640e82b --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e3/c0fd5305c72f001b1e93f29abc467978 @@ -0,0 +1,168 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse; + ArrayList stringList; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + + response = new String(buffer); + System.out.println("Passage : "+response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e5/f07ce4eec02f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e5/f07ce4eec02f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..c0644dd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e5/f07ce4eec02f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, itsPort); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e6/d00cf14aa42d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e6/d00cf14aa42d001b1caedccf60ced923 new file mode 100644 index 0000000..5949a2b --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e6/d00cf14aa42d001b1caedccf60ced923 @@ -0,0 +1,134 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + Boolean valid = true; + int nbResponseMin = 1; + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + while(nbResponseMin > 0 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String listPseudo = new String(buffer); + System.out.println(listPseudo); + String[] lstPseudo = listPseudo.split(":"); + lstPseudo.contains(tmpPseudo); + valid = isPseudo!=tmpPseudo; + nbResponseMin--; + } + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User activeUsr1 = new User(2001,"Mike"); + User activeUsr2 = new User(2002,"Sue"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e7/10ea35febe2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e7/10ea35febe2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..f0ff18b --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e7/10ea35febe2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(2001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2001,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e8/0059b8cfc52f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e8/0059b8cfc52f001b1e93f29abc467978 new file mode 100644 index 0000000..727ed64 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e8/0059b8cfc52f001b1e93f29abc467978 @@ -0,0 +1,57 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket = null; + + while(!this.myUser.haveToStopThread) { + + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12459); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e8/a0783574cb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e8/a0783574cb2f001b1e93f29abc467978 new file mode 100644 index 0000000..d3f880d --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e8/a0783574cb2f001b1e93f29abc467978 @@ -0,0 +1,181 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu=true; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e9/40b2ea2bcb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e9/40b2ea2bcb2f001b1e93f29abc467978 new file mode 100644 index 0000000..91f4963 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/e9/40b2ea2bcb2f001b1e93f29abc467978 @@ -0,0 +1,181 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + + } + buffer = inPacket.getData(); + response = new String(buffer); + + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser") + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + newDate = new Date(); + buffer = new byte[256]; + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ea/d0c8566dcc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ea/d0c8566dcc2f001b1e93f29abc467978 new file mode 100644 index 0000000..ae3e83b --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ea/d0c8566dcc2f001b1e93f29abc467978 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= null; + try { + dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/eb/f0211c27c52f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/eb/f0211c27c52f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..56882dd --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/eb/f0211c27c52f001b1e3d9e6aa3539da2 @@ -0,0 +1,156 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ec/704158189b2d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ec/704158189b2d001b1caedccf60ced923 new file mode 100644 index 0000000..c3da475 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ec/704158189b2d001b1caedccf60ced923 @@ -0,0 +1,75 @@ +import java.net.*; +import java.util.Scanner; // Import the Scanner class + +public class User { + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + public User(int nport){ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + this.actif = true; + + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo"); + String tmpPseudo = myObj.nextLine(); // Read user input + + this.pseudo = pseudo; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) { + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ec/b059099acc2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ec/b059099acc2f001b1e93f29abc467978 new file mode 100644 index 0000000..cd098ad --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ec/b059099acc2f001b1e93f29abc467978 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= null; + try { + dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo()+":"; + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ed/9037a5e9982d001b1caedccf60ced923 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ed/9037a5e9982d001b1caedccf60ced923 new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ed/9037a5e9982d001b1caedccf60ced923 @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f/309cb032c52f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f/309cb032c52f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..afbc8b9 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f/309cb032c52f001b1e3d9e6aa3539da2 @@ -0,0 +1,161 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12458); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response; + String[] lstresponse; + ArrayList stringList; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + response = new String(buffer); + System.out.println(response); + lstresponse = response.split(":"); + stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=!(stringList.contains(tmpPseudo)); + newDate = new Date(); + } + System.out.println("Pseudo valide"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12458,"Mike"); + + User usr1 = new User(12459); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f/504142a9c02f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f/504142a9c02f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..fa799be --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f/504142a9c02f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f0/b0b94a13c12f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f0/b0b94a13c12f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..2f794d8 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f0/b0b94a13c12f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5002,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5002,"Mike"); + + User usr1 = new User(5001); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f1/d04d998ec02f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f1/d04d998ec02f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..b539f42 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f1/d04d998ec02f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 5002); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + System.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(2000,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f97754bf2f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f97754bf2f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..7f8e70e --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f97754bf2f001b1e3d9e6aa3539da2 @@ -0,0 +1,146 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + + public User(int nport) throws IOException{ + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(5001,addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 2001); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + System.out.println("Wait for pseudo validation ..."); + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + dgramSocket.receive(inPacket); + buffer = inPacket.getData(); + String response = new String(buffer); + System.out.println(response); + String[] lstresponse = response.split(":"); + ArrayList stringList = new ArrayList(Arrays.asList(lstresponse)); + valid=stringList.contains(tmpPseudo); + newDate = new Date(); + } + system.out.println("Fin"); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(5001,"Mike"); + + User usr1 = new User(3); + usr1.setPseudo(); + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/fc/c0d3c49ac72f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/fc/c0d3c49ac72f001b1e93f29abc467978 new file mode 100644 index 0000000..e58614a --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/fc/c0d3c49ac72f001b1e93f29abc467978 @@ -0,0 +1,50 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.addIP);; + + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/fe/e0df85b8cb2f001b1e93f29abc467978 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/fe/e0df85b8cb2f001b1e93f29abc467978 new file mode 100644 index 0000000..1ed1785 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/fe/e0df85b8cb2f001b1e93f29abc467978 @@ -0,0 +1,187 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [3]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + System.out.println(tmpPseudo==lstresponse[2]); + + valid=!(lstresponse[2].equals(tmpPseudo)); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ff/80d51617c42f001b1e3d9e6aa3539da2 b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ff/80d51617c42f001b1e3d9e6aa3539da2 new file mode 100644 index 0000000..78efd3a --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.history/ff/80d51617c42f001b1e3d9e6aa3539da2 @@ -0,0 +1,54 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + while(true) { + + DatagramSocket dgramSocket = null; + try { + dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP()); + } catch (SocketException e) { + e.printStackTrace(); + } + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (IOException e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo(); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12459); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } +} + + + diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.indexes/af/history.index b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.indexes/af/history.index new file mode 100644 index 0000000..9b5e678 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.indexes/af/history.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.indexes/e4/history.index b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.indexes/e4/history.index new file mode 100644 index 0000000..b01b32f Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.indexes/e4/history.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.markers b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.markers new file mode 100644 index 0000000..30b9afa Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.markers differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.markers.snap b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.markers.snap new file mode 100644 index 0000000..91d6c54 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.markers.snap differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.syncinfo.snap b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.syncinfo.snap new file mode 100644 index 0000000..91d6c54 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/.syncinfo.snap differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/org.eclipse.jdt.core/state.dat b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..005d326 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/Clavardage/org.eclipse.jdt.core/state.dat differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap new file mode 100644 index 0000000..91d6c54 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap new file mode 100644 index 0000000..91d6c54 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000..25cb955 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000..6cfd72d Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap new file mode 100644 index 0000000..91d6c54 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree new file mode 100644 index 0000000..016b25b Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/Application/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000..56b6b06 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.resources/2.snap b/Application/.metadata/.plugins/org.eclipse.core.resources/2.snap new file mode 100644 index 0000000..da34768 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.core.resources/2.snap differ diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..dffc6b5 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +version=1 diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs new file mode 100644 index 0000000..9dd00d6 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n +preferredTargets=default\:default| diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.logging.aeri.ide.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.logging.aeri.ide.prefs new file mode 100644 index 0000000..c186df8 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.logging.aeri.ide.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +resetSendMode=KEEP +resetSendModeOn=0 +sendMode=NOTIFY diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..c24a64f --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs new file mode 100644 index 0000000..31df02c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=true diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000..fb7ea05 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_VM_XML=\r\n\r\n\r\n\r\n\r\n\r\n diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..4563969 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,16 @@ +content_assist_disabled_computers=org.eclipse.jdt.ui.textProposalCategory\u0000org.eclipse.recommenders.calls.rcp.proposalCategory.templates\u0000org.eclipse.mylyn.java.ui.javaAllProposalCategory\u0000org.eclipse.jdt.ui.javaAllProposalCategory\u0000org.eclipse.jdt.ui.javaTypeProposalCategory\u0000org.eclipse.jdt.ui.javaNoTypeProposalCategory\u0000org.eclipse.recommenders.chain.rcp.proposalCategory.chain\u0000 +content_assist_lru_history= +content_assist_number_of_computers=24 +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 +eclipse.preferences.version=1 +org.eclipse.jdt.internal.ui.navigator.layout=2 +org.eclipse.jdt.internal.ui.navigator.librariesnode=true +org.eclipse.jdt.ui.formatterprofiles.version=13 +org.eclipse.jdt.ui.text.code_templates_migrated=true +org.eclipse.jdt.ui.text.custom_code_templates= +org.eclipse.jdt.ui.text.custom_templates= +org.eclipse.jdt.ui.text.templates_migrated=true +spelling_locale_initialized=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.j2ee.webservice.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.j2ee.webservice.ui.prefs new file mode 100644 index 0000000..553bb96 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.j2ee.webservice.ui.prefs @@ -0,0 +1,2 @@ +areThereWebServices=false +eclipse.preferences.version=1 diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs new file mode 100644 index 0000000..67b1d96 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 0000000..43e97e4 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs new file mode 100644 index 0000000..2a6fe50 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.java.ui.run.count.3_10_0=1 +org.eclipse.mylyn.java.ui.run.count.3_1_0=1 diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 0000000..8d462a6 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000..2b60c21 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +migrated.task.repositories.secure.store=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true +org.eclipse.mylyn.tasks.ui.welcome.message=true diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.pde.api.tools.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000..d2ed603 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +knownEEFragments= diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.recommenders.completion.rcp.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.recommenders.completion.rcp.prefs new file mode 100644 index 0000000..b9bd711 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.recommenders.completion.rcp.prefs @@ -0,0 +1,2 @@ +completion_tips_seen=org.eclipse.recommenders.completion.rcp.tips.discovery\:org.eclipse.recommenders.completion.rcp.tips.types +eclipse.preferences.version=1 diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs new file mode 100644 index 0000000..46b2b7e --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs @@ -0,0 +1,4 @@ +activeuserprofiles=DESKTOP-TG533B7;Team +eclipse.preferences.version=1 +org.eclipse.rse.systemtype.local.systemType.defaultUserId=Alexandre +useridperkey=DESKTOP-TG533B7.Local\=Alexandre; diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs new file mode 100644 index 0000000..336004d --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.rse.preferences.order.connections=DESKTOP-TG533B7.Local diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs new file mode 100644 index 0000000..56cd496 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.team.ui.first_time=false diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs new file mode 100644 index 0000000..61f3bb8 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +overviewRuler_migration=migrated_3.1 diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs new file mode 100644 index 0000000..b63dbb0 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,5 @@ +PROBLEMS_FILTERS_MIGRATE=true +eclipse.preferences.version=1 +platformState=1547826617293 +quickStart=false +tipsAndTricks=true diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs new file mode 100644 index 0000000..08076f2 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +showIntro=false diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs new file mode 100644 index 0000000..03c90db --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,24 @@ +//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false +//org.eclipse.ui.commands/state/org.eclipse.wst.xml.views.XPathView.processor.xpathprocessor/org.eclipse.ui.commands.radioState=xpath10 +PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; +REMOTE_COMMANDS_VIEW_FONT=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +eclipse.preferences.version=1 +org.eclipse.compare.contentmergeviewer.TextMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.debug.ui.DetailPaneFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.debug.ui.MemoryViewTableFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.debug.ui.consoleFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.egit.ui.CommitMessageEditorFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.egit.ui.CommitMessageFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.egit.ui.DiffHeadlineFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.jdt.internal.ui.compare.JavaMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.jdt.internal.ui.compare.PropertiesFileMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.jdt.ui.PropertiesFileEditor.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.jdt.ui.editors.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.jface.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.mylyn.wikitext.ui.presentation.textFont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.pde.internal.ui.compare.ManifestContentMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.pde.internal.ui.compare.PluginContentMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.wst.jsdt.internal.ui.compare.JavaMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.wst.jsdt.ui.editors.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.wst.sse.ui.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +terminal.views.view.font.definition=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; diff --git a/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs new file mode 100644 index 0000000..15efa49 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +fontPropagated=true +org.eclipse.jface.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +org.eclipse.wst.jsdt.ui.editor.tab.width= +org.eclipse.wst.jsdt.ui.formatterprofiles.version=11 +org.eclipse.wst.jsdt.ui.javadoclocations.migrated=true +proposalOrderMigrated=true +tabWidthPropagated=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/Application/.metadata/.plugins/org.eclipse.debug.core/.launches/User.launch b/Application/.metadata/.plugins/org.eclipse.debug.core/.launches/User.launch new file mode 100644 index 0000000..3e1ff45 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.debug.core/.launches/User.launch @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/Application/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml new file mode 100644 index 0000000..364579b --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml @@ -0,0 +1,8 @@ + +
+
+ + + +
+
diff --git a/Application/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/Application/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml new file mode 100644 index 0000000..d499601 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/Application/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000..16a3ffe --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,3251 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.rse.core.search.searchActionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.wst.jsdt.chromium.debug.ui.actionSets + persp.actionSet:org.eclipse.jst.j2ee.J2eeMainActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.debug.ui.debugActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.wst.server.ui.ServersView + persp.viewSC:org.eclipse.datatools.connectivity.DataSourceExplorerNavigator + persp.viewSC:org.eclipse.ui.views.BookmarkView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.PropertySheet + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.wst.common.snippets.internal.ui.SnippetsView + persp.viewSC:org.eclipse.ui.views.AllMarkersView + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.wst.ws.explorer.explorer + persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard + persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.perspSC:org.eclipse.jdt.ui.JavaPerspective + persp.perspSC:org.eclipse.ui.resourcePerspective + persp.perspSC:org.eclipse.wst.web.ui.webDevPerspective + persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard + persp.newWizSC:org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.project.facet.EjbProjectWizard + persp.newWizSC:org.eclipse.jst.j2ee.jca.ui.internal.wizard.ConnectorProjectWizard + persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard + persp.newWizSC:org.eclipse.wst.web.ui.internal.wizards.SimpleWebProjectWizard + persp.newWizSC:org.eclipse.jpt.ui.wizard.newJpaProject + persp.newWizSC:org.eclipse.jst.servlet.ui.internal.wizard.AddServletWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddSessionBeanWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddMessageDrivenBeanWizard + persp.newWizSC:org.eclipse.jpt.ui.wizard.newEntity + persp.newWizSC:org.eclipse.jst.ws.creation.ui.wizard.serverwizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.actionSet:org.eclipse.wst.server.ui.internal.webbrowser.actionSet + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.newWizSC:org.eclipse.jpt.jpa.ui.wizard.newJpaProject + persp.perspSC:org.eclipse.jpt.ui.jpaPerspective + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.rse.core.search.searchActionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.wst.jsdt.chromium.debug.ui.actionSets + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.views.ResourceNavigator + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.perspSC:org.eclipse.wst.jsdt.ui.JavaPerspective + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.viewSC:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + Minimized + + + + + + + + + + + + + + + active + + + Editor + org.eclipse.jdt.ui.CompilationUnitEditor + removeOnHide + + menuContribution:popup + popup:#CompilationUnitEditorContext + popup:org.eclipse.jdt.ui.CompilationUnitEditor.EditorContext + popup:#AbstractTextEditorContext + + + menuContribution:popup + popup:#CompilationUnitRulerContext + popup:org.eclipse.jdt.ui.CompilationUnitEditor.RulerContext + popup:#AbstractTextEditorRulerContext + + + menuContribution:popup + popup:#OverviewRulerContext + + + + + Editor + org.eclipse.jdt.ui.CompilationUnitEditor + removeOnHide + active + activeOnClose + + menuContribution:popup + popup:#CompilationUnitEditorContext + popup:org.eclipse.jdt.ui.CompilationUnitEditor.EditorContext + popup:#AbstractTextEditorContext + + + menuContribution:popup + popup:#CompilationUnitRulerContext + popup:org.eclipse.jdt.ui.CompilationUnitEditor.RulerContext + popup:#AbstractTextEditorRulerContext + + + menuContribution:popup + popup:#OverviewRulerContext + + + + + org.eclipse.e4.secondaryDataStack + + + + + + + + + + + + + + + Minimized + + + + org.eclipse.e4.secondaryNavigationStack + Minimized + + + + + + + + + + + + + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:Server + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + menuContribution:popup + popup:org.eclipse.ui.views.ProblemView + popup:org.eclipse.ui.ide.MarkersView + + + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + menuContribution:popup + popup:org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu + + + menuContribution:popup + popup:org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + menuContribution:popup + popup:org.eclipse.jdt.ui.PackageExplorer + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Git + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + TrimStack + Draggable + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:JPA + + + + + View + categoryTag:JPA + + + + + View + categoryTag:JavaServer Faces + + + + + View + categoryTag:JavaServer Faces + + + + + View + categoryTag:Web Services + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:API Tools + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Code Recommenders + + + + + View + categoryTag:Code Recommenders + + + + + View + categoryTag:Code Recommenders + + + + + View + categoryTag:Code Recommenders + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:Remote Systems + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Team + + + + + View + categoryTag:Team + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Other + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Debug + + + + + View + categoryTag:JavaScript + + + + + View + categoryTag:JavaScript + + + + + View + categoryTag:JavaScript + + + + + View + categoryTag:JavaScript + + + + + View + categoryTag:JavaScript + + + + + View + categoryTag:Server + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/1188785453.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/1188785453.index new file mode 100644 index 0000000..7485970 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/1188785453.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/1794327708.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/1794327708.index new file mode 100644 index 0000000..ce9a98d Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/1794327708.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/1878111493.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/1878111493.index new file mode 100644 index 0000000..8b73a0c Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/1878111493.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/1897928139.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/1897928139.index new file mode 100644 index 0000000..7f873de Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/1897928139.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/2953298812.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/2953298812.index new file mode 100644 index 0000000..98c0932 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/2953298812.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3079686767.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3079686767.index new file mode 100644 index 0000000..9add4c7 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3079686767.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3431489974.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3431489974.index new file mode 100644 index 0000000..13fdca0 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3431489974.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3498974549.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3498974549.index new file mode 100644 index 0000000..7e0dd4e Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3498974549.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3517127072.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3517127072.index new file mode 100644 index 0000000..c9ac66a Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3517127072.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3698278747.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3698278747.index new file mode 100644 index 0000000..0471a7c Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3698278747.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3705452257.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3705452257.index new file mode 100644 index 0000000..7231c41 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3705452257.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/3861206012.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/3861206012.index new file mode 100644 index 0000000..d8e60b8 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/3861206012.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/4019172236.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/4019172236.index new file mode 100644 index 0000000..d482660 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/4019172236.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/402782763.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/402782763.index new file mode 100644 index 0000000..911d26b Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/402782763.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/434535315.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/434535315.index new file mode 100644 index 0000000..7cb03ab Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/434535315.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/58444662.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/58444662.index new file mode 100644 index 0000000..3191fe3 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/58444662.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/899518542.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/899518542.index new file mode 100644 index 0000000..68dd6e0 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/899518542.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/904289187.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/904289187.index new file mode 100644 index 0000000..bdfb2f5 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/904289187.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/972666350.index b/Application/.metadata/.plugins/org.eclipse.jdt.core/972666350.index new file mode 100644 index 0000000..23573ff Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/972666350.index differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/Application/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/Application/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000..b573b24 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps b/Application/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps new file mode 100644 index 0000000..a2b90ad Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/index.db b/Application/.metadata/.plugins/org.eclipse.jdt.core/index.db new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/Application/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 0000000..8586397 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/Application/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000..b573b24 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt b/Application/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt new file mode 100644 index 0000000..29c09d6 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt @@ -0,0 +1,20 @@ +INDEX VERSION 1.130+C:\Users\Alexandre\Downloads\src-20201006T193227Z-001\.metadata\.plugins\org.eclipse.jdt.core +3861206012.index +3517127072.index +972666350.index +58444662.index +434535315.index +4019172236.index +3431489974.index +904289187.index +899518542.index +1188785453.index +3079686767.index +402782763.index +3705452257.index +1897928139.index +3498974549.index +2953298812.index +1878111493.index +1794327708.index +3698278747.index diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/Application/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..3a4bba2 Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/Application/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 0000000..f32c6f2 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,4 @@ + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml b/Application/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml new file mode 100644 index 0000000..e115bb1 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/Application/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/Application/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..5ec2a5a --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/Application/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000..6514186 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,40 @@ + +
+
+ + + + + +
+
+ + + + +
+
+ + +
+
+ +
+
+
+
+
+
+ + + + + +
+
+ + +
+
+
+
diff --git a/Application/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/Application/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 0000000..3fb7f74 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1,63 @@ +2020-11-23 15:31:12,367 [Worker-3] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2020-11-23 15:36:20,575 [Worker-8] WARN o.e.r.models.ModelRepository - Failed to download org.eclipse.recommenders:index::zip:0.0.0 +org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) ~[na:na] + at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) [org.eclipse.recommenders.models_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) [org.eclipse.recommenders.models_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) [org.eclipse.recommenders.models.rcp_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) [org.eclipse.recommenders.models.rcp_2.5.2.v20180401-1226.jar:na] + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) [org.eclipse.core.jobs_3.9.3.v20180115-1757.jar:na] +Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:76) ~[na:na] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:590) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:258) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:529) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) ~[na:na] + ... 8 common frames omitted +2020-11-26 08:08:01,556 [Worker-4] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2020-11-26 08:21:09,778 [Worker-15] WARN o.e.r.models.ModelRepository - Failed to download org.eclipse.recommenders:index::zip:0.0.0 +org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) ~[na:na] + at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) [org.eclipse.recommenders.models_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) [org.eclipse.recommenders.models_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) [org.eclipse.recommenders.models.rcp_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) [org.eclipse.recommenders.models.rcp_2.5.2.v20180401-1226.jar:na] + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) [org.eclipse.core.jobs_3.9.3.v20180115-1757.jar:na] +Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:76) ~[na:na] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:590) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:258) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:529) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) ~[na:na] + ... 8 common frames omitted +2020-11-26 09:57:07,820 [Worker-0] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. +2020-11-26 10:04:24,996 [Worker-20] WARN o.e.r.models.ModelRepository - Failed to download org.eclipse.recommenders:index::zip:0.0.0 +org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) ~[na:na] + at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) [org.eclipse.recommenders.models_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) [org.eclipse.recommenders.models_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) [org.eclipse.recommenders.models.rcp_2.5.2.v20180401-1226.jar:na] + at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) [org.eclipse.recommenders.models.rcp_2.5.2.v20180401-1226.jar:na] + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) [org.eclipse.core.jobs_3.9.3.v20180115-1757.jar:na] +Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.eclipse.recommenders:index:zip:0.0.0-SNAPSHOT in models (http://download.eclipse.org/recommenders/models/oxygen/) + at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:76) ~[na:na] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:590) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:258) ~[org.apache.maven.resolver.connector.basic_1.0.3.v20170405-0725.jar:1.0.3] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:529) ~[na:na] + at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) ~[na:na] + ... 8 common frames omitted diff --git a/Application/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.8.3.20180227-2137.xml b/Application/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.8.3.20180227-2137.xml new file mode 100644 index 0000000..e33758c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.8.3.20180227-2137.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/Application/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/Application/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 0000000..1f73e14 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/Application/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties b/Application/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties new file mode 100644 index 0000000..4c6a028 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties @@ -0,0 +1,2 @@ +#Cached timestamps +#Thu Nov 26 11:26:26 CET 2020 diff --git a/Application/.metadata/.plugins/org.eclipse.rse.core/.log b/Application/.metadata/.plugins/org.eclipse.rse.core/.log new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark b/Application/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/FP.local.files_0/node.properties b/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/FP.local.files_0/node.properties new file mode 100644 index 0000000..3095597 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/FP.local.files_0/node.properties @@ -0,0 +1,57 @@ +# RSE DOM Node +00-name=DESKTOP-TG533B7\:local.files +01-type=FilterPool +03-attr.default=true +03-attr.deletable=true +03-attr.id=local.files +03-attr.nonRenamable=false +03-attr.owningParentName=null +03-attr.release=200 +03-attr.singleFilterStringOnly=false +03-attr.singleFilterStringOnlyESet=false +03-attr.stringsCaseSensitive=true +03-attr.supportsDuplicateFilterStrings=false +03-attr.supportsNestedFilters=true +03-attr.type=default +06-child.00000.00-name=My Home +06-child.00000.01-type=Filter +06-child.00000.03-attr.default=false +06-child.00000.03-attr.filterType=default +06-child.00000.03-attr.id=My Home +06-child.00000.03-attr.nonChangable=false +06-child.00000.03-attr.nonDeletable=false +06-child.00000.03-attr.nonRenamable=false +06-child.00000.03-attr.promptable=false +06-child.00000.03-attr.relativeOrder=0 +06-child.00000.03-attr.release=200 +06-child.00000.03-attr.singleFilterStringOnly=false +06-child.00000.03-attr.stringsCaseSensitive=false +06-child.00000.03-attr.stringsNonChangable=false +06-child.00000.03-attr.supportsDuplicateFilterStrings=false +06-child.00000.03-attr.supportsNestedFilters=true +06-child.00000.06-child.00000.00-name=C\:\\Users\\Alexandre\\* +06-child.00000.06-child.00000.01-type=FilterString +06-child.00000.06-child.00000.03-attr.default=false +06-child.00000.06-child.00000.03-attr.string=C\:\\Users\\Alexandre\\* +06-child.00000.06-child.00000.03-attr.type=default +06-child.00001.00-name=Drives +06-child.00001.01-type=Filter +06-child.00001.03-attr.default=false +06-child.00001.03-attr.filterType=default +06-child.00001.03-attr.id=Drives +06-child.00001.03-attr.nonChangable=false +06-child.00001.03-attr.nonDeletable=false +06-child.00001.03-attr.nonRenamable=false +06-child.00001.03-attr.promptable=false +06-child.00001.03-attr.relativeOrder=0 +06-child.00001.03-attr.release=200 +06-child.00001.03-attr.singleFilterStringOnly=false +06-child.00001.03-attr.stringsCaseSensitive=false +06-child.00001.03-attr.stringsNonChangable=false +06-child.00001.03-attr.supportsDuplicateFilterStrings=false +06-child.00001.03-attr.supportsNestedFilters=true +06-child.00001.06-child.00000.00-name=* +06-child.00001.06-child.00000.01-type=FilterString +06-child.00001.06-child.00000.03-attr.default=false +06-child.00001.06-child.00000.03-attr.string=* +06-child.00001.06-child.00000.03-attr.type=default diff --git a/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/H.local_16/node.properties b/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/H.local_16/node.properties new file mode 100644 index 0000000..9b35943 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/H.local_16/node.properties @@ -0,0 +1,25 @@ +# RSE DOM Node +00-name=Local +01-type=Host +03-attr.description= +03-attr.hostname=LOCALHOST +03-attr.offline=false +03-attr.promptable=false +03-attr.systemType=org.eclipse.rse.systemtype.local +03-attr.type=Local +06-child.00000.00-name=Local Connector Service +06-child.00000.01-type=ConnectorService +06-child.00000.03-attr.group=Local Connector Service +06-child.00000.03-attr.port=0 +06-child.00000.03-attr.useSSL=false +06-child.00000.06-child.00000.00-name=Local Files +06-child.00000.06-child.00000.01-type=SubSystem +06-child.00000.06-child.00000.03-attr.hidden=false +06-child.00000.06-child.00000.03-attr.type=local.files +06-child.00000.06-child.00000.06-child.00000.00-name=DESKTOP-TG533B7___DESKTOP-TG533B7\:local.files +06-child.00000.06-child.00000.06-child.00000.01-type=FilterPoolReference +06-child.00000.06-child.00000.06-child.00000.03-attr.refID=local.files +06-child.00000.06-child.00001.00-name=Local Shells +06-child.00000.06-child.00001.01-type=SubSystem +06-child.00000.06-child.00001.03-attr.hidden=false +06-child.00000.06-child.00001.03-attr.type=local.shells diff --git a/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/node.properties b/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/node.properties new file mode 100644 index 0000000..2365076 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-tg533b7_32610/node.properties @@ -0,0 +1,7 @@ +# RSE DOM Node +00-name=DESKTOP-TG533B7 +01-type=Profile +03-attr.defaultPrivate=true +03-attr.isActive=true +05-ref.00000=FP.local.files_0 +05-ref.00001=H.local_16 diff --git a/Application/.metadata/.plugins/org.eclipse.rse.ui/.log b/Application/.metadata/.plugins/org.eclipse.rse.ui/.log new file mode 100644 index 0000000..e69de29 diff --git a/Application/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties b/Application/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties new file mode 100644 index 0000000..b1a9e96 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties @@ -0,0 +1,6 @@ +#Mon Nov 23 15:31:00 CET 2020 +0.Path=C\:\\Program Files\\Git\\bin\\sh.exe +0.Name=Git Bash +0.Args=--login -i +0.Translate=true +0.Icon=C\:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico diff --git a/Application/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/Application/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 0000000..db31459 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+
+ + + +
+
+ + +
+
diff --git a/Application/.metadata/.plugins/org.eclipse.ui.intro/introstate b/Application/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 0000000..236d56c --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/Application/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 0000000..851c296 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,15 @@ + +
+
+ + + + + + + + + + +
+
diff --git a/Application/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/Application/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 0000000..f6a9848 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Application/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat b/Application/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..3f8e74c Binary files /dev/null and b/Application/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat differ diff --git a/Application/.metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml b/Application/.metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/Application/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml b/Application/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..9e390f5 --- /dev/null +++ b/Application/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/Application/.metadata/version.ini b/Application/.metadata/version.ini new file mode 100644 index 0000000..af7bbe1 --- /dev/null +++ b/Application/.metadata/version.ini @@ -0,0 +1,3 @@ +#Thu Nov 26 09:56:59 CET 2020 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.7.3.v20180330-0640 diff --git a/Application/.recommenders/caches/identified-project-coordinates.json b/Application/.recommenders/caches/identified-project-coordinates.json new file mode 100644 index 0000000..7a1573e --- /dev/null +++ b/Application/.recommenders/caches/identified-project-coordinates.json @@ -0,0 +1 @@ +[[{"location":"C:\\Program Files\\Java\\jre1.8.0_201","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"]] \ No newline at end of file diff --git a/Application/.recommenders/caches/manual-mappings.json b/Application/.recommenders/caches/manual-mappings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/Application/.recommenders/caches/manual-mappings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/Application/Clavardage/.classpath b/Application/Clavardage/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Application/Clavardage/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Application/Clavardage/.project b/Application/Clavardage/.project new file mode 100644 index 0000000..7ee0ed5 --- /dev/null +++ b/Application/Clavardage/.project @@ -0,0 +1,17 @@ + + + Clavardage + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Application/Clavardage/.settings/org.eclipse.jdt.core.prefs b/Application/Clavardage/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Application/Clavardage/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Application/Clavardage/bin/User.class b/Application/Clavardage/bin/User.class new file mode 100644 index 0000000..f74a1c2 Binary files /dev/null and b/Application/Clavardage/bin/User.class differ diff --git a/Application/Clavardage/bin/UserListeningThread.class b/Application/Clavardage/bin/UserListeningThread.class new file mode 100644 index 0000000..1416ea4 Binary files /dev/null and b/Application/Clavardage/bin/UserListeningThread.class differ diff --git a/Application/Clavardage/src/User.java b/Application/Clavardage/src/User.java new file mode 100644 index 0000000..3a8f7bb --- /dev/null +++ b/Application/Clavardage/src/User.java @@ -0,0 +1,193 @@ +import java.awt.List; +import java.io.IOException; +import java.net.*; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Scanner; // Import the Scanner class + +public class User{ + + protected InetAddress addIP; + protected String pseudo; + protected int nport; + protected boolean actif; + + protected User[] remoteUserList; + public Boolean haveToStopThread=false; + + public User(int nport) throws IOException{ + //localUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + + this.nport = nport; + + this.setPseudo(); + + this.actif = true; + + } + + public User(int nport,String pseudo) { + //remoteUser + try + { + this.addIP = InetAddress.getLocalHost(); + } + catch(UnknownHostException e) { + System.out.println("Could not find local address!"); + } + this.pseudo = pseudo; + this.nport = nport; + this.actif = true; + UserListeningThread th = new UserListeningThread("UDP Listening thread",this); + th.start(); + } + + + public InetAddress getAddIP() { + return addIP; + } + + + public void setAddIP(InetAddress addIP) { + this.addIP = addIP; + } + + + public String getPseudo() { + return pseudo; + } + + + public void setPseudo() throws IOException { + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Enter pseudo :"); + String tmpPseudo = myObj.nextLine(); // Read user input + + while(!(this.validatePseudo(tmpPseudo))) { + System.out.println("Already taken, choose another one :"); + tmpPseudo = myObj.nextLine(); // Read user input + } + + this.pseudo = tmpPseudo; + } + + public Boolean validatePseudo(String tmpPseudo) throws IOException { + + + // Call broadcast + InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast + + DatagramSocket dgramSocket = new DatagramSocket(this.nport,this.addIP); + + byte[] buffer = new byte[256]; + + DatagramPacket outPacket= new DatagramPacket(tmpPseudo.getBytes(), tmpPseudo.length(),broadcastIP, 12228); + + dgramSocket.send(outPacket); + + Boolean valid = true; + + Date oldDate = new Date(); + Date newDate = new Date(); + + DatagramPacket inPacket; + String response = null; + String[] lstresponse= new String [4]; + dgramSocket.setSoTimeout(1000); + Boolean arecu; + + System.out.println("Wait for pseudo validation ..."); + while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) { + + + inPacket= new DatagramPacket(buffer, buffer.length); + + arecu=true; + try{ + dgramSocket.receive(inPacket); + }catch (Exception e) { + arecu=false; + } + buffer = inPacket.getData(); + response = new String(buffer); + + if(arecu) { + System.out.println("Reponse : "+response); + + lstresponse = response.split(":"); + + System.out.println("RemoteUser"); + System.out.println("IP : "+lstresponse[0]); + System.out.println("nPort : "+lstresponse[1]); + System.out.println("pseudo : "+lstresponse[2]); + + System.out.println(tmpPseudo); + + //System.out.println(tmpPseudo==lstresponse[2]); + + valid= (tmpPseudo.compareTo(lstresponse[2])!=0); + if(!valid) { + System.out.println("Déjà pris"); + } + } + + newDate = new Date(); + } + System.out.println(valid); + dgramSocket.close(); + + return valid; + } + + + public int getNport() { + return nport; + } + + + public void setNport(int nport) { + this.nport = nport; + } + + + public boolean isActif() { + return actif; + } + + + public void setActif(boolean actif) { + this.actif = actif; + } + + + + public static void main(String[] args) throws IOException { + User activeUsr1 = new User(12228,"Mike"); + + User usr1 = new User(12229); + + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Do you want to stop :"); + String response = myObj.nextLine(); // Read user input + + if(response=="Yes") { + activeUsr1.haveToStopThread=true; + } + } +} +/* +public Boolean compare(String str1, String str2) { + + +} +*/ \ No newline at end of file diff --git a/Application/Clavardage/src/UserListeningThread.java b/Application/Clavardage/src/UserListeningThread.java new file mode 100644 index 0000000..c33c7c0 --- /dev/null +++ b/Application/Clavardage/src/UserListeningThread.java @@ -0,0 +1,55 @@ +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UserListeningThread extends Thread{ + + private User myUser; + + public UserListeningThread(String s,User user) { + super(s); + this.myUser = user; + } + + public void run(){ + DatagramSocket dgramSocket= null; + try { + dgramSocket= new DatagramSocket(this.myUser.getNport(),this.myUser.getAddIP()); + } catch (IOException e) { + e.printStackTrace(); + } + + + while(!this.myUser.haveToStopThread) { + + + byte[] buffer = new byte[256]; + DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length); + try { + dgramSocket.receive(inPacket); + } catch (Exception e) { + e.printStackTrace(); + } + buffer = inPacket.getData(); + InetAddress itsIP=inPacket.getAddress(); + int itsPort=inPacket.getPort(); + + String toSend = myUser.getAddIP().toString()+":"+myUser.getNport()+":"+myUser.getPseudo()+":testS"; + System.out.println(toSend); + DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, 12229); + + try { + dgramSocket.send(outPacket); + } catch (IOException e) { + e.printStackTrace(); + } + + } + dgramSocket.close(); + + } +} + + + diff --git a/Application/RemoteSystemsTempFiles/.project b/Application/RemoteSystemsTempFiles/.project new file mode 100644 index 0000000..5447a64 --- /dev/null +++ b/Application/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + +