accept connect

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
protected void acceptConnection(SelectionKey key, MMOConnection<T> con)
{
ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
SocketChannel sc;
try
{
if((sc = ssc.accept()) != null)
{
while (true)
{
if(this.getAcceptFilter() == null || this.getAcceptFilter().accept(sc))
{
//configure
sc.configureBlocking(false);
sc.socket().setTrafficClass(0);
sc.socket().setTcpNoDelay(false);
sc.socket().setKeepAlive(false);
SelectionKey clientKey = sc.register(this.getSelector(), SelectionKey.OP_READ);
clientKey.attach(this.getClientFactory().create(new MMOConnection<T>(this, sc, clientKey)));
}
else
{
sc.socket().close();
}
}
}
else
{
System.out.println("Made in attack server for modifications divane." + con.getSocketChannel().socket().getInetAddress().getHostAddress());
}
}
catch (IOException e)
{
e.printStackTrace();
}
}