private void onNetBegin(
                BeginFW begin)
            {
                final long sequence = begin.sequence();
                final long acknowledge = begin.acknowledge();
                final int maximum = begin.maximum();
                final long traceId = begin.traceId();
                final long authorization = begin.authorization();
                final long affinity = begin.affinity();
                assert acknowledge <= sequence;
                assert sequence >= replySeq;
                assert acknowledge <= replyAck;
                replySeq = sequence;
                replyAck = acknowledge;
                assert replyAck == replySeq;
                assert maximum == 0;
                boolean handshakeHashOK = false;
                final OctetsFW extension = begin.extension();
                if (extension.sizeof() != 0)
                {
                    // TODO: need lightweight approach (start)
                    final HttpBeginExFW httpBeginEx = extension.get(httpBeginExRO::wrap);
                    final Map<String, String> headers = new LinkedHashMap<>();
                    httpBeginEx.headers().forEach(header ->
                    {
                        final String name = header.name().asString();
                        final String value = header.value().asString();
                        headers.merge(name, value, (v1, v2) -> String.format("%s, %s", v1, v2));
                    });
                    final String status = headers.get(":status");
                    final String upgrade = headers.get("upgrade");
                    final String hash = headers.get("sec-websocket-accept");
                    final String protocol = headers.get("sec-websocket-protocol");
                    // TODO: need lightweight approach (end)
                    if (WEBSOCKET_STATUS.equals(status) &&
                        WEBSOCKET_UPGRADE.equals(upgrade) &&
                        Objects.equals(this.protocol, protocol))
                    {
                        sha1.reset();
                        sha1.update(key.getBytes(US_ASCII));
                        final byte[] digest = sha1.digest(HANDSHAKE_GUID);
                        final Encoder encoder = Base64.getEncoder();
                        final String handshakeHash = new String(encoder.encode(digest), US_ASCII);
                        handshakeHashOK = handshakeHash.equals(hash);
                    }
                }
                if (handshakeHashOK)
                {
                    doAppBegin(maximum, traceId, authorization, affinity);
                }
                else
                {
                    doAppReset(traceId, authorization);
                }
            }
private void onNetBegin(
                BeginFW begin)
            {
                final long sequence = begin.sequence();
                final long acknowledge = begin.acknowledge();
                final int maximum = begin.maximum();
                final long traceId = begin.traceId();
                final long authorization = begin.authorization();
                final long affinity = begin.affinity();
                assert acknowledge <= sequence;
                assert sequence >= replySeq;
                assert acknowledge <= replyAck;
                replySeq = sequence;
                replyAck = acknowledge;
                assert replyAck == replySeq;
                assert maximum == 0;
                boolean handshakeHashOK = false;
                final OctetsFW extension = begin.extension();
                if (extension.sizeof() != 0)
                {
                   
                    final HttpBeginExFW httpBeginEx = extension.get(httpBeginExRO::wrap);
                    final Map<String, String> headers = new LinkedHashMap<>();
                    httpBeginEx.headers().forEach(header ->
                    {
                        final String name = header.name().asString();
                        final String value = header.value().asString();
                        headers.merge(name, value, (v1, v2) -> String.format("%s, %s", v1, v2));
                    });
                    final String status = headers.get(":status");
                    final String upgrade = headers.get("upgrade");
                    final String hash = headers.get("sec-websocket-accept");
                    final String protocol = headers.get("sec-websocket-protocol");
                   
                    if (WEBSOCKET_STATUS.equals(status) &&
                        WEBSOCKET_UPGRADE.equals(upgrade) &&
                        Objects.equals(this.protocol, protocol))
                    {
                        sha1.reset();
                        sha1.update(key.getBytes(US_ASCII));
                        final byte[] digest = sha1.digest(HANDSHAKE_GUID);
                        final Encoder encoder = Base64.getEncoder();
                        final String handshakeHash = new String(encoder.encode(digest), US_ASCII);
                        handshakeHashOK = handshakeHash.equals(hash);
                    }
                }
                if (handshakeHashOK)
                {
                    doAppBegin(maximum, traceId, authorization, affinity);
                }
                else
                {
                    doAppReset(traceId, authorization);
                }
            }
private void onnetbegin( beginfw begin) { final long sequence = begin.sequence(); final long acknowledge = begin.acknowledge(); final int maximum = begin.maximum(); final long traceid = begin.traceid(); final long authorization = begin.authorization(); final long affinity = begin.affinity(); assert acknowledge <= sequence; assert sequence >= replyseq; assert acknowledge <= replyack; replyseq = sequence; replyack = acknowledge; assert replyack == replyseq; assert maximum == 0; boolean handshakehashok = false; final octetsfw extension = begin.extension(); if (extension.sizeof() != 0) { final httpbeginexfw httpbeginex = extension.get(httpbeginexro::wrap); final map<string, string> headers = new linkedhashmap<>(); httpbeginex.headers().foreach(header -> { final string name = header.name().asstring(); final string value = header.value().asstring(); headers.merge(name, value, (v1, v2) -> string.format("%s, %s", v1, v2)); }); final string status = headers.get(":status"); final string upgrade = headers.get("upgrade"); final string hash = headers.get("sec-websocket-accept"); final string protocol = headers.get("sec-websocket-protocol"); if (websocket_status.equals(status) && websocket_upgrade.equals(upgrade) && objects.equals(this.protocol, protocol)) { sha1.reset(); sha1.update(key.getbytes(us_ascii)); final byte[] digest = sha1.digest(handshake_guid); final encoder encoder = base64.getencoder(); final string handshakehash = new string(encoder.encode(digest), us_ascii); handshakehashok = handshakehash.equals(hash); } } if (handshakehashok) { doappbegin(maximum, traceid, authorization, affinity); } else { doappreset(traceid, authorization); } }