Example #1
0
  private void sendOpen(final short channelMax, final int maxFrameSize) {
    Open open = new Open();

    open.setChannelMax(UnsignedShort.valueOf(DEFAULT_CHANNEL_MAX));
    open.setContainerId(_container.getId());
    open.setMaxFrameSize(getDesiredMaxFrameSize());
    open.setHostname(getRemoteHostname());

    send(CONNECTION_CONTROL_CHANNEL, open);
  }
Example #2
0
  public synchronized void receiveOpen(short channel, Open open) {

    _channelMax =
        open.getChannelMax() == null
            ? DEFAULT_CHANNEL_MAX
            : open.getChannelMax().shortValue() < DEFAULT_CHANNEL_MAX
                ? DEFAULT_CHANNEL_MAX
                : open.getChannelMax().shortValue();

    UnsignedInteger remoteDesiredMaxFrameSize =
        open.getMaxFrameSize() == null
            ? UnsignedInteger.valueOf(DEFAULT_MAX_FRAME)
            : open.getMaxFrameSize();

    _maxFrameSize =
        (remoteDesiredMaxFrameSize.compareTo(_desiredMaxFrameSize) < 0
                ? remoteDesiredMaxFrameSize
                : _desiredMaxFrameSize)
            .intValue();

    _remoteContainerId = open.getContainerId();

    if (open.getIdleTimeOut() != null) {
      _idleTimeout = open.getIdleTimeOut().longValue();
    }

    switch (_state) {
      case UNOPENED:
        sendOpen(_channelMax, _maxFrameSize);
      case AWAITING_OPEN:
        _state = ConnectionState.OPEN;
      default:
        // TODO bad stuff (connection already open)

    }
    /*if(_state == ConnectionState.AWAITING_OPEN)
            {
                _state = ConnectionState.OPEN;
            }
    */
  }