public class KeepOnlineSession extends Object implements DeviceSession, ReplaceableDeviceSession, PersistentSession
| 构造器和说明 |
|---|
KeepOnlineSession(DeviceSession parent,
java.time.Duration keepAliveTimeOut) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
关闭session
|
long |
connectTime() |
Optional<InetSocketAddress> |
getClientAddress() |
String |
getDeviceId() |
String |
getId() |
java.time.Duration |
getKeepAliveTimeout() |
DeviceOperator |
getOperator()
获取设备操作对象,在类似TCP首次请求的场景下,返回值可能为
null. |
String |
getProvider() |
Optional<String> |
getServerId() |
Transport |
getTransport()
传输协议,比如MQTT,TCP等
|
boolean |
isAlive() |
boolean |
isWrapFrom(Class<?> type)
判断会话是否包装自指定的类型,在某些场景下,可能会对会话进行包装
|
long |
lastPingTime() |
void |
onClose(Runnable call)
设置close回调
|
void |
ping()
心跳
|
void |
replaceWith(DeviceSession session) |
reactor.core.publisher.Mono<Boolean> |
send(EncodedMessage encodedMessage)
发送消息给会话
|
void |
setKeepAliveTimeout(java.time.Duration timeout)
设置心跳超时时间
|
<T extends DeviceSession> |
unwrap(Class<T> type)
展开为指定对会话类型,通过此方法拿到最原始对会话对象进行操作.如果类型不一致可能会抛出
ClassCastException |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitkeepAlivepublic KeepOnlineSession(DeviceSession parent, java.time.Duration keepAliveTimeOut)
public String getId()
getId 在接口中 DeviceSessionpublic String getDeviceId()
getDeviceId 在接口中 DeviceSession@Nullable public DeviceOperator getOperator()
DeviceSessionnull.
可以通过判断此返回值是否为null,来处理首次连接的情况。getOperator 在接口中 DeviceSessionpublic long lastPingTime()
lastPingTime 在接口中 DeviceSessionpublic long connectTime()
connectTime 在接口中 DeviceSessionpublic reactor.core.publisher.Mono<Boolean> send(EncodedMessage encodedMessage)
DeviceSessionsend 在接口中 DeviceSessionencodedMessage - 消息MqttMessagepublic Transport getTransport()
DeviceSessiongetTransport 在接口中 DeviceSessionpublic void close()
DeviceSessionclose 在接口中 DeviceSessionpublic void ping()
DeviceSessionping 在接口中 DeviceSessionDeviceSession.keepAlive()public boolean isAlive()
isAlive 在接口中 DeviceSessionpublic void onClose(Runnable call)
DeviceSessiononClose 在接口中 DeviceSessioncall - 回调public Optional<String> getServerId()
getServerId 在接口中 DeviceSessionpublic Optional<InetSocketAddress> getClientAddress()
getClientAddress 在接口中 DeviceSessionpublic void setKeepAliveTimeout(java.time.Duration timeout)
DeviceSessionsetKeepAliveTimeout 在接口中 DeviceSessiontimeout - 心跳超时时间public java.time.Duration getKeepAliveTimeout()
getKeepAliveTimeout 在接口中 DeviceSessionpublic boolean isWrapFrom(Class<?> type)
DeviceSessionisWrapFrom 在接口中 DeviceSessiontype - 类型public <T extends DeviceSession> T unwrap(Class<T> type)
DeviceSessionClassCastExceptionunwrap 在接口中 DeviceSessionT - 类型泛型type - 类型public void replaceWith(DeviceSession session)
replaceWith 在接口中 ReplaceableDeviceSessionpublic String getProvider()
getProvider 在接口中 PersistentSessionCopyright © 2019–2022. All rights reserved.