Mekanism-tilera-Edition/common/mekanism/client/ClientConnectionHandler.java

65 lines
1.7 KiB
Java
Raw Normal View History

package mekanism.client;
2013-10-14 20:08:15 +02:00
import java.net.InetAddress;
import java.net.Socket;
import mekanism.client.voice.VoiceClient;
import mekanism.common.Mekanism;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClientConnectionHandler implements IConnectionHandler
{
2013-10-24 23:14:09 +02:00
public VoiceClient voiceClient;
2013-10-14 20:08:15 +02:00
@Override
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {}
@Override
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
{
return null;
}
@Override
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager)
{
2013-10-24 23:14:09 +02:00
try {
voiceClient = new VoiceClient(server, 36123);
voiceClient.run();
} catch(Exception e) {}
}
@Override
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager)
{
2013-10-14 20:08:15 +02:00
try {
2013-10-24 23:14:09 +02:00
voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), 36123);
voiceClient.run();
2013-10-14 20:08:15 +02:00
} catch(Exception e) {}
}
@Override
public void connectionClosed(INetworkManager manager)
{
2013-10-27 04:23:11 +01:00
if(voiceClient != null)
{
voiceClient.disconnect();
voiceClient = null;
}
Mekanism.proxy.unloadSoundHandler();
}
@Override
2013-10-14 20:08:15 +02:00
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {}
}