package it.gotoandplay.smartfoxclient.http;

/*
 * RawProtocolCodec class.
 * 
 * @version 1.0.0
 * 
 * @author The gotoAndPlay() Team<br>
 *         <a href="http://www.smartfoxserver.com">http://www.smartfoxserver.com</a><br>
 *         <a href="http://www.gotoandplay.it">http://www.gotoandplay.it</a><br>
 */
public class RawProtocolCodec implements IHttpProtocolCodec
{
    private static final int SESSION_ID_LEN = 32;

    public String encode(String sessionId, String message)
    {
        return ((sessionId == null ? "" : sessionId) + message);
    }

    public String decode(String message)
    {
        String decoded = null;

        // Decode the connect response
        if (message.charAt(0) == HttpConnection.HANDSHAKE_TOKEN)
        {
                decoded = message.substring(1, SESSION_ID_LEN + 1);
        }

        return decoded;
    }
}
