net.jetrix.protocols
Class TetrinetProtocol

java.lang.Object
  extended by net.jetrix.protocols.AbstractProtocol
      extended by net.jetrix.protocols.TetrinetProtocol
All Implemented Interfaces:
Protocol
Direct Known Subclasses:
TetrifastProtocol, TspecProtocol

public class TetrinetProtocol
extends AbstractProtocol

Protocol to communicate with TetriNET 1.13 compatible clients.

Version:
$Revision: 863 $, $Date: 2010-08-20 12:26:25 +0200 (ven., 20 août 2010) $
Author:
Emmanuel Bourg

Field Summary
static String INIT_TOKEN
          Initialization token
 
Constructor Summary
TetrinetProtocol()
           
 
Method Summary
 String applyStyle(String text)
          Transform the style tags (<blue>, <u>, etc...) contained in the specified string into the style codes of this protocol.
static String decode(String initString)
          Decodes TetriNET client initialization string
static String encode(String nickname, String version, byte[] ip, boolean tetrifast)
          Return the initialization string for the specified user.
 char getEOL()
          Return the end of line character used by this protocol.
 Message getMessage(String line)
          Parse the specified string and return the corresponding server message for this protocol.
 String getName()
          Return the name of this protocol
 Map<String,String> getStyles()
          Return the map of the color and style codes for this protocol.
 String stripStyle(String text)
          Removes the style tags from the specified text.
 String translate(AddLineMessage m)
           
 String translate(BlockBombMessage m)
           
 String translate(BlockQuakeMessage m)
           
 String translate(ClearLineMessage m)
           
 String translate(ClearSpecialsMessage m)
           
 String translate(ClientInfoMessage m)
           
 String translate(CommandMessage m)
           
 String translate(EndGameMessage m)
           
 String translate(FieldMessage m)
           
 String translate(GmsgMessage m, Locale locale)
           
 String translate(GravityMessage m)
           
 String translate(IngameMessage m)
           
 String translate(JoinMessage m, Locale locale)
           
 String translate(LeaveMessage m, Locale locale)
           
 String translate(LevelMessage m)
           
 String translate(LinesAddedMessage m)
           
 String translate(Message m, Locale locale)
          Translate the specified message into a string that will be sent to a client using this protocol.
 String translate(NewGameMessage m)
           
 String translate(NoConnectingMessage m)
           
 String translate(NoopMessage m)
           
 String translate(NukeFieldMessage m)
           
 String translate(PauseMessage m)
           
 String translate(PlayerLostMessage m)
           
 String translate(PlayerNumMessage m)
           
 String translate(PlayerWonMessage m)
           
 String translate(PlineActMessage m, Locale locale)
           
 String translate(PlineMessage m, Locale locale)
           
 String translate(RandomClearMessage m)
           
 String translate(ResumeMessage m)
           
 String translate(SmsgMessage m, Locale locale)
           
 String translate(SpecialMessage m)
           
 String translate(SpectatorListMessage m, Locale locale)
           
 String translate(StartGameMessage m)
           
 String translate(StopGameMessage m)
           
 String translate(SwitchFieldsMessage m)
           
 String translate(TeamMessage m)
           
 String translate(WinlistMessage m, Locale locale)
           
 
Methods inherited from class net.jetrix.protocols.AbstractProtocol
equals, hashCode, readFrame, readLine, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INIT_TOKEN

public static final String INIT_TOKEN
Initialization token

See Also:
Constant Field Values
Constructor Detail

TetrinetProtocol

public TetrinetProtocol()
Method Detail

getName

public String getName()
Return the name of this protocol

Returns:
the name of this protocol

getMessage

public Message getMessage(String line)
Parse the specified string and return the corresponding server message for this protocol.

Parameters:
line - the client message to parse
Returns:
the Message equivalent of the specified String or null if the protocol cannot understand the message.

translate

public String translate(Message m,
                        Locale locale)
Translate the specified message into a string that will be sent to a client using this protocol.

Parameters:
m - the message to translate
locale - the locale used for internationalized text messages
Returns:
the String equivalent in this protocol for the specified Message or null if it can't be translated.

translate

public String translate(SpecialMessage m)

translate

public String translate(PlineMessage m,
                        Locale locale)

translate

public String translate(PlineActMessage m,
                        Locale locale)

translate

public String translate(CommandMessage m)

translate

public String translate(TeamMessage m)

translate

public String translate(JoinMessage m,
                        Locale locale)

translate

public String translate(LeaveMessage m,
                        Locale locale)

translate

public String translate(PlayerNumMessage m)

translate

public String translate(StartGameMessage m)

translate

public String translate(StopGameMessage m)

translate

public String translate(NewGameMessage m)

translate

public String translate(EndGameMessage m)

translate

public String translate(PauseMessage m)

translate

public String translate(ResumeMessage m)

translate

public String translate(IngameMessage m)

translate

public String translate(GmsgMessage m,
                        Locale locale)

translate

public String translate(LevelMessage m)

translate

public String translate(FieldMessage m)

translate

public String translate(PlayerLostMessage m)

translate

public String translate(PlayerWonMessage m)

translate

public String translate(NoConnectingMessage m)

translate

public String translate(LinesAddedMessage m)

translate

public String translate(AddLineMessage m)

translate

public String translate(ClearLineMessage m)

translate

public String translate(NukeFieldMessage m)

translate

public String translate(RandomClearMessage m)

translate

public String translate(SwitchFieldsMessage m)

translate

public String translate(ClearSpecialsMessage m)

translate

public String translate(GravityMessage m)

translate

public String translate(BlockQuakeMessage m)

translate

public String translate(BlockBombMessage m)

translate

public String translate(SpectatorListMessage m,
                        Locale locale)

translate

public String translate(SmsgMessage m,
                        Locale locale)

translate

public String translate(WinlistMessage m,
                        Locale locale)

translate

public String translate(ClientInfoMessage m)

translate

public String translate(NoopMessage m)

getStyles

public Map<String,String> getStyles()
Return the map of the color and style codes for this protocol.


applyStyle

public String applyStyle(String text)
Description copied from interface: Protocol
Transform the style tags (<blue>, <u>, etc...) contained in the specified string into the style codes of this protocol.

Parameters:
text - the string to transform
Returns:
the stylized representation of the specified string for this protocol.

stripStyle

public String stripStyle(String text)
Removes the style tags from the specified text.


getEOL

public char getEOL()
Description copied from interface: Protocol
Return the end of line character used by this protocol.


decode

public static String decode(String initString)
Decodes TetriNET client initialization string

Parameters:
initString - initialization string
Returns:
decoded string
Throws:
IllegalArgumentException - thrown if the string can't be decoded

encode

public static String encode(String nickname,
                            String version,
                            byte[] ip,
                            boolean tetrifast)
Return the initialization string for the specified user.

Parameters:
nickname - the nickname of the client
version - the version of the client
ip - the IP of the server
tetrifast - is this a tetrifast client ?


Copyright © 2001-2010. All Rights Reserved.