重写了ACUCheckReq封包的处理,相当于对自动踢人有了一定的处理能力,但是具体情况还需测试。
This commit is contained in:
parent
2007572632
commit
9a2d7d9cb7
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,7 +6,21 @@ public class GmsvServer {
|
|||||||
private String ServerName = "";
|
private String ServerName = "";
|
||||||
private int ServerID = 0;
|
private int ServerID = 0;
|
||||||
private ArrayList<Player> players = null;
|
private ArrayList<Player> players = null;
|
||||||
|
private String serverIP = "";
|
||||||
|
private String serverPort = "";
|
||||||
|
|
||||||
|
public String getServerIP() {
|
||||||
|
return serverIP;
|
||||||
|
}
|
||||||
|
public void setServerIP(String serverIP) {
|
||||||
|
this.serverIP = serverIP;
|
||||||
|
}
|
||||||
|
public String getServerPort() {
|
||||||
|
return serverPort;
|
||||||
|
}
|
||||||
|
public void setServerPort(String serverPort) {
|
||||||
|
this.serverPort = serverPort;
|
||||||
|
}
|
||||||
public GmsvServer()
|
public GmsvServer()
|
||||||
{
|
{
|
||||||
players = new ArrayList<Player>();
|
players = new ArrayList<Player>();
|
||||||
@ -94,4 +108,5 @@ public class GmsvServer {
|
|||||||
players.remove(p);
|
players.remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
public class MultiThreadServer {
|
public class MultiThreadServer {
|
||||||
private final int port = 9650;
|
private final int port = 9651;
|
||||||
private final ServerSocket serverSocket;
|
private final ServerSocket serverSocket;
|
||||||
private final ExecutorService executorService;// 线程池
|
private final ExecutorService executorService;// 线程池
|
||||||
private final int POOL_SIZE = 5;// 单个CPU线程池大小
|
private final int POOL_SIZE = 5;// 单个CPU线程池大小
|
||||||
@ -85,6 +85,8 @@ class Handler implements Runnable {
|
|||||||
|
|
||||||
public String[] echo(final String msg) {
|
public String[] echo(final String msg) {
|
||||||
String []ret = null;
|
String []ret = null;
|
||||||
|
String myIP = socket.getInetAddress().toString();
|
||||||
|
String myPort = Integer.toString(socket.getPort());
|
||||||
if(msg!=null)
|
if(msg!=null)
|
||||||
{
|
{
|
||||||
String[] packet = msg.split(" ");
|
String[] packet = msg.split(" ");
|
||||||
@ -97,10 +99,12 @@ class Handler implements Runnable {
|
|||||||
GmsvServer gs = new GmsvServer();
|
GmsvServer gs = new GmsvServer();
|
||||||
gs.setServerName(packet[1]);
|
gs.setServerName(packet[1]);
|
||||||
gs.setServerID(Integer.parseInt(packet[3]));
|
gs.setServerID(Integer.parseInt(packet[3]));
|
||||||
|
gs.setServerIP(myIP);
|
||||||
|
gs.setServerPort(myPort);
|
||||||
sl.addNewServer(gs);
|
sl.addNewServer(gs);
|
||||||
ret = new String[1];
|
ret = new String[1];
|
||||||
ret[0] = "ACServerLogin successful";
|
ret[0] = "ACServerLogin successful";
|
||||||
System.out.println("Authed Server [" +packet[3] + " : " + packet[1] + "] connected... From "+socket.getInetAddress().toString() + ":" + socket.getPort() + ".");
|
System.out.println("Authed Server [" +packet[3] + " : " + packet[1] + "] connected... From "+myIP + ":" + myPort + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(packet[0].equalsIgnoreCase("ACServerLogout") )
|
else if(packet[0].equalsIgnoreCase("ACServerLogout") )
|
||||||
@ -185,14 +189,16 @@ class Handler implements Runnable {
|
|||||||
}
|
}
|
||||||
else if(packet[0].equalsIgnoreCase("ACUCheckReq"))//自动踢人
|
else if(packet[0].equalsIgnoreCase("ACUCheckReq"))//自动踢人
|
||||||
{
|
{
|
||||||
/*int RegNumber = Tools.SixtyTwoScale(packet[1]);
|
int RegNumber = Tools.SixtyTwoScale(packet[1]);
|
||||||
String cdkey = packet[2];
|
String cdkey = packet[2];
|
||||||
if(sl.hasCdKeyPlayer(cdkey)>0 )
|
GmsvServer gs = sl.getServerFromIP(myIP, myPort);
|
||||||
|
//System.out.println("ACUCheckReq "+RegNumber+" " + cdkey);
|
||||||
|
if(gs.findPlayer(cdkey, RegNumber)!=null && gs.findPlayer(cdkey, RegNumber).getOnline()==1)
|
||||||
{
|
{
|
||||||
|
//System.out.println("ACUCheckReq sent");
|
||||||
|
ret = new String[1];
|
||||||
|
ret[0] = "ACUCheck " + cdkey;
|
||||||
}
|
}
|
||||||
ret = new String[1];
|
|
||||||
ret[0] = "ACUCheck " + cdkey;*/
|
|
||||||
}
|
}
|
||||||
else if(packet[0].equalsIgnoreCase("MessageFlush"))
|
else if(packet[0].equalsIgnoreCase("MessageFlush"))
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,20 @@ public class ServerList {
|
|||||||
return gs;
|
return gs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GmsvServer getServerFromIP(String ip,String p)
|
||||||
|
{
|
||||||
|
GmsvServer gs = null;
|
||||||
|
for(int i=0;i<servers.size();i++)
|
||||||
|
{
|
||||||
|
gs = servers.get(i);
|
||||||
|
if(gs!=null && gs.getServerIP().equalsIgnoreCase(ip) && gs.getServerPort().equalsIgnoreCase(p))
|
||||||
|
return gs;
|
||||||
|
else
|
||||||
|
gs = null;
|
||||||
|
}
|
||||||
|
return gs;
|
||||||
|
}
|
||||||
|
|
||||||
public int hasCdKeyPlayer(String cdkey)
|
public int hasCdKeyPlayer(String cdkey)
|
||||||
{
|
{
|
||||||
//System.out.println("Looking for "+ cdkey+ " rn: " + rn);
|
//System.out.println("Looking for "+ cdkey+ " rn: " + rn);
|
||||||
|
Loading…
Reference in New Issue
Block a user