Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Quentin DRUAULT-AUBIN
lo23-project
Commits
5526962a
Commit
5526962a
authored
Jan 02, 2018
by
Thibault Chiche
Browse files
[com] ajout fonctions removeGame et message m_removeGame
parent
0eeadfea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Battleship/src/main/java/com/utclo23/com/ComFacade.java
View file @
5526962a
...
...
@@ -168,7 +168,7 @@ public class ComFacade {
Sender
os
=
new
Sender
(
kIpCtrl
.
getHashMap
().
get
(
recipient
.
getId
()).
getHostAddress
(),
kIpCtrl
.
getPort
(),
mLeaveGame
);
new
Thread
(
os
).
start
();
}
}
}
}
/**
...
...
@@ -243,4 +243,15 @@ public class ComFacade {
Logger
.
getLogger
(
ComFacade
.
class
.
getName
()).
log
(
Level
.
INFO
,
null
,
"Fail joinGame"
);
}
}
public
void
removeGame
(
String
idGame
){
M_RemoveGame
m_RemoveGame
=
new
M_RemoveGame
(
iDataCom
.
getMyPublicUserProfile
(),
idGame
);
for
(
Inet4Address
ip
:
kIpCtrl
.
getHashMap
().
values
())
{
if
(
ip
!=
null
)
{
Sender
os
=
new
Sender
(
ip
.
getHostAddress
(),
kIpCtrl
.
getPort
(),
m_RemoveGame
);
Thread
thread
=
new
Thread
(
os
);
thread
.
start
();
}
}
}
}
Battleship/src/main/java/com/utclo23/com/messages/M_RemoveGame.java
0 → 100644
View file @
5526962a
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
com.utclo23.com.messages
;
import
com.utclo23.data.facade.IDataCom
;
import
com.utclo23.data.structure.PublicUser
;
/**
* M_LeaveGame is a Message generated when a user wants to leave a game.
* @author Thibault CHICHE
*/
public
class
M_RemoveGame
extends
Message
{
private
final
String
idGame
;
/**
* Constructor.
* @param user is the message's sender
* @param idGame is the id of the game to remove
*/
public
M_RemoveGame
(
PublicUser
user
,
String
idGame
){
super
(
user
);
this
.
idGame
=
idGame
;
}
@Override
public
void
callback
(
IDataCom
iDataCom
){
iDataCom
.
removeGame
(
idGame
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment