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
genie_logiciel_2015
the_dungeon_project
Commits
de6c1341
Commit
de6c1341
authored
Jan 04, 2016
by
Bogdan
Browse files
Implementing lounges with remote procedure calls. Still not ready.
parent
91077a16
Changes
40
Hide whitespace changes
Inline
Side-by-side
src/core/event/Event.java
View file @
de6c1341
...
...
@@ -2,7 +2,7 @@ package core.event;
import
core.gamestate.GameContent
;
import
network.NetworkObject
;
import
network.
innershell.
NetworkObject
;
/**
* This interface is used to define the message transmitted between the Relayer,
...
...
src/core/gamestate/Being.java
View file @
de6c1341
...
...
@@ -10,12 +10,11 @@ import core.event.Event;
import
core.event.ToServerDeathEvent
;
import
core.zone.Zone
;
import
gameloop.DummyLocalGameLoop
;
import
gameloop.ServerLoop
;
import
graphics.guiSkeleton.entityDisplayer.EntityDisplayerType
;
import
logging.Logging
;
import
map_generation.tiles.TilePropertyVector
;
import
network.NetworkConnection
;
import
network.NetworkObject
;
import
network.
innershell.
NetworkConnection
;
import
network.
innershell.
NetworkObject
;
/**
* This class represents an Entity able to be hit and die.
...
...
src/core/gamestate/Entity.java
View file @
de6c1341
...
...
@@ -6,7 +6,6 @@ import java.util.List;
import
java.util.Objects
;
import
core.abilities.Ability
;
import
core.abilities.effects.CommonCharacterIDListFilter
;
import
core.abilities.effects.Effect
;
import
core.event.TriggerEvent
;
import
core.relayer.RelayerEntity
;
...
...
@@ -19,8 +18,8 @@ import graphics.guiSkeleton.entityDisplayer.EntityDisplayerProvider;
import
graphics.guiSkeleton.entityDisplayer.EntityDisplayerType
;
import
map_generation.map.Map
;
import
map_generation.tiles.TilePropertyVector
;
import
network.NetworkConnection
;
import
network.NetworkObject
;
import
network.
innershell.
NetworkConnection
;
import
network.
innershell.
NetworkObject
;
/**
* This interface is used to define one object in the GameState.
...
...
src/core/gamestate/GameContent.java
View file @
de6c1341
...
...
@@ -2,8 +2,8 @@ package core.gamestate;
import
core.zone.Point
;
import
map_generation.map.Map
;
import
network.NetworkConnection
;
import
network.NetworkObject
;
import
network.
innershell.
NetworkConnection
;
import
network.
innershell.
NetworkObject
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
...
...
src/gameloop/DummyLocalGameLoop.java
View file @
de6c1341
...
...
@@ -3,14 +3,14 @@ package gameloop;
import
core.event.Event
;
import
core.event.MapInit
;
import
core.event.ToClientDeathEvent
;
import
core.event.ToServerDeathEvent
;
import
core.gamestate.GameContent
;
import
core.relayer.Relayer
;
import
core.relayer.Relayers
;
import
graphics.graphical_abstraction.GraphicsMasterAbstraction
;
import
network.EndEvent
;
import
network.NetworkConnection
;
import
network.NetworkObject
;
import
network.innershell.EndEvent
;
import
network.innershell.NetworkConnection
;
import
network.innershell.NetworkObject
;
import
java.util.concurrent.Semaphore
;
...
...
@@ -23,13 +23,12 @@ public class DummyLocalGameLoop extends Thread{
private
GameContent
gameContent
;
//this is the counter which gives us the ID of the game
private
int
gameCounterID
=
0
;
private
Semaphore
relayerSemaphore
=
new
Semaphore
(
1
,
true
);
private
Relayer
followedRelayer
;
private
boolean
isPlaying
=
false
;
private
boolean
shouldRPC
=
false
;
...
...
@@ -96,6 +95,12 @@ public class DummyLocalGameLoop extends Thread{
return
false
;
}
public
synchronized
void
setStartedBefore
()
{
gameCounterID
=
1
;
}
/**
* pauses the execution of the gameLoop
*/
...
...
@@ -137,6 +142,8 @@ public class DummyLocalGameLoop extends Thread{
while
(
true
)
{
//System.out.println("DummyLocalGameLoopThread, game is "+isPlaying);
if
(
getIsPlaying
())
{
//initially this is false!
setShouldRPC
(
false
);
System
.
out
.
println
(
"DummyLocalGameLoopThread,"
+
currentThread
().
getId
()+
"game is "
+
isPlaying
);
Event
eventToReceive
=
null
;
System
.
out
.
println
(
"The game is on!"
);
...
...
@@ -158,14 +165,21 @@ public class DummyLocalGameLoop extends Thread{
System
.
out
.
println
(
"DummyLocalGameLoop Thread: End Event Received!"
);
}
else
{
try
{
sleep
(
10
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
try
{
sleep
(
10
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
//System.out.println("DummyLocalGameLoop Thread dying..."+ourInstance);
}
public
synchronized
boolean
isShouldRPC
()
{
return
shouldRPC
;
}
public
synchronized
void
setShouldRPC
(
boolean
shouldRPC
)
{
this
.
shouldRPC
=
shouldRPC
;
}
}
src/gameloop/GameStarter.java
View file @
de6c1341
...
...
@@ -3,10 +3,10 @@ package gameloop;
import
artificial_intelligence.AIControler
;
import
core.relayer.Relayer
;
import
core.relayer.Relayers
;
import
network.ClientConnection
;
import
network.LocalConnection
;
import
network.NetworkConnection
;
import
network.NetworkObject
;
import
network.
innershell.
ClientConnection
;
import
network.
innershell.
LocalConnection
;
import
network.
innershell.
NetworkConnection
;
import
network.
innershell.
NetworkObject
;
/**
* Created by dupriez on 12/11/15.
...
...
@@ -42,9 +42,9 @@ public class GameStarter {
}
static
public
void
startGameMultiplayerPlayer
()
static
public
void
startGameMultiplayerPlayer
(
String
ip
,
int
port
)
{
NetworkConnection
<
NetworkObject
>
networkConnection
=
new
ClientConnection
(
"127.0.0.1"
,
8888
);
NetworkConnection
<
NetworkObject
>
networkConnection
=
new
ClientConnection
(
ip
,
port
);
DummyLocalGameLoop
.
getInstance
().
setNetworkConnection
(
networkConnection
);
//Symmetric behavior, the same as with singlePlayerStartProcedure
if
(!
DummyLocalGameLoop
.
getInstance
().
startedBefore
())
...
...
src/gameloop/ServerLoop.java
View file @
de6c1341
package
gameloop
;
import
artificial_intelligence.AIControler
;
import
core.event.EmptyEvent
;
import
core.event.Event
;
import
core.event.MapInit
;
import
core.event.ToServerDeathEvent
;
import
core.gamestate.*
;
import
core.relayer.Relayers
;
import
graphics.graphical_abstraction.GraphicsMasterAbstraction
;
import
map_generation.map.Map
;
import
map_generation.map.MapGeneration
;
import
network.EndEvent
;
import
network.NetworkConnection
;
import
network.NetworkObject
;
import
network.ServerConnection
;
import
network.
innershell.
EndEvent
;
import
network.
innershell.
NetworkConnection
;
import
network.
innershell.
NetworkObject
;
import
network.
innershell.
ServerConnection
;
/**
* This might also be a LocalServerLoop, it is just a thread object that cannot and should not be reused
...
...
src/graphics/graphical_abstraction/GraphicsMasterAbstraction.java
View file @
de6c1341
...
...
@@ -36,7 +36,9 @@ public abstract class GraphicsMasterAbstraction {
MULTIPLAYER_CHARACTER_CHOICE
,
SINGLEPLAYER_CHARACTER_CHOICE
,
GAME_OVER
,
LOST_CONNECTION
LOST_CONNECTION
,
PLEASE_WAIT
,
SERVER_ADDRESS_PANEL
}
//This map indicates to graphicsMaster which guiPanel is associated to each GUIState, it is filled in Graphicsmaster's constructor
protected
HashMap
<
GUIStates
,
PanelAbstraction
>
mapGUIStatesToGUIPanel
=
new
HashMap
<>();
...
...
src/graphics/guiSkeleton/GraphicsMaster.java
View file @
de6c1341
...
...
@@ -56,7 +56,9 @@ public class GraphicsMaster extends GraphicsMasterAbstraction {
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
SINGLEPLAYER_CHARACTER_CHOICE
,
new
SinglePlayer_CharacterChoicePanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
SINGLEPLAYER_LOADGAME
,
new
SinglePlayer_LoadGamePanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
LOST_CONNECTION
,
new
LostConnectionPanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
PLEASE_WAIT
,
new
PleaseWaitPanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
SERVER_ADDRESS_PANEL
,
new
ServerAddressPanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
GAME_OVER
,
new
GameOverPanel
(
this
));
}
...
...
src/graphics/guiSkeleton/Igniter_Main.java
View file @
de6c1341
...
...
@@ -2,6 +2,7 @@ package graphics.guiSkeleton;
import
core.abilities.AbilityPackageInitialiser
;
import
core.abilities.effects.EffectPackageInitialiser
;
import
gameloop.DummyLocalGameLoop
;
import
graphics.graphical_abstraction.GraphicsMasterAbstraction
;
/**
...
...
@@ -19,6 +20,10 @@ public class Igniter_Main {
EffectPackageInitialiser
.
initialisePackage
();
System
.
out
.
println
();
/** launch the DummyLocalGameLoop**/
DummyLocalGameLoop
.
getInstance
().
setStartedBefore
();
DummyLocalGameLoop
.
getInstance
().
start
();
/** Launch the GUI (and thus the game) **/
GraphicsMaster
.
build
();
GraphicsMasterAbstraction
gm
=
GraphicsMasterAbstraction
.
getInstance
();
...
...
src/graphics/guiSkeleton/guiPanel/menuPanel/LostConnectionPanel.java
View file @
de6c1341
...
...
@@ -17,7 +17,7 @@ public class LostConnectionPanel extends MenuPanel{
public
LostConnectionPanel
(
GraphicsMaster
graphicsMaster
)
{
super
(
graphicsMaster
);
JLabel
sorryLabel
=
new
JLabel
(
"Connection Lost..."
);
JLabel
sorryLabel
=
new
JLabel
(
"Connection Lost
or Bad Server Address
..."
);
sorryLabel
.
setFont
(
GUIColorsAndFonts
.
smallFont1
);
sorryLabel
.
setForeground
(
GUIColorsAndFonts
.
fontColor1
);
...
...
src/graphics/guiSkeleton/guiPanel/menuPanel/MainMenuPanel.java
View file @
de6c1341
package
graphics.guiSkeleton.guiPanel.menuPanel
;
import
graphics.graphical_abstraction.GraphicsMasterAbstraction
;
import
graphics.graphical_abstraction.panel.menu.MainMenuPanelAbstraction
;
import
graphics.graphical_abstraction.panel.menu.MainMenuPanelAbstractionController
;
import
graphics.guiSkeleton.GraphicsMaster
;
...
...
@@ -102,7 +103,7 @@ public class MainMenuPanel extends MenuPanel implements MainMenuPanelAbstraction
@Override
public
void
multiPlayerButtonAction
()
{
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMaster
.
GUIStates
.
MULTIPLAYER_MENU
);
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMaster
.
GUIStates
.
SERVER_ADDRESS_PANEL
);
}
@Override
...
...
src/graphics/guiSkeleton/guiPanel/menuPanel/PleaseWaitPanel.java
0 → 100644
View file @
de6c1341
package
graphics.guiSkeleton.guiPanel.menuPanel
;
import
graphics.guiSkeleton.GUIColorsAndFonts
;
import
graphics.guiSkeleton.GraphicsMaster
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel
;
import
graphics.ingame_input_listener.Input
;
import
javax.swing.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
/**
* Created by bogdanbear on 02/01/2016.
*/
public
class
PleaseWaitPanel
extends
MenuPanel
{
public
PleaseWaitPanel
(
GraphicsMaster
graphicsMaster
)
{
super
(
graphicsMaster
);
JLabel
sorryLabel
=
new
JLabel
(
"Please wait until the other players join in..."
);
sorryLabel
.
setFont
(
GUIColorsAndFonts
.
smallFont1
);
sorryLabel
.
setForeground
(
GUIColorsAndFonts
.
fontColor1
);
addToCentralColumn
(
sorryLabel
,
1
,
1
);
setTitlePanel
(
"Please wait"
);
}
@Override
public
void
initialise
()
{
}
@Override
public
void
finalise
()
{
}
@Override
public
void
keyPressedHandler
(
Input
e
)
{
}
@Override
public
void
keyReleasedHandler
(
Input
e
)
{
}
@Override
public
void
keyTypedHandler
(
Input
e
)
{
}
}
src/graphics/guiSkeleton/guiPanel/menuPanel/ServerAddressPanel.java
0 → 100644
View file @
de6c1341
package
graphics.guiSkeleton.guiPanel.menuPanel
;
import
gameloop.DummyLocalGameLoop
;
import
graphics.graphical_abstraction.GraphicsMasterAbstraction
;
import
graphics.guiSkeleton.GUIColorsAndFonts
;
import
graphics.guiSkeleton.GraphicsMaster
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel
;
import
graphics.ingame_input_listener.Input
;
import
network.outershell.RPCClient
;
import
javax.swing.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
/**
* Created by bogdanbear on 04/01/2016.
*/
public
class
ServerAddressPanel
extends
MenuPanel
{
JTextField
addressTextField
=
new
JTextField
(
"127.0.0.1"
);;
public
ServerAddressPanel
(
GraphicsMaster
graphicsMaster
)
{
super
(
graphicsMaster
);
JLabel
inputLabel
=
new
JLabel
(
"Please input server address to connect..."
);
inputLabel
.
setFont
(
GUIColorsAndFonts
.
smallFont1
);
inputLabel
.
setForeground
(
GUIColorsAndFonts
.
fontColor1
);
addToCentralColumn
(
inputLabel
,
1
,
1
);
setTitlePanel
(
"IP address."
);
addToCentralColumn
(
addressTextField
,
1
,
1
);
addToCentralColumn
(
inputLabel
,
1
,
1
);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Confirm"
,
confirmButtonActionListener
),
1
,
1
);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Back"
,
backButtonActionListener
),
1
,
1
);
}
private
ActionListener
confirmButtonActionListener
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
String
address
=
addressTextField
.
getText
();
RPCClient
.
setIp
(
address
);
//it should start RPC calls
DummyLocalGameLoop
.
getInstance
().
setShouldRPC
(
true
);
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMaster
.
GUIStates
.
MULTIPLAYER_MENU
);
}
};
private
ActionListener
backButtonActionListener
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMaster
.
GUIStates
.
MAIN_MENU
);
}
};
@Override
public
void
initialise
()
{
}
@Override
public
void
finalise
()
{
}
@Override
public
void
keyPressedHandler
(
Input
e
)
{
}
@Override
public
void
keyReleasedHandler
(
Input
e
)
{
}
@Override
public
void
keyTypedHandler
(
Input
e
)
{
}
}
src/graphics/guiSkeleton/guiPanel/menuPanel/gameCreation/GameCreationInput_SubPanel.java
View file @
de6c1341
...
...
@@ -10,9 +10,17 @@ import java.awt.*;
*/
public
class
GameCreationInput_SubPanel
extends
JPanel
{
private
JTextField
gameName
=
new
JTextField
();
private
static
final
long
serialVersionUID
=
1L
;
GameCreationInput_SubPanel
()
{
add
(
new
Label
(
"GameCreationInput_SubPanel"
));
add
(
new
Label
(
"GameCreationInput_SubPanel| Room Name:"
));
this
.
setPreferredSize
(
new
Dimension
(
500
,
54
));
gameName
.
setPreferredSize
(
new
Dimension
(
200
,
24
)
);
add
(
gameName
);
}
public
String
getGameName
()
{
return
gameName
.
getText
();
}
}
src/graphics/guiSkeleton/guiPanel/menuPanel/multiPlayer_MenuPanel/LoungeList_SubPanel.java
View file @
de6c1341
package
graphics.guiSkeleton.guiPanel.menuPanel.multiPlayer_MenuPanel
;
import
network.outershell.Lounge
;
import
network.outershell.RPCClient
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.util.ArrayList
;
/**
* Created by dupriez on 07/12/15.
...
...
@@ -11,9 +16,26 @@ import javax.swing.*;
*/
public
class
LoungeList_SubPanel
extends
JPanel
{
//CODE FROM BoxLayout tutorial, ListDialog.java
private
JPanel
listPanel
;
private
static
final
long
serialVersionUID
=
1L
;
public
LoungeList_SubPanel
()
{
add
(
new
JLabel
(
"LoungeList_SubPanel"
));
listPanel
=
new
JPanel
();
ArrayList
<
Lounge
>
lounges
=
RPCClient
.
getLoungeList
();
for
(
Lounge
lounge:
lounges
)
{
JPanel
loungePanel
=
PickLoungeSubPanelFactory
.
createPickLoungeSubPanel
(
lounge
.
getName
()+
" "
+(
lounge
.
MAX_PLAYERS
-
lounge
.
numberFreeSpots
())+
"/"
+
lounge
.
MAX_PLAYERS
,
lounge
);
listPanel
.
add
(
loungePanel
);
}
BoxLayout
boxLayout
=
new
BoxLayout
(
listPanel
,
BoxLayout
.
Y_AXIS
);
listPanel
.
setLayout
(
boxLayout
);
JScrollPane
scrollPane
=
new
JScrollPane
();
scrollPane
.
getViewport
().
add
(
listPanel
);
add
(
scrollPane
);
}
}
src/graphics/guiSkeleton/guiPanel/menuPanel/multiPlayer_MenuPanel/MultiPlayer_MenuPanel.java
View file @
de6c1341
...
...
@@ -25,11 +25,11 @@ public class MultiPlayer_MenuPanel extends MenuPanel {
public
MultiPlayer_MenuPanel
(
GraphicsMaster
graphicsMaster
){
super
(
graphicsMaster
);
setTitlePanel
(
"MultiPlayer Thessia"
);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Host new game"
,
hostNewGameButton_ActionListener
),
1
,
1
);
addToCentralColumn
(
new
LoungeList_SubPanel
(),
1
,
1
);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Join Lounge"
,
joinLoungeButton_ActionListener
),
1
,
1
);
addToCentralColumn
(
new
IPtextField
(),
1
,
1
);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Join game at IP:"
,
joinGameAtIP_ActionListener
),
1
,
1
);
//addToCentralColumn(ButtonMaker.makeButton("Join Lounge", joinLoungeButton_ActionListener),1,1);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Host new game"
,
hostNewGameButton_ActionListener
),
1
,
1
);
//addToCentralColumn(new IPtextField(),1,1);
//addToCentralColumn(ButtonMaker.makeButton("Join game at IP:", joinGameAtIP_ActionListener),1,1);
JButton
oldPlayButton
=
ButtonMaker
.
makeButton
(
"Old play button"
,
oldPlayButton_ActionListener
);
oldPlayButton
.
setBackground
(
new
Color
(
174
,
0
,
0
));
addToCentralColumn
(
oldPlayButton
,
1
,
1
);
...
...
@@ -39,16 +39,16 @@ public class MultiPlayer_MenuPanel extends MenuPanel {
private
ActionListener
hostNewGameButton_ActionListener
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMasterAbstraction
.
GUIStates
.
MULTIPLAYER_GAME_CREATION
);
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMasterAbstraction
.
GUIStates
.
PLEASE_WAIT
);
}
};
private
ActionListener
joinLoungeButton_ActionListener
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMasterAbstraction
.
GUIStates
.
LOUNGE
);
}
};
//
private ActionListener joinLoungeButton_ActionListener = new ActionListener() {
//
@Override
//
public void actionPerformed(ActionEvent actionEvent) {
//
getGraphicsMaster().changeGUIStateTo(GraphicsMasterAbstraction.GUIStates.
PLEASE_WAIT
);
//
}
//
};
private
ActionListener
joinGameAtIP_ActionListener
=
new
ActionListener
()
{
@Override
...
...
@@ -60,7 +60,7 @@ public class MultiPlayer_MenuPanel extends MenuPanel {
private
ActionListener
oldPlayButton_ActionListener
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
GameStarter
.
startGameMultiplayerPlayer
();
GameStarter
.
startGameMultiplayerPlayer
(
"127.0.0.1"
,
8888
);
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMaster
.
GUIStates
.
GAME_PANEL
);
}
};
...
...
src/graphics/guiSkeleton/guiPanel/menuPanel/multiPlayer_MenuPanel/PickLoungeSubPanelFactory.java
0 → 100644
View file @
de6c1341
package
graphics.guiSkeleton.guiPanel.menuPanel.multiPlayer_MenuPanel
;
import
graphics.guiSkeleton.GUIColorsAndFonts
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker
;
import
network.outershell.Lounge
;
import
network.outershell.RPCClient
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
/**
* Created by bogdanbear on 04/01/2016.
*/
public
class
PickLoungeSubPanelFactory
{
public
static
JPanel
createPickLoungeSubPanel
(
String
info
,
Lounge
lounge
)
{
JPanel
result
=
new
JPanel
(
new
FlowLayout
());
JLabel
infoLabel
=
new
JLabel
(
info
);
infoLabel
.
setFont
(
GUIColorsAndFonts
.
smallFont1
);
infoLabel
.
setForeground
(
GUIColorsAndFonts
.
fontColor1
);
//ImageIcon imageIcon=new ImageIcon("src/graphics/guiSkeleton/guiPanel/interfaceElements/playicon.jpg");
JButton
playButton
=
new
JButton
(
"Join"
);
playButton
.
addActionListener
(
new
PlayButtonActionListener
(
lounge
));
result
.
add
(
infoLabel
);
result
.
add
(
playButton
);
return
result
;
}
private
static
class
PlayButtonActionListener
implements
ActionListener
{
private
Lounge
lounge
;
public
PlayButtonActionListener
(
Lounge
lounge
)
{
this
.
lounge
=
lounge
;
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
RPCClient
.
joinLounge
(
lounge
.
getLoungeID
()))
{
System
.
out
.
println
(
"PickLoungeSubPanel in the PickLoungeSubPanelFactory: server gives green light. Initiate join..."
);
}
else
{
System
.
out
.
println
(
"PickLoungeSubPanel in the PickLoungeSubPanelFactory: join failed"
);
}
}
}
}
src/network/ClientConnection.java
→
src/network/
innershell/
ClientConnection.java
View file @
de6c1341
package
network
;
package
network
.innershell
;
import
java.io.IOException
;
import
java.io.NotSerializableException
;
...
...
@@ -26,7 +26,8 @@ public class ClientConnection extends NetworkConnection<NetworkObject>{
socket
=
new
Socket
(
serverAddress
,
PORT
);
//inputStream = new ObjectInputStream(socket.getInputStream());
outputStream
=
new
ObjectOutputStream
(
socket
.
getOutputStream
());
ClientInputThread
clientInputThread
=
new
ClientInputThread
(
socket
,
this
,
false
);
//the id of this thread is not important, since it is on the client side.
ClientInputThread
clientInputThread
=
new
ClientInputThread
(
socket
,
this
,
false
,
0
);
clientInputThread
.
start
();
//catch (IOException e) {
// System.out.println("network: IO excception thrown in ClientConnection.close(), could also be a case of UnknownHostException");
...
...
@@ -35,6 +36,7 @@ public class ClientConnection extends NetworkConnection<NetworkObject>{
}
catch
(
IOException
e
)
{
setBroken
(
true
);
LOGGER
.
warning
(
e
.
toString
());
}
}
...
...
@@ -59,6 +61,7 @@ public class ClientConnection extends NetworkConnection<NetworkObject>{
if
(
e1
instanceof
NotSerializableException
)
LOGGER
.
severe
(
"Not SerializableObject"
);
//System.out.println("NOTSERIALIZABLE!!!! network: NotSerializableObject!!!!!!!!!");
setBroken
(
true
);
LOGGER
.
warning
(
e1
.
toString
());
//System.out.println("network: IO excception thrown in ClientConnection.sendEvent()" + e1);
}
...
...
src/network/ClientInputThread.java
→
src/network/
innershell/
ClientInputThread.java
View file @
de6c1341
package
network
;
package
network
.innershell
;
import
logging.Logging
;
...
...
@@ -20,16 +20,18 @@ public class ClientInputThread extends Thread {
private
NetworkConnection
<?>
parent
;
private
boolean
serverside
;
private
static
Logger
LOGGER
=
new
Logging
().
getLogger
();
private
int
ID
;
/**
* Initialization of the class.
* @param socket socket of the connection