use of com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory in project baseio by generallycloud.
the class TestBrowser method main.
public static void main(String[] args) throws Exception {
String queueName = "qName";
SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
ServerConfiguration configuration = new ServerConfiguration(8300);
SocketChannelContext context = new NioSocketChannelContext(configuration);
SocketChannelConnector connector = new SocketChannelConnector(context);
context.setIoEventHandleAdaptor(eventHandle);
context.setProtocolFactory(new ParamedProtobaseProtocolFactory());
context.addSessionEventListener(new LoggerSocketSEListener());
FixedSession session = new FixedSession(connector.connect());
session.login("admin", "admin100");
MessageBrowser browser = new DefaultMessageBrowser(session);
Message message = browser.browser(queueName);
System.out.println("message:" + message);
int size = browser.size();
System.out.println("size:" + size);
boolean isOnline = browser.isOnline(queueName);
System.out.println("isOnline:" + isOnline);
connector.close();
}
use of com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory in project baseio by generallycloud.
the class TestListener method main.
public static void main(String[] args) throws Exception {
SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
ServerConfiguration configuration = new ServerConfiguration(8300);
SocketChannelContext context = new NioSocketChannelContext(configuration);
SocketChannelConnector connector = new SocketChannelConnector(context);
context.setIoEventHandleAdaptor(eventHandle);
context.setProtocolFactory(new ParamedProtobaseProtocolFactory());
context.addSessionEventListener(new LoggerSocketSEListener());
FixedSession session = new FixedSession(connector.connect());
session.login("admin", "admin100");
MessageConsumer consumer = new DefaultMessageConsumer(session);
long old = System.currentTimeMillis();
consumer.receive(new OnMessage() {
@Override
public void onReceive(Message message) {
System.out.println(message);
}
});
System.out.println("Time:" + (System.currentTimeMillis() - old));
ThreadUtil.sleep(1500000);
CloseUtil.close(connector);
}
use of com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory in project baseio by generallycloud.
the class ProtobaseApplicationContextEnricher method enrich.
@Override
public void enrich(ApplicationContext context) {
SocketChannelContext channelContext = context.getChannelContext();
context.setServiceFilter(new FutureAcceptorServiceFilter());
// FIXME 重复的
Set<String> blackIPs = context.getBlackIPs();
if (blackIPs != null && !blackIPs.isEmpty()) {
channelContext.addSessionEventListener(new BlackIPFilter(blackIPs));
}
channelContext.addSessionEventListener(new LoggerSocketSEListener());
channelContext.setProtocolFactory(new ParamedProtobaseProtocolFactory());
channelContext.setBeatFutureFactory(new ParamedProtobaseBeatFutureFactory());
}
use of com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory in project baseio by generallycloud.
the class Test404 method main.
public static void main(String[] args) throws Exception {
String serviceKey = "22";
LoggerFactory.configure();
SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
ServerConfiguration configuration = new ServerConfiguration(8300);
SocketChannelContext context = new NioSocketChannelContext(configuration);
SocketChannelConnector connector = new SocketChannelConnector(context);
context.setIoEventHandleAdaptor(eventHandle);
context.setProtocolFactory(new ParamedProtobaseProtocolFactory());
context.addSessionEventListener(new LoggerSocketSEListener());
FixedSession session = new FixedSession(connector.connect());
ProtobaseFuture future = session.request(serviceKey, null);
System.out.println(future.getReadText());
Future future1 = new ProtobaseFutureImpl(connector.getContext()).setPING();
session.getSession().flush(future1);
CloseUtil.close(connector);
}
use of com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory in project baseio by generallycloud.
the class TestPublish method main.
public static void main(String[] args) throws Exception {
LoggerFactory.configure();
SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
ServerConfiguration configuration = new ServerConfiguration(8300);
SocketChannelContext context = new NioSocketChannelContext(configuration);
SocketChannelConnector connector = new SocketChannelConnector(context);
context.setIoEventHandleAdaptor(eventHandle);
context.setProtocolFactory(new ParamedProtobaseProtocolFactory());
context.addSessionEventListener(new LoggerSocketSEListener());
FixedSession session = new FixedSession(connector.connect());
session.login("admin", "admin100");
MessageProducer producer = new DefaultMessageProducer(session);
TextMessage message = new TextMessage("msgId", "qName", "你好!");
producer.publish(message);
connector.close();
}
Aggregations