我正在使用本教程构建一个没有可写部分的java nio服务器.
一切都很好,除了一个有趣的事情:
任何的想法?
我正在添加服务器类代码,如果你需要在下面的代码中提到的另一个类,我在这里:).
NIOServer类:
package server;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
import java.util.*;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
public class NioServer implements Runnable {
// The host:port combination to listen on
private InetAddress hostAddress;
private int port;
// The channel on which we'll accept connections
private ServerSocketChannel serverChannel;
// The selector we'll be monitoring
private Selector selector;
//the cach will …Run Code Online (Sandbox Code Playgroud) 试图在模拟器上运行 - 工作.试图在ios 5.1上运行 - 工作.
任何的想法?
我需要通知中心的所有通知都会出现,并且在我的应用中,只有从后台收到的通知或应用程序关闭时才会在通知中心显示.那是我的问题吗?如何从代码中向通知中心添加通知?
谢谢!