2013-10-14 04:50:21 +02:00
|
|
|
package mekanism.client;
|
|
|
|
|
|
|
|
import java.net.InetAddress;
|
|
|
|
import java.net.Socket;
|
2013-10-13 18:31:26 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2013-10-14 04:50:21 +02:00
|
|
|
public class VoiceClientManager implements IConnectionHandler
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
2013-10-14 04:50:21 +02:00
|
|
|
public Socket socket;
|
|
|
|
|
2013-10-13 18:31:26 +02:00
|
|
|
@Override
|
2013-10-14 04:50:21 +02:00
|
|
|
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
2013-10-14 04:50:21 +02:00
|
|
|
try {
|
|
|
|
socket = new Socket(manager.getSocketAddress().toString(), 36123);
|
|
|
|
} catch(Exception e) {}
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-14 04:50:21 +02:00
|
|
|
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager)
|
|
|
|
{
|
2013-10-14 04:50:21 +02:00
|
|
|
//connecting to foreign server
|
|
|
|
try {
|
|
|
|
socket = new Socket(server, 36123);
|
|
|
|
} catch(Exception e) {}
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager)
|
|
|
|
{
|
2013-10-14 04:50:21 +02:00
|
|
|
//connecting to LAN server on same instance
|
|
|
|
try {
|
|
|
|
socket = new Socket(InetAddress.getLocalHost().getHostAddress(), 36123);
|
|
|
|
} catch(Exception e) {}
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void connectionClosed(INetworkManager manager)
|
|
|
|
{
|
2013-10-14 04:50:21 +02:00
|
|
|
try {
|
|
|
|
socket.close();
|
|
|
|
socket = null;
|
|
|
|
} catch(Exception e) {}
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-14 04:50:21 +02:00
|
|
|
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login)
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
2013-10-14 04:50:21 +02:00
|
|
|
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
}
|