package voxo.client.actions;
import java.io.IOException;
import java.math.BigInteger;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.EnumSet;
import voxo.client.controllers.ClientController;
import voxo.client.services.NetworkService;
import voxo.common.entities.Packet;
import voxo.common.enums.EnumPacket;
import voxo.common.enums.EnumVerbose;
import voxo.common.packets.RegisterPacket;
public class RegisterAction {
public RegisterAction(ClientController c, RegisterPacket p){
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
md.update(p.getPwd().getBytes(), 0, p.getPwd().length());
p.setPwd(new BigInteger(1, md.digest()).toString(16));
NetworkService.sendPacket(new Packet(EnumPacket.CLIENT_Register, p));
} catch (UnknownHostException e) {
c.getVerbose().addConsoleMsg(e, EnumSet.of(EnumVerbose.ToConsole, EnumVerbose.ToLog));
new ServerErrorAction(c);
} catch (IOException e) {
c.getVerbose().addConsoleMsg(e, EnumSet.of(EnumVerbose.ToConsole, EnumVerbose.ToLog));
new ServerErrorAction(c);
} catch (NoSuchAlgorithmException e) {
c.getVerbose().addConsoleMsg(e, EnumSet.of(EnumVerbose.ToConsole, EnumVerbose.ToLog));
new ServerErrorAction(c);
}
}
}