类 Sessions
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<io.netty.channel.Channel>
-
- io.netty.channel.group.DefaultChannelGroup
-
- xin.alum.aio.groups.Sessions
-
- 所有已实现的接口:
io.netty.channel.group.ChannelGroup,Comparable<io.netty.channel.group.ChannelGroup>,Iterable<io.netty.channel.Channel>,Collection<io.netty.channel.Channel>,Set<io.netty.channel.Channel>
@Component public class Sessions extends io.netty.channel.group.DefaultChannelGroup所有在线连接管理【不支持群组集群,集群推送请用SessionGroups】- 作者:
- alum(alum @ live.cn)
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringALL_SESSIONS所有在线用户static StringPREFIX_BIND_USER_GROUP区分
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidbindUid(io.netty.channel.Channel ch, String userId)绑定voidbindUser(io.netty.channel.Channel ch, String userId, String deviceId)绑定BooleanbindUser(io.netty.channel.Channel ch, String userId, AioPlatform platform, String deviceId)绑定ObjectgetAttr(io.netty.channel.Channel ch, String key)获取StringgetClientIP(io.netty.channel.Channel ch)获取客户端IPStringgetUId(io.netty.channel.Channel ch)获取 bindUser设定的UIDvoidkick(Session session)集群通知 Session上线voidsend(String uid, Transportable msg)向用户发送消息[含集群]io.netty.channel.group.ChannelGroupFuturesends(io.netty.channel.Channel ch, Transportable msg)向不包含ch的其它通道发送消息io.netty.channel.group.ChannelGroupFuturesends(io.netty.channel.group.ChannelMatcher matcher, Transportable msg)向通道Matcher匹配到的连接发送信息io.netty.channel.group.ChannelGroupFuturesends(Transportable msg)向当前群组发送消息[不含集群]<T extends Class>
voidsetAttr(io.netty.channel.Channel ch, String key, T val)设置属性-
从类继承的方法 io.netty.channel.group.DefaultChannelGroup
add, clear, close, close, compareTo, contains, deregister, deregister, disconnect, disconnect, equals, find, flush, flush, flushAndWrite, flushAndWrite, hashCode, isEmpty, iterator, name, newCloseFuture, newCloseFuture, remove, size, toArray, toArray, toString, write, write, write, writeAndFlush, writeAndFlush, writeAndFlush
-
从类继承的方法 java.util.AbstractSet
removeAll
-
从类继承的方法 java.util.AbstractCollection
addAll, containsAll, retainAll
-
从接口继承的方法 java.util.Collection
parallelStream, removeIf, stream, toArray
-
从接口继承的方法 java.util.Set
addAll, containsAll, removeAll, retainAll, spliterator
-
-
-
-
构造器详细资料
-
Sessions
public Sessions()
-
Sessions
public Sessions(String name)
- 参数:
name-
-
-
方法详细资料
-
kick
public void kick(Session session)
集群通知 Session上线- 参数:
session-
-
getClientIP
public String getClientIP(io.netty.channel.Channel ch)
获取客户端IP- 参数:
ch-- 返回:
-
getUId
public String getUId(io.netty.channel.Channel ch)
获取 bindUser设定的UID- 参数:
ch-- 返回:
-
setAttr
public <T extends Class> void setAttr(io.netty.channel.Channel ch, String key, T val)
设置属性- 类型参数:
T-- 参数:
ch-key-val-
-
bindUid
public void bindUid(io.netty.channel.Channel ch, String userId)绑定
-
bindUser
public Boolean bindUser(io.netty.channel.Channel ch, String userId, AioPlatform platform, String deviceId)
绑定- 参数:
ch-userId-platform-
-
sends
public io.netty.channel.group.ChannelGroupFuture sends(Transportable msg)
向当前群组发送消息[不含集群]- 参数:
msg-- 返回:
-
send
public void send(String uid, Transportable msg)
向用户发送消息[含集群]- 参数:
uid-msg-
-
sends
public io.netty.channel.group.ChannelGroupFuture sends(io.netty.channel.Channel ch, Transportable msg)向不包含ch的其它通道发送消息- 参数:
ch-msg-
-
sends
public io.netty.channel.group.ChannelGroupFuture sends(io.netty.channel.group.ChannelMatcher matcher, Transportable msg)向通道Matcher匹配到的连接发送信息- 参数:
matcher- 通道匹配表达式msg- 消息体- 返回:
- 结果
-
-