mirror of
https://github.com/ProjectSWGCore/client-holocore.git
synced 2026-01-16 22:04:23 -05:00
Added better error handling and updated dependencies
This commit is contained in:
@@ -2,8 +2,8 @@ plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 9
|
||||
targetCompatibility = 9
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
@@ -14,6 +14,3 @@ dependencies {
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = "4.7"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.holo.HoloConnectionStarted;
|
||||
import com.projectswg.common.network.packets.swg.holo.HoloConnectionStopped;
|
||||
import com.projectswg.common.network.packets.swg.holo.HoloSetProtocolVersion;
|
||||
import com.projectswg.connection.packets.RawPacket;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import me.joshlarson.jlcommon.network.TCPSocket;
|
||||
import me.joshlarson.jlcommon.network.TCPSocket.TCPSocketCallback;
|
||||
@@ -125,6 +124,14 @@ public class HolocoreSocket {
|
||||
* @return the server status as a string
|
||||
*/
|
||||
public String getServerStatus(long timeout) {
|
||||
Log.t("Requesting server status from %s", address);
|
||||
if (!udpServer.isRunning()) {
|
||||
try {
|
||||
udpServer.bind();
|
||||
} catch (SocketException e) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
udpServer.send(address, new byte[]{1});
|
||||
try {
|
||||
DatagramPacket packet = udpInboundQueue.poll(timeout, TimeUnit.MILLISECONDS);
|
||||
@@ -301,7 +308,7 @@ public class HolocoreSocket {
|
||||
|
||||
private UDPServer createUDPServer() {
|
||||
try {
|
||||
UDPServer server = new UDPServer(new InetSocketAddress(0), 1500, udpInboundQueue::offer);
|
||||
UDPServer server = new UDPServer(new InetSocketAddress(0), 1500, udpInboundQueue::add);
|
||||
server.bind();
|
||||
return server;
|
||||
} catch (SocketException e) {
|
||||
|
||||
41
src/main/java/com/projectswg/connection/RawPacket.java
Normal file
41
src/main/java/com/projectswg/connection/RawPacket.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (C) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* This file is part of the ProjectSWG Launcher. *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***********************************************************************************/
|
||||
|
||||
package com.projectswg.connection;
|
||||
|
||||
public class RawPacket {
|
||||
|
||||
private final int crc;
|
||||
private final byte[] data;
|
||||
|
||||
public RawPacket(int crc, byte[] data) {
|
||||
this.crc = crc;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCrc() {
|
||||
return crc;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.projectswg.connection;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.connection.packets.RawPacket;
|
||||
|
||||
class SWGProtocol {
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.projectswg.connection.packets;
|
||||
|
||||
public class RawPacket {
|
||||
|
||||
private final int crc;
|
||||
private final byte[] data;
|
||||
|
||||
public RawPacket(int crc, byte[] data) {
|
||||
this.crc = crc;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCrc() {
|
||||
return crc;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user