pl.agh.iosr.ballamigos.webapp.core
Class WebApplicationCommunicator

java.lang.Object
  extended by pl.agh.iosr.ballamigos.webapp.core.WebApplicationCommunicator
All Implemented Interfaces:
java.rmi.Remote, pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface

public class WebApplicationCommunicator
extends java.lang.Object
implements pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface

Author:
wrobel

Constructor Summary
WebApplicationCommunicator(java.util.Properties props)
           
WebApplicationCommunicator(java.lang.String serverName, int port)
          Constructor that tries to locate server via rmiregistry
 
Method Summary
 void changeMatchProperties(pl.agh.iosr.ballamigos.common.MatchProperties properties)
          Change properties of current match
 void createMatch(java.lang.String name)
          tries to create and register a match on the server
 void createPlayer(java.lang.String login, java.lang.String passwd)
           
 pl.agh.iosr.ballamigos.common.Match getMatch()
           
 pl.agh.iosr.ballamigos.client.room.MatchesListModel getMatches()
           
 java.util.List<java.lang.String> getMatchesInRoom()
          Gets a list of matches for the chosen room.
 java.lang.String getPlayerLogin()
           
 java.util.List<java.lang.String> getPlayersInRoom()
          requests list of players names in player room from server.
 java.lang.String getRoomName()
           
 java.util.List<java.lang.String> getRoomNames()
           
 pl.agh.iosr.ballamigos.common.communication.rmi.ServerInterface getServer()
           
 pl.agh.iosr.ballamigos.common.ServerStatistics getServerStatistics()
           
 void joinMatch(java.lang.String matchName)
          Joins match if posible.
 void login(java.lang.String login, java.lang.String passwd)
          tries to log to a server using login and password
 void logout()
          logs this player out of server.
 void matchCreated(java.lang.String matchName)
          Notyfies that a macth in this room was created.
 boolean matchReceived()
           
 void matchRemoved(java.lang.String matchName)
          Notyfies that a macth in this room was removed.
 boolean matchStarted()
          Check if current match is active
 void moveToRoom(java.lang.String roomName)
          tells server to bind player to a room
 boolean playerEntered()
           
 void playerEnteredRoom(java.lang.String playerName)
          Used to notify client that a player has entered the room he is in.
 void playerJoins(java.lang.String playerName)
          Implements playerJoins method.
 void playerLeftRoom(java.lang.String playerName)
          Used to notify client that a player has left the room he is in.
 void playerQuitedMatch()
           
 void reciveCurrentMatch(pl.agh.iosr.ballamigos.common.Match match)
          Implements reciveCurrentMatch method.
 void reciveMessage(java.lang.String arg0)
           
 void reciveMessage(java.lang.String arg0, java.lang.String arg1)
           
 void reciveMessage(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)
           
 void sendDecision(pl.agh.iosr.ballamigos.common.Decision decision)
          Sends current player move decision.
 void sendStartMatch()
          Sends a signal to server to start match, if succed start the match on this clienmt to.
 void setMatch(pl.agh.iosr.ballamigos.common.Match match)
           
 void setMatches(pl.agh.iosr.ballamigos.client.room.MatchesListModel matches)
           
 void setPlayerLogin(java.lang.String playerLogin)
           
 void setRoomName(java.lang.String roomName)
           
 void setRoomNames(java.util.List<java.lang.String> roomNames)
           
 void setServer(pl.agh.iosr.ballamigos.common.communication.rmi.ServerInterface server)
           
 void startMatch()
          Implements startMatch method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebApplicationCommunicator

public WebApplicationCommunicator(java.lang.String serverName,
                                  int port)
                           throws java.rmi.RemoteException,
                                  java.rmi.NotBoundException
Constructor that tries to locate server via rmiregistry

Parameters:
serverName - - inet addres of rmiregistry
port - - port of rmiregistry
Throws:
java.rmi.RemoteException - - can't connect to rmiregistry
java.rmi.NotBoundException - - there's no server bounded in rmiregistry

WebApplicationCommunicator

public WebApplicationCommunicator(java.util.Properties props)
                           throws java.lang.NumberFormatException,
                                  java.rmi.RemoteException,
                                  java.rmi.NotBoundException
Throws:
java.lang.NumberFormatException
java.rmi.RemoteException
java.rmi.NotBoundException
Method Detail

login

public void login(java.lang.String login,
                  java.lang.String passwd)
           throws java.rmi.RemoteException,
                  pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyLoggedException,
                  pl.agh.iosr.ballamigos.common.exceptions.LoginException
tries to log to a server using login and password

Parameters:
login - - player login.
passwd - - player password.
Throws:
java.rmi.RemoteException - - server connection failed
pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyLoggedException - - there is a player logged with this login.
pl.agh.iosr.ballamigos.common.exceptions.LoginException

createPlayer

public void createPlayer(java.lang.String login,
                         java.lang.String passwd)
                  throws java.rmi.RemoteException,
                         pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyExistsException
Parameters:
login -
passwd -
Throws:
java.rmi.RemoteException
pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyExistsException

moveToRoom

public void moveToRoom(java.lang.String roomName)
                throws java.rmi.RemoteException
tells server to bind player to a room

Parameters:
roomName - - name of the room that player wants to join
Throws:
java.rmi.RemoteException - - server connection failed

getPlayersInRoom

public java.util.List<java.lang.String> getPlayersInRoom()
                                                  throws java.rmi.RemoteException
requests list of players names in player room from server.

Returns:
list of players names in players room
Throws:
java.rmi.RemoteException - - server connection failed

reciveMessage

public void reciveMessage(java.lang.String arg0)
                   throws java.rmi.RemoteException
Specified by:
reciveMessage in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Throws:
java.rmi.RemoteException

reciveMessage

public void reciveMessage(java.lang.String arg0,
                          java.lang.String arg1)
                   throws java.rmi.RemoteException
Specified by:
reciveMessage in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Throws:
java.rmi.RemoteException

reciveMessage

public void reciveMessage(java.lang.String arg0,
                          java.lang.String arg1,
                          java.lang.String arg2)
                   throws java.rmi.RemoteException
Specified by:
reciveMessage in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Throws:
java.rmi.RemoteException

playerEnteredRoom

public void playerEnteredRoom(java.lang.String playerName)
                       throws java.rmi.RemoteException
Used to notify client that a player has entered the room he is in.

Specified by:
playerEnteredRoom in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Parameters:
playerName - - name of player that entered room
Throws:
java.rmi.RemoteException
See Also:
ClientInterface.playerEnteredRoom(java.lang.String)

playerLeftRoom

public void playerLeftRoom(java.lang.String playerName)
Used to notify client that a player has left the room he is in.

Specified by:
playerLeftRoom in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Parameters:
playerName - - name of player that left room
See Also:
ClientInterface.playerLeftRoom(java.lang.String)

logout

public void logout()
            throws java.rmi.RemoteException
logs this player out of server.

Throws:
java.rmi.RemoteException

createMatch

public void createMatch(java.lang.String name)
                 throws java.rmi.RemoteException,
                        pl.agh.iosr.ballamigos.common.exceptions.MatchAlreadyExistsException,
                        pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyInGameException
tries to create and register a match on the server

Parameters:
name - - name of this match
Throws:
java.rmi.RemoteException
pl.agh.iosr.ballamigos.common.exceptions.MatchAlreadyExistsException
pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyInGameException

matchCreated

public void matchCreated(java.lang.String matchName)
                  throws java.rmi.RemoteException
Notyfies that a macth in this room was created.

Specified by:
matchCreated in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Parameters:
matchName - - name match that was created.
Throws:
java.rmi.RemoteException
See Also:
ClientInterface.matchCreated(java.lang.String)

matchRemoved

public void matchRemoved(java.lang.String matchName)
                  throws java.rmi.RemoteException
Notyfies that a macth in this room was removed.

Specified by:
matchRemoved in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Parameters:
matchName - - name match that was removed.
Throws:
java.rmi.RemoteException
See Also:
ClientInterface.matchRemoved(java.lang.String)

joinMatch

public void joinMatch(java.lang.String matchName)
               throws java.rmi.RemoteException,
                      pl.agh.iosr.ballamigos.common.exceptions.MatchFullException,
                      pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyInGameException
Joins match if posible.

Parameters:
matchName - - name of a match to join
Throws:
java.rmi.RemoteException
pl.agh.iosr.ballamigos.common.exceptions.MatchFullException
pl.agh.iosr.ballamigos.common.exceptions.PlayerAlreadyInGameException

playerJoins

public void playerJoins(java.lang.String playerName)
                 throws java.rmi.RemoteException
Implements playerJoins method. Used by server to notify clients when a player has joined their room.

Specified by:
playerJoins in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Throws:
java.rmi.RemoteException
See Also:
ClientInterface.playerJoins(java.lang.String)

playerQuitedMatch

public void playerQuitedMatch()
Specified by:
playerQuitedMatch in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface

matchReceived

public boolean matchReceived()

reciveCurrentMatch

public void reciveCurrentMatch(pl.agh.iosr.ballamigos.common.Match match)
                        throws java.rmi.RemoteException
Implements reciveCurrentMatch method. Used by server to send results of their moves (current match state). It tells display panel to display animation a this move

Specified by:
reciveCurrentMatch in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Throws:
java.rmi.RemoteException
See Also:
ClientInterface.reciveCurrentMatch(pl.agh.iosr.ballamigos.common.Match)

playerEntered

public boolean playerEntered()

matchStarted

public boolean matchStarted()
Check if current match is active

Returns:

startMatch

public void startMatch()
                throws java.rmi.RemoteException
Implements startMatch method. Tells client that match has started

Specified by:
startMatch in interface pl.agh.iosr.ballamigos.common.communication.rmi.ClientInterface
Throws:
java.rmi.RemoteException
See Also:
ClientInterface.startMatch()

sendStartMatch

public void sendStartMatch()
                    throws java.rmi.RemoteException
Sends a signal to server to start match, if succed start the match on this clienmt to.

Throws:
java.rmi.RemoteException

changeMatchProperties

public void changeMatchProperties(pl.agh.iosr.ballamigos.common.MatchProperties properties)
                           throws java.rmi.RemoteException,
                                  pl.agh.iosr.ballamigos.common.exceptions.MatchDoesntExistException
Change properties of current match

Parameters:
properties -
Throws:
java.rmi.RemoteException
pl.agh.iosr.ballamigos.common.exceptions.MatchDoesntExistException

sendDecision

public void sendDecision(pl.agh.iosr.ballamigos.common.Decision decision)
                  throws java.rmi.RemoteException
Sends current player move decision.

Parameters:
decision - - contains player choises for this round.
Throws:
java.rmi.RemoteException

getRoomNames

public java.util.List<java.lang.String> getRoomNames()
                                              throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getServerStatistics

public pl.agh.iosr.ballamigos.common.ServerStatistics getServerStatistics()
                                                                   throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getMatch

public pl.agh.iosr.ballamigos.common.Match getMatch()
Returns:
Returns the match.

setMatch

public void setMatch(pl.agh.iosr.ballamigos.common.Match match)
Parameters:
match - The match to set.

getMatches

public pl.agh.iosr.ballamigos.client.room.MatchesListModel getMatches()
Returns:
Returns the matches.

setMatches

public void setMatches(pl.agh.iosr.ballamigos.client.room.MatchesListModel matches)
Parameters:
matches - The matches to set.

getPlayerLogin

public java.lang.String getPlayerLogin()
Returns:
Returns the playerLogin.

setPlayerLogin

public void setPlayerLogin(java.lang.String playerLogin)
Parameters:
playerLogin - The playerLogin to set.

getRoomName

public java.lang.String getRoomName()
Returns:
Returns the roomName.

setRoomName

public void setRoomName(java.lang.String roomName)
Parameters:
roomName - The roomName to set.

getServer

public pl.agh.iosr.ballamigos.common.communication.rmi.ServerInterface getServer()
Returns:
Returns the server.

setServer

public void setServer(pl.agh.iosr.ballamigos.common.communication.rmi.ServerInterface server)
Parameters:
server - The server to set.

setRoomNames

public void setRoomNames(java.util.List<java.lang.String> roomNames)
Parameters:
roomNames - The roomNames to set.

getMatchesInRoom

public java.util.List<java.lang.String> getMatchesInRoom()
                                                  throws java.rmi.RemoteException
Gets a list of matches for the chosen room.

Returns:
Returns a list of matches in the current room
Throws:
java.rmi.RemoteException - when there a problems with RMI


Copyright © 2006 . All Rights Reserved.