1
This commit is contained in:
parent
441e46da63
commit
83d48a38e7
23
ListHead.java
Normal file
23
ListHead.java
Normal file
@ -0,0 +1,23 @@
|
||||
package a6;
|
||||
|
||||
public class ListHead {
|
||||
|
||||
public ListHead next;
|
||||
public ListHead prev;
|
||||
|
||||
public void del() {
|
||||
|
||||
}
|
||||
|
||||
public void delInit() {
|
||||
|
||||
}
|
||||
|
||||
public void addTail(ListHead newNode) {
|
||||
|
||||
}
|
||||
|
||||
public boolean empty() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -2,4 +2,7 @@ package a6;
|
||||
|
||||
public class SysUtils {
|
||||
|
||||
public static void test() {
|
||||
System.out.println("test");
|
||||
}
|
||||
}
|
||||
|
66
TcpListener.java
Normal file
66
TcpListener.java
Normal file
@ -0,0 +1,66 @@
|
||||
package a6;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
|
||||
public class TcpListener {
|
||||
|
||||
public int bindPort = 0;
|
||||
public String bindAddress;
|
||||
|
||||
public void TcpListener(int max_client_cnt) {
|
||||
|
||||
}
|
||||
|
||||
public void open() {
|
||||
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
|
||||
try {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
b.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
// ch.pipeline().addLast(new DiscardServerHandler());
|
||||
}
|
||||
})
|
||||
.option(ChannelOption.SO_BACKLOG, 128)
|
||||
.childOption(ChannelOption.SO_KEEPALIVE, true);
|
||||
|
||||
ChannelFuture f = b.bind(this.bindPort).sync();
|
||||
f.channel().closeFuture().sync();
|
||||
|
||||
} catch(Exception e) {
|
||||
|
||||
} finally {
|
||||
workerGroup.shutdownGracefully();
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendClientMsg() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void broadcastMsg() {
|
||||
|
||||
}
|
||||
|
||||
}
|
80
Timer.java
Normal file
80
Timer.java
Normal file
@ -0,0 +1,80 @@
|
||||
package a6;
|
||||
|
||||
public class Timer {
|
||||
|
||||
public class TimerList
|
||||
{
|
||||
private ListHead entry = new ListHead();
|
||||
private ListHead attachEntry;
|
||||
private int timerType = 0;
|
||||
private int milli_seconds = 0;
|
||||
private long expires = 0;
|
||||
|
||||
private ITimerFunc timerFunc;
|
||||
private ITimerAfterFunc timerAfterFunc;
|
||||
private XParams param;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ITimerFunc
|
||||
{
|
||||
public void OnTimer(XParams param);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ITimerAfterFunc
|
||||
{
|
||||
public void OnTimerAfter(XParams param);
|
||||
}
|
||||
|
||||
private int freeTimerNum = 0;
|
||||
private ListHead freeTimer = new ListHead();
|
||||
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
public void unInit() {
|
||||
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
public TimerList addDeadLineTimer(int expire_time, XParams param, ITimerFunc timer_func) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TimerList addDeadLineTimer(int expire_time, XParams param, ITimerFunc timer_func,
|
||||
ITimerAfterFunc timer_after_func) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void modifyTimer(TimerList timer_list, int expire_time) {
|
||||
|
||||
}
|
||||
|
||||
public void deleteTimer(TimerList timer_list) {
|
||||
if (timer_list.timerAfterFunc != null) {
|
||||
timer_list.timerAfterFunc.OnTimerAfter(timer_list.param);
|
||||
}
|
||||
detachTimer(timer_list);
|
||||
if (timer_list.attachEntry != null && !timer_list.attachEntry.empty()) {
|
||||
timer_list.attachEntry.del();
|
||||
}
|
||||
addToFreeList(timer_list);
|
||||
}
|
||||
|
||||
public void detachTimer(TimerList timer_list) {
|
||||
if (timer_list.entry != null && !timer_list.entry.empty()) {
|
||||
timer_list.entry.delInit();
|
||||
}
|
||||
}
|
||||
|
||||
private void addToFreeList(TimerList timer_list) {
|
||||
freeTimer.addTail(timer_list.entry);
|
||||
++freeTimerNum;
|
||||
}
|
||||
|
||||
}
|
13
TimerAttacher.java
Normal file
13
TimerAttacher.java
Normal file
@ -0,0 +1,13 @@
|
||||
package a6;
|
||||
|
||||
public class TimerAttacher {
|
||||
|
||||
public void clearTimer() {
|
||||
|
||||
}
|
||||
|
||||
public void free() {
|
||||
clearTimer();
|
||||
}
|
||||
|
||||
}
|
14
XParams.java
Normal file
14
XParams.java
Normal file
@ -0,0 +1,14 @@
|
||||
package a6;
|
||||
|
||||
public class XParams {
|
||||
|
||||
public XValue sender = new XValue();
|
||||
public XValue param1 = new XValue();
|
||||
public XValue param2 = new XValue();
|
||||
public XValue param3 = new XValue();
|
||||
|
||||
public static XParams newXParams() {
|
||||
return new XParams();
|
||||
}
|
||||
|
||||
}
|
5
XValue.java
Normal file
5
XValue.java
Normal file
@ -0,0 +1,5 @@
|
||||
package a6;
|
||||
|
||||
public class XValue {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user