码迷,mamicode.com
首页 > 其他好文 > 详细

Jetsever开源项目学习(三)Session学习

时间:2016-01-02 18:19:22      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

 

 

package org.menacheri.jetserver.app;

import java.util.List;

import org.menacheri.jetserver.communication.MessageSender;
import org.menacheri.jetserver.communication.MessageSender.Fast;
import org.menacheri.jetserver.communication.MessageSender.Reliable;
import org.menacheri.jetserver.event.Events;
import org.menacheri.jetserver.event.Event;
import org.menacheri.jetserver.event.EventDispatcher;
import org.menacheri.jetserver.event.EventHandler;


public interface Session
{
    /**
     * session status types
     */
    enum Status
    {
        NOT_CONNECTED, CONNECTING, CONNECTED, CLOSED
    }

    Object getId();

    void setId(Object id);

    void setAttribute(String key, Object value);

    Object getAttribute(String key);

    void removeAttribute(String key);

    void onEvent(Event event);

    EventDispatcher getEventDispatcher();


    boolean isWriteable();

    void setWriteable(boolean writeable);

    /**
     * A session would not have UDP capability when created. Depending on the
     * network abilities of the client, it can request UDP communication to be
     * enabled with the LOGIN_UDP and CONNECT_UDP events of the {@link Events}
     * class. Once UDP is enabled this flag will be set to true on the session.
     * 
     * @return Returns true if the a UDP {@link MessageSender} instance is
     *         attached to this session, else false.
     */
    boolean isUDPEnabled();
    
    /**
     * A session would not have UDP capability when created. Depending on the
     * network abilities of the client, it can request UDP communication to be
     * enabled with the LOGIN_UDP and CONNECT_UDP events of the {@link Events}
     * class. Once UDP {@link MessageSender} instance is attached to the
     * session, this method should be called with flag to true to signal that
     * the session is now UDP enabled.
     * 
     * @param isEnabled
     *            Should be true in most use cases. It is used to signal that
     *            the UDP {@link MessageSender} has been attached to session.
     */
    void setUDPEnabled(boolean isEnabled);
    
    boolean isShuttingDown();
    
    long getCreationTime();

    long getLastReadWriteTime();

    void setStatus(Status status);

    Status getStatus();

    boolean isConnected();

    void addHandler(EventHandler eventHandler);
    
    void removeHandler(EventHandler eventHandler);
    
    List<EventHandler> getEventHandlers(int eventType);
    
    void close();

    public abstract void setUdpSender(Fast udpSender);

    public abstract Fast getUdpSender();

    public abstract void setTcpSender(Reliable tcpSender);

    public abstract Reliable getTcpSender();
}

 

Jetsever开源项目学习(三)Session学习

标签:

原文地址:http://www.cnblogs.com/Guoyutian/p/5094863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!