cz.cuni.amis.pogamut.ut2004.teamcomm.mina.client
Class TCMinaClient

Package class diagram package TCMinaClient
java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.teamcomm.mina.client.TCMinaClient
All Implemented Interfaces:
org.apache.mina.core.service.IoHandler

public class TCMinaClient
extends Object
implements org.apache.mina.core.service.IoHandler


Nested Class Summary
static class TCMinaClient.RequestFuture<T>
           
 
Constructor Summary
TCMinaClient(UT2004TCClient owner, InetSocketAddress connectToAddress, cz.cuni.amis.pogamut.base.communication.worldview.IWorldView teamWorldView, Logger log)
           
 
Method Summary
 void connect()
           
protected  void connected(org.apache.mina.core.future.ConnectFuture event)
           
 void exceptionCaught(org.apache.mina.core.session.IoSession session, Throwable exception)
           
 TCChannel getChannel(int channelId)
          Returns details about bots/channels connected to the team.
 cz.cuni.amis.utils.flag.ImmutableFlag<Boolean> getConnected()
           
 Set<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId> getConnectedAllBots()
          Returns set of all bots connected to the same TC server.
 Set<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId> getConnectedChannelBots(int channelId)
          Returns set of bots connected to the channel of 'channelId' of the same TC server.
 Set<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId> getConnectedTeamBots()
          Returns set of bots of the same team connected to the same TC server.
 cz.cuni.amis.utils.flag.ImmutableFlag<Boolean> getConnecting()
           
 String getHost()
           
 int getPort()
           
 TCTeam getTeam()
          Returns details about bots/channels connected to the team.
 cz.cuni.amis.pogamut.base.communication.worldview.IWorldView getWorldView()
          WorldView used by this TCMinaClient.
 boolean isChannelExist(int channelId)
           
 boolean isConnected(Player bot)
           
 boolean isConnected(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId)
           
 boolean isConnectedToChannel(Player bot, int channelId)
           
 boolean isConnectedToChannel(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId, int channelId)
           
 boolean isConnectedToMyTeam(Player bot)
           
 boolean isConnectedToMyTeam(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId)
           
 void messageReceived(org.apache.mina.core.session.IoSession session, Object message)
           
 void messageSent(org.apache.mina.core.session.IoSession session, Object message)
           
 TCMinaClient.RequestFuture<TCInfoTeamChannelCreated> requestCreateChannel()
          Request to create a new channel, the channel will gets channelId assigned by TCMinaServer.
 TCMinaClient.RequestFuture<TCInfoTeamChannelDestroyed> requestDestroyChannel(int channelId)
          Request to destroy an existing channel.
 TCMinaClient.RequestFuture<TCInfoStatus> requestGetStatus()
          Request TCInfoStatus update from TCMinaServer.
 TCMinaClient.RequestFuture<TCInfoTeamChannelBotJoined> requestJoinChannel(int channelId)
          Request to join an existing channel.
 TCMinaClient.RequestFuture<TCInfoTeamChannelBotLeft> requestLeaveChannel(int channelId)
          Request to leave an existing channel.
 boolean sendPrivate(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId targetBotId, cz.cuni.amis.utils.token.IToken messageType, Serializable data)
           
 boolean sendToAll(cz.cuni.amis.utils.token.IToken messageType, Serializable data)
          Sends message to ALL connected bots (not just to your team).
 boolean sendToChannel(int channelId, cz.cuni.amis.utils.token.IToken messageType, Serializable data)
           
 boolean sendToTeam(cz.cuni.amis.utils.token.IToken messageType, Serializable data)
          Sends message to connected bots of YOUR TEAM (not to all bots connected to the TC server).
 void sessionClosed(org.apache.mina.core.session.IoSession session)
           
 void sessionCreated(org.apache.mina.core.session.IoSession session)
           
 void sessionIdle(org.apache.mina.core.session.IoSession session, org.apache.mina.core.session.IdleStatus status)
           
 void sessionOpened(org.apache.mina.core.session.IoSession session)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCMinaClient

public TCMinaClient(UT2004TCClient owner,
                    InetSocketAddress connectToAddress,
                    cz.cuni.amis.pogamut.base.communication.worldview.IWorldView teamWorldView,
                    Logger log)
Method Detail

getHost

public String getHost()

getPort

public int getPort()

getWorldView

public cz.cuni.amis.pogamut.base.communication.worldview.IWorldView getWorldView()
WorldView used by this TCMinaClient. We're auto-propagating incoming messages to this.

Returns:

getConnected

public cz.cuni.amis.utils.flag.ImmutableFlag<Boolean> getConnected()

getConnecting

public cz.cuni.amis.utils.flag.ImmutableFlag<Boolean> getConnecting()

connect

public void connect()

isConnected

public boolean isConnected(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId)

isConnected

public boolean isConnected(Player bot)

isConnectedToMyTeam

public boolean isConnectedToMyTeam(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId)

isConnectedToMyTeam

public boolean isConnectedToMyTeam(Player bot)

isConnectedToChannel

public boolean isConnectedToChannel(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId,
                                    int channelId)

isConnectedToChannel

public boolean isConnectedToChannel(Player bot,
                                    int channelId)

isChannelExist

public boolean isChannelExist(int channelId)

getConnectedAllBots

public Set<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId> getConnectedAllBots()
Returns set of all bots connected to the same TC server.

Returns:
READ-ONLY!

getConnectedTeamBots

public Set<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId> getConnectedTeamBots()
Returns set of bots of the same team connected to the same TC server.

Returns:
READ-ONLY!

getConnectedChannelBots

public Set<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId> getConnectedChannelBots(int channelId)
Returns set of bots connected to the channel of 'channelId' of the same TC server.

Returns:
READ-ONLY!

getTeam

public TCTeam getTeam()
Returns details about bots/channels connected to the team. Returns NULL if not connected!

Returns:
READ-ONLY!

getChannel

public TCChannel getChannel(int channelId)
Returns details about bots/channels connected to the team. Returns NULL if not connected or non-existing channel!

Returns:
READ-ONLY!

requestCreateChannel

public TCMinaClient.RequestFuture<TCInfoTeamChannelCreated> requestCreateChannel()
Request to create a new channel, the channel will gets channelId assigned by TCMinaServer. When created, you will be automatically added to it as its creator.

Returns:

requestDestroyChannel

public TCMinaClient.RequestFuture<TCInfoTeamChannelDestroyed> requestDestroyChannel(int channelId)
Request to destroy an existing channel. Note that you must be channel's creator in able to do this!

Parameters:
channelId -
Returns:

requestGetStatus

public TCMinaClient.RequestFuture<TCInfoStatus> requestGetStatus()
Request TCInfoStatus update from TCMinaServer.

Returns:
request future or NULL if not connected

requestJoinChannel

public TCMinaClient.RequestFuture<TCInfoTeamChannelBotJoined> requestJoinChannel(int channelId)
Request to join an existing channel.

Parameters:
channelId -
Returns:

requestLeaveChannel

public TCMinaClient.RequestFuture<TCInfoTeamChannelBotLeft> requestLeaveChannel(int channelId)
Request to leave an existing channel. Leaving a channel you have created will NOT destroy it.

Parameters:
channelId -
Returns:

sendToAll

public boolean sendToAll(cz.cuni.amis.utils.token.IToken messageType,
                         Serializable data)
Sends message to ALL connected bots (not just to your team).

Parameters:
messageType - CANNOT BE NULL
data - may be null
Returns:

sendToTeam

public boolean sendToTeam(cz.cuni.amis.utils.token.IToken messageType,
                          Serializable data)
Sends message to connected bots of YOUR TEAM (not to all bots connected to the TC server).

Parameters:
messageType - CANNOT BE NULL
data - may be null
Returns:

sendToChannel

public boolean sendToChannel(int channelId,
                             cz.cuni.amis.utils.token.IToken messageType,
                             Serializable data)

sendPrivate

public boolean sendPrivate(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId targetBotId,
                           cz.cuni.amis.utils.token.IToken messageType,
                           Serializable data)

connected

protected void connected(org.apache.mina.core.future.ConnectFuture event)

exceptionCaught

public void exceptionCaught(org.apache.mina.core.session.IoSession session,
                            Throwable exception)
                     throws Exception
Specified by:
exceptionCaught in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

messageReceived

public void messageReceived(org.apache.mina.core.session.IoSession session,
                            Object message)
                     throws Exception
Specified by:
messageReceived in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

messageSent

public void messageSent(org.apache.mina.core.session.IoSession session,
                        Object message)
                 throws Exception
Specified by:
messageSent in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

sessionClosed

public void sessionClosed(org.apache.mina.core.session.IoSession session)
                   throws Exception
Specified by:
sessionClosed in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

sessionCreated

public void sessionCreated(org.apache.mina.core.session.IoSession session)
                    throws Exception
Specified by:
sessionCreated in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

sessionIdle

public void sessionIdle(org.apache.mina.core.session.IoSession session,
                        org.apache.mina.core.session.IdleStatus status)
                 throws Exception
Specified by:
sessionIdle in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

sessionOpened

public void sessionOpened(org.apache.mina.core.session.IoSession session)
                   throws Exception
Specified by:
sessionOpened in interface org.apache.mina.core.service.IoHandler
Throws:
Exception

stop

public void stop()


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.