net.jetrix.protocols
Class TetrinetProtocol
java.lang.Object
net.jetrix.protocols.TetrinetProtocol
- All Implemented Interfaces:
- Protocol
- Direct Known Subclasses:
- TetrifastProtocol, TspecProtocol
public class TetrinetProtocol
- extends Object
- implements Protocol
Protocol to communicate with TetriNET 1.13 compatible clients.
- Version:
- $Revision: 627 $, $Date: 2005-02-18 01:00:43 +0100 (ven., 18 févr. 2005) $
- Author:
- Emmanuel Bourg
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. |
static String |
readLine(Reader in)
Read a line as defined in the TetriNET protocol (that's ending with a
0xFF character). 0xOA and 0xOD are also accepted as EOL characters. |
String |
toString()
|
String |
translate(AddLineMessage m)
|
String |
translate(BlockBombMessage m)
|
String |
translate(BlockQuakeMessage m)
|
String |
translate(ClearLineMessage m)
|
String |
translate(ClearSpecialsMessage m)
|
String |
translate(EndGameMessage m)
|
String |
translate(FieldMessage m)
|
String |
translate(FourLinesAddedMessage 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(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(OneLineAddedMessage 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(TwoLinesAddedMessage m)
|
String |
translate(WinlistMessage m,
Locale locale)
|
TetrinetProtocol
public TetrinetProtocol()
getName
public String getName()
- Return the name of this protocol
- Specified by:
getName
in interface 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.
- Specified by:
getMessage
in interface 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.
- Specified by:
translate
in interface Protocol
- Parameters:
m
- the message to translatelocale
- 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(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(OneLineAddedMessage m)
translate
public String translate(TwoLinesAddedMessage m)
translate
public String translate(FourLinesAddedMessage 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(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.
- Specified by:
applyStyle
in interface Protocol
- Parameters:
text
- the string to transform
- Returns:
- the stylized representation of the specified string for
this protocol.
getEOL
public char getEOL()
- Description copied from interface:
Protocol
- Return the end of line character used by this protocol.
- Specified by:
getEOL
in interface 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 clientversion
- the version of the clientip
- the IP of the servertetrifast
- is this a tetrifast client ?
readLine
public static String readLine(Reader in)
throws IOException
- Read a line as defined in the TetriNET protocol (that's ending with a
0xFF character). 0xOA and 0xOD are also accepted as EOL characters.
- Parameters:
in
- the stream to be read
- Throws:
IOException
- thrown if the stream is closed- Since:
- 0.2.1
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2001-2008 Emmanuel Bourg. All Rights Reserved.