Examples of attachment()


Examples of com.cloud.utils.nio.Link.attachment()

                        // upgradeAgent(task.getLink(), data, e.getReason());
                    }
                } else if (type == Task.Type.CONNECT) {
                } else if (type == Task.Type.DISCONNECT) {
                    final Link link = task.getLink();
                    final AgentAttache attache = (AgentAttache) link.attachment();
                    if (attache != null) {
                        disconnectWithInvestigation(attache, Event.AgentDisconnected);
                    } else {
                        s_logger.info("Connection from " + link.getIpAddress() + " closed but no cleanup was done.");
                        link.close();
View Full Code Here

Examples of com.github.xgameenginee.buffer.GameUpBuffer.attachment()

            while ((c = msgQueue.poll()) != null) {
                short type = c.getShort();
                try {
                    GameHandler handler = GameHandlerManager.getInstance().getHandler(type);
                    if (handler != null) {
                        if (!handler.isSystem() && c.attachment() == null) // real upstream message
                            handler.process(c.getConnection(), c);
                        else if (handler.isSystem()) // the system message
                            handler.process(c.getConnection(), c);
                        else {
                            logger.error("error in upstream :" + type);
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

            while(keyItor.hasNext()) {
                SelectionKey key = keyItor.next();
                keyItor.remove();
                // The key indexes into the selector so you
                // can retrieve the socket that's ready for I/O
                Handler handler = (Handler) key.attachment();
                try {
                    handler.handle(key);
                } catch (CancelledKeyException cke) {
                    ;
                } catch (IOException ioe) {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

        SelectionKey selectionKey = iter.next();
        iter.remove();
        try {
          int ops = selectionKey.readyOps();
          if ((ops & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
            if (selectionKey.attachment() == tcp) {
              while (true) {
                Object object = tcp.readObject(this);
                if (object == null) break;
                if (!tcpRegistered) {
                  if (object instanceof RegisterTCP) {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

      for (Iterator<SelectionKey> iter = keys.iterator(); iter.hasNext();) {
        SelectionKey selectionKey = iter.next();
        iter.remove();
        try {
          int ops = selectionKey.readyOps();
          Connection fromConnection = (Connection)selectionKey.attachment();

          if (fromConnection != null) {
            // Must be a TCP read or write operation.
            if (udp != null && fromConnection.udpRemoteAddress == null) continue;
            if ((ops & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                    it.remove();

                    if (key.isAcceptable()) {
                        srv_sock=(ServerSocketChannel) key.channel();
                        // get server socket and attachment
                        src=(InetSocketAddress) key.attachment();
                        in_sock=srv_sock.accept(); // accept request
                        if (verbose)
                            log("Proxy.loop()", "accepted connection from " + toString(in_sock));
                        dest=(InetSocketAddress) mappings.get(src);
                        // find corresponding dest
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                        // validate the key
                        if ( !selKey.isValid() ) continue;

                        // at least our ConnectionAcceptor has created a client
                        // ConnectionHeader
                        clientInfo = (ConnectionHeader) selKey.attachment();

                        // first check read-availbility
                        if ( selKey.isReadable() )
                        {
                            // get the underlying socket channel
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

      for(Iterator<SelectionKey> i = selector.selectedKeys().iterator(); i.hasNext();) {
        SelectionKey sk = i.next();
        i.remove();

       
        IoSessionImpl session = (IoSessionImpl) sk.attachment();
       
        if(sk.isValid() == false) {
          try {
            session.closeNow0();
          } catch (IOException e) {}
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                // What kind of activity is it?
                if ((key.readyOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ)
                {
                    SocketChannel ch = (SocketChannel)key.channel();
                    java.net.Socket ss = (java.net.Socket)ch.socket();
                    Socket s = (Socket)key.attachment();
                    if (s != null)
                    {
//                        System.out.println(s + ": OnRead");
                        s.OnRead();
                        if (s.LineProtocol())
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                }
                if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT)
                {
                    ServerSocketChannel ch = (ServerSocketChannel)key.channel();
                    java.net.ServerSocket ss = (java.net.ServerSocket)ch.socket();
                    Socket s = (Socket)key.attachment();
                    if (s != null)
                    {
//                        System.out.println(s + ": OnRead(ACCEPT)");
                        s.OnRead(); // ListenSocket.OnRead will call OnAccept on new Socket
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.