LAN is now functional
This commit is contained in:
parent
038ae4d325
commit
d47243a30f
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -392,7 +392,7 @@ window.initializeLANClient = (() => {
|
|||
}
|
||||
|
||||
sendPacketToServer(buffer) {
|
||||
if(this.dataChannel.readyState == "open") {
|
||||
if(this.dataChannel != null && this.dataChannel.readyState == "open") {
|
||||
this.dataChannel.send(buffer);
|
||||
}else {
|
||||
this.signalRemoteDisconnect(false);
|
||||
|
@ -681,7 +681,7 @@ window.initializeLANServer = (() => {
|
|||
sendPacketToRemoteClient(peerId, buffer) {
|
||||
var thePeer = this.peerList.get(peerId);
|
||||
if((typeof thePeer !== "undefined") && thePeer !== null) {
|
||||
if(thePeer.dataChannel.readyState == "open") {
|
||||
if(thePeer.dataChannel != null && thePeer.dataChannel.readyState == "open") {
|
||||
thePeer.dataChannel.send(buffer);
|
||||
}else {
|
||||
this.signalRemoteDisconnect(peerId);
|
||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.src.NetHandler;
|
|||
public class WorkerListenThread {
|
||||
/** Reference to the MinecraftServer object. */
|
||||
private final MinecraftServer mcServer;
|
||||
private final HashSet connections = new HashSet();
|
||||
private final HashMap<String, WorkerNetworkManager> channels = new HashMap();
|
||||
private final HashSet<NetHandler> connections = new HashSet<>();
|
||||
private final HashMap<String, WorkerNetworkManager> channels = new HashMap<>();
|
||||
|
||||
/** Whether the network listener object is listening. */
|
||||
public volatile boolean isListening = false;
|
||||
|
@ -33,8 +33,7 @@ public class WorkerListenThread {
|
|||
|
||||
public void stopListening() {
|
||||
this.isListening = false;
|
||||
List<String> names = new ArrayList();
|
||||
names.addAll(channels.keySet());
|
||||
List<String> names = new ArrayList<>(channels.keySet());
|
||||
for(int i = 0, l = names.size(); i < l; ++i) {
|
||||
closeChannel(names.get(i));
|
||||
}
|
||||
|
@ -66,8 +65,9 @@ public class WorkerListenThread {
|
|||
|
||||
private void deleteDeadConnections() {
|
||||
Iterator<NetHandler> itr = this.connections.iterator();
|
||||
while(itr.hasNext()) {
|
||||
if(((NetHandler)itr.next()).shouldBeRemoved()) {
|
||||
while (itr.hasNext()) {
|
||||
NetHandler handler = itr.next();
|
||||
if (handler.shouldBeRemoved()) {
|
||||
itr.remove();
|
||||
//System.out.println("[Client][REMOVEDEAD]");
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class WorkerListenThread {
|
|||
|
||||
deleteDeadConnections();
|
||||
|
||||
for (NetHandler var2 : (HashSet<NetHandler>)this.connections) {
|
||||
for (NetHandler var2 : this.connections) {
|
||||
var2.handlePackets();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ public class NetServerHandler extends NetHandler {
|
|||
private static int hashCounter = 0;
|
||||
|
||||
public NetServerHandler(MinecraftServer par1, INetworkManager par2, EntityPlayerMP par3) {
|
||||
this.hash = ++hashCounter;
|
||||
this.mcServer = par1;
|
||||
this.netManager = par2;
|
||||
this.playerEntity = par3;
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ServerConfigurationManager {
|
|||
this.playerLoggedIn(par2EntityPlayerMP);
|
||||
var7.setPlayerLocation(par2EntityPlayerMP.posX, par2EntityPlayerMP.posY, par2EntityPlayerMP.posZ,
|
||||
par2EntityPlayerMP.rotationYaw, par2EntityPlayerMP.rotationPitch);
|
||||
this.mcServer.getNetworkThread().addPlayer(var7);
|
||||
//this.mcServer.getNetworkThread().addPlayer(var7);
|
||||
var7.sendPacket(new Packet4UpdateTime(var5.getTotalWorldTime(), var5.getWorldTime()));
|
||||
|
||||
//if (this.mcServer.getTexturePack().length() > 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user