Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COMP90015-DSAss2-InfinityMonkeys-remaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ho Dac Hai
COMP90015-DSAss2-InfinityMonkeys-remaster
Commits
7a9d34c7
Commit
7a9d34c7
authored
Oct 20, 2019
by
mpriymak
Browse files
Options
Downloads
Patches
Plain Diff
test ok
parent
17c59007
No related branches found
No related tags found
1 merge request
!15
Hai
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/GUI/StartScreen.java
+6
-8
6 additions, 8 deletions
src/GUI/StartScreen.java
src/client/Client.java
+21
-13
21 additions, 13 deletions
src/client/Client.java
with
27 additions
and
21 deletions
src/GUI/StartScreen.java
+
6
−
8
View file @
7a9d34c7
...
@@ -27,28 +27,26 @@ public class StartScreen {
...
@@ -27,28 +27,26 @@ public class StartScreen {
// }
// }
ActionListener
actionListener
=
new
ActionListener
()
{
ActionListener
actionListener
=
new
ActionListener
()
public
void
actionPerformed
(
ActionEvent
e
)
{
{
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
e
.
getSource
()
==
joinButton
)
if
(
e
.
getSource
()
==
joinButton
)
{
{
client
.
setUsername
(
textField1
.
getText
());
client
.
setServerAddress
(
textField2
.
getText
());
client
.
setServerAddress
(
textField2
.
getText
());
client
.
setUsername
(
textField1
.
getText
());
if
(
client
.
connect
()
)
if
(
client
.
connect
()
)
{
{
frame
.
setVisible
(
false
);
frame
.
setVisible
(
false
);
frame
.
dispose
();
frame
.
dispose
();
client
.
run
();
}
}
else
else
{
{
showErrorMessage
(
"Could not connect to server..."
);
showErrorMessage
(
"Could not connect to server..."
);
}
}
client
.
//new ChatScreen();
//new ChatScreen();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/client/Client.java
+
21
−
13
View file @
7a9d34c7
...
@@ -21,7 +21,7 @@ public class Client
...
@@ -21,7 +21,7 @@ public class Client
private
IChatController
chatController
;
private
IChatController
chatController
;
private
IClientController
clientController
;
private
IClientController
clientController
;
private
ChatUpdate
chatUpdate
;
private
ChatUpdate
chatUpdate
;
private
DrawingUpdate
drawingUpdate
;
//
private DrawingUpdate drawingUpdate;
private
StartScreen
startScreen
;
private
StartScreen
startScreen
;
...
@@ -40,7 +40,7 @@ public class Client
...
@@ -40,7 +40,7 @@ public class Client
this
.
userName
=
"DefaultUser"
;
this
.
userName
=
"DefaultUser"
;
this
.
chatUpdate
=
new
ChatUpdate
();
this
.
chatUpdate
=
new
ChatUpdate
();
this
.
startScreen
=
new
StartScreen
(
this
);
this
.
startScreen
=
new
StartScreen
(
this
);
this
.
drawingUpdate
=
new
DrawingUpdate
();
//
this.drawingUpdate = new DrawingUpdate();
}
}
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
...
@@ -56,12 +56,13 @@ public class Client
...
@@ -56,12 +56,13 @@ public class Client
}
}
}
}
public
void
run
()
throws
RemoteException
,
NotBoundException
public
void
run
()
{
{
connect
();
//
connect();
try
try
{
{
System
.
out
.
println
(
"Sleeping..."
);
TimeUnit
.
MINUTES
.
sleep
(
5
);
TimeUnit
.
MINUTES
.
sleep
(
5
);
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
...
@@ -70,24 +71,31 @@ public class Client
...
@@ -70,24 +71,31 @@ public class Client
}
}
}
}
public
boolean
connect
()
throws
RemoteException
,
NotBoundException
public
boolean
connect
()
{
{
registryServer
=
LocateRegistry
.
getRegistry
(
"localhost"
);
try
{
registryServer
=
LocateRegistry
.
getRegistry
(
serverAddress
);
chatController
=
(
IChatController
)
registryServer
.
lookup
(
"ChatController"
);
chatController
=
(
IChatController
)
registryServer
.
lookup
(
"ChatController"
);
clientController
=
(
IClientController
)
registryServer
.
lookup
(
"ClientController"
);
clientController
=
(
IClientController
)
registryServer
.
lookup
(
"ClientController"
);
System
.
out
.
println
(
userName
+
" fetched all controller from RMI registry"
);
if
(
clientController
.
join
(
userName
,
this
.
chatUpdate
))
if
(
clientController
.
join
(
userName
,
this
.
chatUpdate
))
{
{
System
.
out
.
println
(
"Connected to server"
);
System
.
out
.
println
(
"Connected to server"
);
return
true
;
return
true
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
false
;
return
false
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment