// Path: ws/src/main/java/org/kaazing/netx/ws/internal/ext/flyweight/Opcode.java
// public enum Opcode {
//     BINARY, CLOSE, CONTINUATION, PING, PONG, TEXT;
// 
//     public static Opcode fromInt(int value) {
//         switch (value) {
//         case 0x00:
//             return CONTINUATION;
//         case 0x01:
//             return TEXT;
//         case 0x02:
//             return BINARY;
//         case 0x08:
//             return CLOSE;
//         case 0x09:
//             return PING;
//         case 0x0A:
//             return PONG;
//         default:
//             throw new IllegalStateException(format("Unrecognized WebSocket OpCode %x", value));
//         }
//     };
// 
//     public static int toInt(Opcode value) {
//         switch (value) {
//         case CONTINUATION:
//             return 0x00;
//         case TEXT:
//             return 0x01;
//         case BINARY:
//             return 0x02;
//         case CLOSE:
//             return 0x08;
//         case PING:
//             return 0x09;
//         case PONG:
//             return 0x0A;
//         default:
//             throw new IllegalStateException(format("Unrecognised OpCode %s", value));
//         }
//     };
// }


import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import org.kaazing.netx.ws.internal.ext.WebSocketContext;
import org.kaazing.netx.ws.internal.ext.WebSocketExtensionSpi;
import org.kaazing.netx.ws.internal.ext.flyweight.Frame;
import org.kaazing.netx.ws.internal.ext.flyweight.FrameRW;
import org.kaazing.netx.ws.internal.ext.flyweight.Opcode;
import org.kaazing.netx.ws.internal.ext.function.WebSocketFrameConsumer;
/**
 * Copyright 2007-2015, Kaazing Corporation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kaazing.netx.ws.specification.ext.primary;



public class PrimaryExtensionSpi extends WebSocketExtensionSpi {
    private static final Charset UTF_8 = Charset.forName("UTF-8");

    private final FrameRW outgoingFrame = new FrameRW().wrap(ByteBuffer.allocate(1024), 0);
    private final FrameRW incomingFrame = new FrameRW().wrap(ByteBuffer.allocate(1024), 0);
    {
        onTextReceived = new WebSocketFrameConsumer() {

            @Override
            public void accept(WebSocketContext context, Frame frame) throws IOException {
// Path: ws/src/main/java/org/kaazing/netx/ws/internal/ext/flyweight/Opcode.java
// public enum Opcode {
//     BINARY, CLOSE, CONTINUATION, PING, PONG, TEXT;
// 
//     public static Opcode fromInt(int value) {
//         switch (value) {
//         case 0x00:
//             return CONTINUATION;
//         case 0x01:
//             return TEXT;
//         case 0x02:
//             return BINARY;
//         case 0x08:
//             return CLOSE;
//         case 0x09:
//             return PING;
//         case 0x0A:
//             return PONG;
//         default:
//             throw new IllegalStateException(format("Unrecognized WebSocket OpCode %x", value));
//         }
//     };
// 
//     public static int toInt(Opcode value) {
//         switch (value) {
//         case CONTINUATION:
//             return 0x00;
//         case TEXT:
//             return 0x01;
//         case BINARY:
//             return 0x02;
//         case CLOSE:
//             return 0x08;
//         case PING:
//             return 0x09;
//         case PONG:
//             return 0x0A;
//         default:
//             throw new IllegalStateException(format("Unrecognised OpCode %s", value));
//         }
//     };
// }


// Path: ws/src/test/java/org/kaazing/netx/ws/specification/ext/primary/PrimaryExtensionSpi.java
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import org.kaazing.netx.ws.internal.ext.WebSocketContext;
import org.kaazing.netx.ws.internal.ext.WebSocketExtensionSpi;
import org.kaazing.netx.ws.internal.ext.flyweight.Frame;
import org.kaazing.netx.ws.internal.ext.flyweight.FrameRW;
import org.kaazing.netx.ws.internal.ext.flyweight.Opcode;
import org.kaazing.netx.ws.internal.ext.function.WebSocketFrameConsumer;

/**
 * Copyright 2007-2015, Kaazing Corporation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kaazing.netx.ws.specification.ext.primary;



public class PrimaryExtensionSpi extends WebSocketExtensionSpi {
    private static final Charset UTF_8 = Charset.forName("UTF-8");

    private final FrameRW outgoingFrame = new FrameRW().wrap(ByteBuffer.allocate(1024), 0);
    private final FrameRW incomingFrame = new FrameRW().wrap(ByteBuffer.allocate(1024), 0);
    {
        onTextReceived = new WebSocketFrameConsumer() {

            @Override
            public void accept(WebSocketContext context, Frame frame) throws IOException {
                Opcode opcode = frame.opcode();