本文整理汇总了Java中org.apache.mina.core.session.IoSessionConfig类的典型用法代码示例。如果您正苦于以下问题:Java IoSessionConfig类的具体用法?Java IoSessionConfig怎么用?Java IoSessionConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IoSessionConfig类属于org.apache.mina.core.session包,在下文中一共展示了IoSessionConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFrames
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
protected void testFrames ( final String resourceName, final Frame... expectedFrames ) throws Exception
{
final FrameDecoder decoder = new FrameDecoder ();
final MockProtocolDecoderOutput out = new MockProtocolDecoderOutput ();
final DummySession session = new DummySession ();
session.setTransportMetadata ( new DefaultTransportMetadata ( "eclipse.scada", "test", false, true, SocketAddress.class, IoSessionConfig.class, Object.class ) );
for ( final IoBuffer data : BufferLoader.loadBuffersFromResource ( FrameDecoderTest.class, resourceName ) )
{
System.out.println ( "Pushing data packet - " + data.getHexDump () );
decoder.decode ( session, data, out );
}
out.assertMessages ( expectedFrames );
}
示例2: serverStart
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
@Override
protected void serverStart() throws RemotingException {
acceptor = new NioSocketAcceptor(); //TCP Acceptor
// acceptor.getFilterChain().addFirst("logging", new MinaLoggingFilter());
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec())));
acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter());
acceptor.setHandler(new MinaHandler(this));
IoSessionConfig cfg = acceptor.getSessionConfig();
cfg.setReaderIdleTime(remotingServerConfig.getReaderIdleTimeSeconds());
cfg.setWriterIdleTime(remotingServerConfig.getWriterIdleTimeSeconds());
cfg.setBothIdleTime(remotingServerConfig.getServerChannelMaxIdleTimeSeconds());
bindAddress = new InetSocketAddress(remotingServerConfig.getListenPort());
try {
acceptor.bind(bindAddress);
} catch (IOException e) {
throw new RemotingException("Start Mina server error", e);
}
}
示例3: clientStart
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
@Override
protected void clientStart() throws RemotingException {
try {
connector = new NioSocketConnector(); //TCP Connector
// connector.getFilterChain().addFirst("logging", new MinaLoggingFilter());
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec())));
connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());
connector.setHandler(new MinaHandler(this));
IoSessionConfig cfg = connector.getSessionConfig();
cfg.setReaderIdleTime(remotingClientConfig.getReaderIdleTimeSeconds());
cfg.setWriterIdleTime(remotingClientConfig.getWriterIdleTimeSeconds());
cfg.setBothIdleTime(remotingClientConfig.getClientChannelMaxIdleTimeSeconds());
} catch (Exception e) {
throw new RemotingException("Mina Client start error", e);
}
}
示例4: handleHostQuit
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* Handles host's attempt to quit game
*/
public static void handleHostQuit(IoSession session, Packet pktIn, Queue<Packet> queue, Connection con) throws MGOException {
int uid = (Integer) session.getAttribute("userid");
//Update database
ResultSet rs = null;
PreparedStatement stmt = null;
try {
//Delete game, due to table relationship with players; players will be deleted automatically
stmt = con.prepareStatement("DELETE FROM games WHERE host_id=?");
stmt.setInt(1,uid);
stmt.executeUpdate();
} catch(SQLException e) {
//Fail silently, failing here causes problems
}
//Set idle time
IoSessionConfig ic= session.getConfig();
ic.setIdleTime(IdleStatus.READER_IDLE, 900); //10Minutes
//Send reply
queue.add(new Packet(0x4381,new byte[4]));
}
示例5: AbstractIoService
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* Constructor for {@link AbstractIoService}. You need to provide a default
* session configuration and an {@link Executor} for handling I/O events. If
* a null {@link Executor} is provided, a default one will be created using
* {@link Executors#newCachedThreadPool()}.
*
* @param sessionConfig
* the default configuration for the managed {@link IoSession}
* @param executor
* the {@link Executor} used for handling execution of I/O
* events. Can be <code>null</code>.
*/
protected AbstractIoService(IoSessionConfig sessionConfig, Executor executor) {
if (sessionConfig == null) {
throw new IllegalArgumentException("sessionConfig");
}
if (getTransportMetadata() == null) {
throw new IllegalArgumentException("TransportMetadata");
}
if (!getTransportMetadata().getSessionConfigType().isAssignableFrom(sessionConfig.getClass())) {
throw new IllegalArgumentException("sessionConfig type: " + sessionConfig.getClass() + " (expected: "
+ getTransportMetadata().getSessionConfigType() + ")");
}
// Create the listeners, and add a first listener : a activation listener
// for this service, which will give information on the service state.
listeners = new IoServiceListenerSupport(this);
listeners.add(serviceActivationListener);
// Stores the given session configuration
this.sessionConfig = sessionConfig;
// Make JVM load the exception monitor before some transports
// change the thread context class loader.
ExceptionMonitor.getInstance();
if (executor == null) {
this.executor = Executors.newCachedThreadPool();
createdExecutor = true;
} else {
this.executor = executor;
createdExecutor = false;
}
threadName = getClass().getSimpleName() + '-' + id.incrementAndGet();
}
示例6: sessionCreated
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
public void sessionCreated(IoSession session) {
System.out.println("Session created");
IoSessionConfig sessionConfig=session.getConfig();
if (false) {
MessageLoop rb = new MessageLoop();
rb.session = session;
Thread t = new Thread(rb);
t.start();
}
}
示例7: adjustReadBufferSize
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
private void adjustReadBufferSize(IoSession session) {
int maxReadThroughput = this.maxReadThroughput;
if (maxReadThroughput == 0) {
return;
}
IoSessionConfig config = session.getConfig();
if (config.getReadBufferSize() > maxReadThroughput) {
config.setReadBufferSize(maxReadThroughput);
}
if (config.getMaxReadBufferSize() > maxReadThroughput) {
config.setMaxReadBufferSize(maxReadThroughput);
}
}
示例8: ProxyConnector
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* Creates a new proxy connector.
* @see AbstractIoConnector(IoSessionConfig, Executor).
*/
public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) {
super(config, executor);
setConnector(connector);
}
示例9: getSessionConfig
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public IoSessionConfig getSessionConfig() {
return connector.getSessionConfig();
}
示例10: doSetAll
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
@Override
protected void doSetAll(IoSessionConfig config) {
// Do nothing
}
示例11: getSessionConfig
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public IoSessionConfig getSessionConfig() {
return sessionConfig;
}
示例12: DefaultTransportMetadata
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
public DefaultTransportMetadata(String providerName, String name, boolean connectionless, boolean fragmentation,
Class<? extends SocketAddress> addressType, Class<? extends IoSessionConfig> sessionConfigType,
Class<?>... envelopeTypes) {
if (providerName == null) {
throw new IllegalArgumentException("providerName");
}
if (name == null) {
throw new IllegalArgumentException("name");
}
providerName = providerName.trim().toLowerCase();
if (providerName.length() == 0) {
throw new IllegalArgumentException("providerName is empty.");
}
name = name.trim().toLowerCase();
if (name.length() == 0) {
throw new IllegalArgumentException("name is empty.");
}
if (addressType == null) {
throw new IllegalArgumentException("addressType");
}
if (envelopeTypes == null) {
throw new IllegalArgumentException("envelopeTypes");
}
if (envelopeTypes.length == 0) {
throw new IllegalArgumentException("envelopeTypes is empty.");
}
if (sessionConfigType == null) {
throw new IllegalArgumentException("sessionConfigType");
}
this.providerName = providerName;
this.name = name;
this.connectionless = connectionless;
this.fragmentation = fragmentation;
this.addressType = addressType;
this.sessionConfigType = sessionConfigType;
Set<Class<? extends Object>> newEnvelopeTypes = new IdentityHashSet<Class<? extends Object>>();
for (Class<? extends Object> c : envelopeTypes) {
newEnvelopeTypes.add(c);
}
this.envelopeTypes = Collections.unmodifiableSet(newEnvelopeTypes);
}
示例13: getSessionConfigType
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
public Class<? extends IoSessionConfig> getSessionConfigType() {
return sessionConfigType;
}
示例14: AbstractPollingConnectionlessIoAcceptor
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* Creates a new instance.
*/
protected AbstractPollingConnectionlessIoAcceptor( IoSessionConfig sessionConfig )
{
this( sessionConfig, null );
}
示例15: getConfig
import org.apache.mina.core.session.IoSessionConfig; //导入依赖的package包/类
/**
* Does nothing.
*/
@Override
public IoSessionConfig getConfig() {
return null;
}