Examples of HandshakeMessage


Examples of ch.ethz.inf.vs.scandium.dtls.HandshakeMessage

             * a HelloRequest (from server) or a ClientHello
             * (from client) => initialize appropriate
             * handshaker type
             */

            HandshakeMessage handshake = (HandshakeMessage) record.getFragment();

            switch (handshake.getMessageType()) {
            case HELLO_REQUEST:
              /*
               * Client side: server desires a re-handshake
               */
              if (session == null) {
                // create new session
                session = new DTLSSession(peerAddress, true);
                // store session according to peer address
                dtlsSessions.put(addressToKey(peerAddress), session);

                LOGGER.info("Created new session as client with peer: " + peerAddress.toString());
              }
              handshaker = new ClientHandshaker(peerAddress, null, session);
              handshakers.put(addressToKey(peerAddress), handshaker);
              LOGGER.finest("Stored re-handshaker: " + handshaker.toString() + " for " + peerAddress.toString());
              break;

            case CLIENT_HELLO:
              /*
               * Server side: server received a client hello:
               * check first if client wants to resume a
               * session (message must contain session
               * identifier) and then check if particular
               * session still available, otherwise conduct
               * full handshake with fresh session.
               */

              if (!(handshake instanceof FragmentedHandshakeMessage)) {
                // check if session identifier set
                ClientHello clientHello = (ClientHello) handshake;
                session = getSessionByIdentifier(clientHello.getSessionId().getSessionId());
              }
             
              if (session == null) {
                // create new session
                session = new DTLSSession(peerAddress, false);
                // store session according to peer address
                dtlsSessions.put(addressToKey(peerAddress), session);

                LOGGER.info("Created new session as server with peer: " + peerAddress.toString());
                handshaker = new ServerHandshaker(peerAddress, session);
              } else {
                handshaker = new ResumingServerHandshaker(peerAddress, session);
              }
              handshakers.put(addressToKey(peerAddress), handshaker);
              LOGGER.finest("Stored handshaker: " + handshaker.toString() + " for " + peerAddress.toString());
              break;

            default:
              LOGGER.severe("Received unexpected first handshake message (type="+handshake.getMessageType()+") from " + peerAddress.toString() + ":\n" + handshake.toString());
              break;
            }
          }
          flight = handshaker.processMessage(record);
          break;
View Full Code Here

Examples of com.corundumstudio.socketio.store.pubsub.HandshakeMessage

                jsonpParam = jsonpParams.get(0);
            }
            channel.write(new AuthorizeMessage(msg, jsonpParam, origin, sessionId));

            handshake(sessionId);
            HandshakeMessage message = new HandshakeMessage(sessionId);
            configuration.getStoreFactory().getPubSubStore().publish(PubSubStore.HANDSHAKE, message);
            log.debug("Handshake authorized for sessionId: {}", sessionId);
        } else {
            HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.FORBIDDEN);
            ChannelFuture f = channel.write(res);
View Full Code Here

Examples of com.torrent4j.net.peerwire.messages.HandshakeMessage

    if (!(msg instanceof ChannelBuffer))
      return msg;
    final ChannelBuffer buffer = (ChannelBuffer) msg;

    if (!handshaked) {
      final HandshakeMessage message = new HandshakeMessage();
      message.read(buffer);

      return message;
    } else {
      if(buffer.readableBytes() == 0)
        return new KeepAliveMessage();
     
      final byte opcode = buffer.readByte();
      final PeerWireMessage message;
      switch (opcode) {
      case CancelMessage.MESSAGE_ID:
        message = new CancelMessage();
        break;
      case BitFieldMessage.MESSAGE_ID:
        message = new BitFieldMessage();
        break;
      case ChokeMessage.MESSAGE_ID:
        message = new ChokeMessage();
        break;
      case HaveMessage.MESSAGE_ID:
        message = new HaveMessage();
        break;
      case InterestedMessage.MESSAGE_ID:
        message = new InterestedMessage();
        break;
      case NotInterestedMessage.MESSAGE_ID:
        message = new NotInterestedMessage();
        break;
      case BlockMessage.MESSAGE_ID:
        message = new BlockMessage();
        break;
      case PortMessage.MESSAGE_ID:
        message = new PortMessage();
        break;
      case RequestMessage.MESSAGE_ID:
        message = new RequestMessage();
        break;
      case UnchokeMessage.MESSAGE_ID:
        message = new UnchokeMessage();
        break;
      default:
        return null;
      }
      message.read(buffer);
      return message;
    }
  }
View Full Code Here

Examples of com.torrent4j.net.peerwire.messages.HandshakeMessage

    return channel.disconnect().awaitUninterruptibly().isSuccess();
  }

  @Override
  public void handshake(byte[] torrentHash, String peerID) {
    write(new HandshakeMessage(torrentHash, peerID));
  }
View Full Code Here

Examples of com.torrent4j.net.peerwire.messages.HandshakeMessage

    try {
      final Object msg = e.getMessage();
      if (!(msg instanceof PeerWireMessage))
        return;
      if (msg instanceof HandshakeMessage) {
        final HandshakeMessage message = (HandshakeMessage) msg;

        ((PeerWireFrameDecoder) e.getChannel().getPipeline()
            .get("frame-decoder")).setHandshaked(true);
        ((PeerWireMessageDecoder) e.getChannel().getPipeline()
            .get("message-decoder")).setHandshaked(true);
View Full Code Here

Examples of com.wordnik.swaggersocket.protocol.HandshakeMessage

                String message = data.substring(0, 20).replaceAll(" ", "");
                logger.debug(data);
                if (message.startsWith("{\"handshake\"")) {
                    // This will fail if the message is not well formed.
                    HandshakeMessage handshakeMessage = mapper.readValue(data, HandshakeMessage.class);

                    // If we missed the CloseReason for whatever reason (IE is a good candidate), make sure we swap the previous session anyway.
                    String identity = (String) getContextValue(request, IDENTITY);
                    if (identity == null) {
                        identity = UUID.randomUUID().toString();
View Full Code Here

Examples of net.glowstone.net.message.handshake.HandshakeMessage

        final int version = ByteBufUtils.readVarInt(buffer);
        final String address = ByteBufUtils.readUTF8(buffer);
        final int port = buffer.readUnsignedShort();
        final int state = ByteBufUtils.readVarInt(buffer);

        return new HandshakeMessage(version, address, port, state);
    }
View Full Code Here

Examples of net.lightstone.msg.HandshakeMessage

  @Override
  public void handle(Session session, Player player, HandshakeMessage message) {
    Session.State state = session.getState();
    if (state == Session.State.EXCHANGE_HANDSHAKE) {
      session.setState(State.EXCHANGE_IDENTIFICATION);
      session.send(new HandshakeMessage("-"));
    } else {
      session.disconnect("Handshake already exchanged.");
    }
  }
View Full Code Here

Examples of net.lightstone.msg.HandshakeMessage

  }

  @Override
  public HandshakeMessage decode(ChannelBuffer buffer) {
    String identifier = ChannelBufferUtils.readString(buffer);
    return new HandshakeMessage(identifier);
  }
View Full Code Here

Examples of org.graphlab.net.netty.messages.HandshakeMessage

        }

        public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) {
            System.out.println("Channel connected!" + e.getChannel());
            try {
                e.getChannel().write(new HandshakeMessage(99, InetAddress.getLocalHost().getHostName(), 245));
            } catch (Exception err) {
                err.printStackTrace();
            }
        }
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.