public static void main(String[] args) { MessageExecutor.register("123", new ScriptExecutor()); Client client = new Client("172.18.70.109", 10086); SelectorStrategy selectorStrategy = new SingleSelectorStrategy(2, 2); selectorStrategy.setHandleListen(new TestClientHybridDefaultHandleListener()); selectorStrategy.setBufferType(HybridLengthSplitChannelBuffer.class); client.setSelectorStrategy(selectorStrategy); client.start(); }
public static void main(String[] args) { MessageExecutor.register("123", new ScriptExecutor()); Server server = new Server(10086); SelectorStrategy selectorStrategy = new SingleSelectorStrategy(2, 2); selectorStrategy.setHandleListen(new TestServerFileDefaultHandleListener()); selectorStrategy.setBufferType(LengthSplitChannelBuffer.class); MessageContext messageContext = new MessageContext(); messageContext.setAlgorithm(new DefaultAlgorithmImpl()); EncoderAndDecoderFactory encoderAndDecoderFactory = new EncoderAndDecoderFactory(); encoderAndDecoderFactory.setEncoderAndDecoderType(ByteEncoderAndDecoderImpl.class); messageContext.setEncoderAndDecoderFactory(encoderAndDecoderFactory); messageContext.setMessageFormat(new MessageFormatBytesToBytes()); selectorStrategy.setMessageContext(messageContext); server.setSelectorStrategy(selectorStrategy); server.start(); }