模块 mxlib.api

类 RemoteServer

    • 构造器详细资料

      • RemoteServer

        public RemoteServer​(@Nullable
                            @Nullable KeyPair rsa)
                     throws IOException
        Create a server with rsa encoded.
        参数:
        rsa - The rsa key.
        抛出:
        IOException - If cannot create a ServerSocketChannel and Selector
      • RemoteServer

        public RemoteServer​(@NotNull
                            @NotNull ServerSocketChannel server,
                            @NotNull
                            @NotNull Selector selector,
                            @Nullable
                            @Nullable KeyPair rsa)
        Create a server.
        参数:
        server - The Server Socket
        selector - The selector using
        rsa - The rsa key. 'null' to disable.
    • 方法详细资料

      • getSelector

        @Contract(pure=true)
        public Selector getSelector()
      • select

        public void select()
                    throws IOException
        Waiting for connected data and processing it

        Please execute this method in a new thread, or execute it in ExecutorService

        
         RemoteServer server = new RemoteServer();
         server.getServer().socket().bind(new InetSocketAddress(23333));
         new Thread(()->{
              while(server.isOpen()){
                  try{
                      server.select();
                  } catch (IOException ignore){}
              }
         }).start();
        抛出:
        IOException - IOException
      • isOpen

        public boolean isOpen()