diff --git a/ListHead.java b/ListHead.java new file mode 100644 index 0000000..bbee752 --- /dev/null +++ b/ListHead.java @@ -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; + } +} diff --git a/SysUtils.java b/SysUtils.java index 69f165a..a6a283b 100644 --- a/SysUtils.java +++ b/SysUtils.java @@ -2,4 +2,7 @@ package a6; public class SysUtils { + public static void test() { + System.out.println("test"); + } } diff --git a/TcpListener.java b/TcpListener.java new file mode 100644 index 0000000..9dce277 --- /dev/null +++ b/TcpListener.java @@ -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() { + @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() { + + } + +} diff --git a/Timer.java b/Timer.java new file mode 100644 index 0000000..fb7b79f --- /dev/null +++ b/Timer.java @@ -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; + } + +} diff --git a/TimerAttacher.java b/TimerAttacher.java new file mode 100644 index 0000000..568ab39 --- /dev/null +++ b/TimerAttacher.java @@ -0,0 +1,13 @@ +package a6; + +public class TimerAttacher { + + public void clearTimer() { + + } + + public void free() { + clearTimer(); + } + +} diff --git a/XParams.java b/XParams.java new file mode 100644 index 0000000..127f912 --- /dev/null +++ b/XParams.java @@ -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(); + } + +} diff --git a/XValue.java b/XValue.java new file mode 100644 index 0000000..c9ba5cd --- /dev/null +++ b/XValue.java @@ -0,0 +1,5 @@ +package a6; + +public class XValue { + +}