SSEProcessor class final

Constructors

SSEProcessor()

Properties

delivererState DelivererState
get the sse dispatch state (active or pause)
no setter
hashCode int
The hash code for this object.
no setterinherited
isDelivering bool
A flag represent sse cache loop is dispatching event to sse interceptor.
no setter
isFastDeliver bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sio → Sio
no setter
sseBridge SSEBridge
no setter
sseConfig SSEProcessorConfig
This method is used within the module and needs to ensure that it is not null. If there is an external call involved, the isInit method needs to be called first to check the status.
no setter
sseConfigNullable SSEProcessorConfig?
no setter
streamTransforming bool
A flag represent stream is transforming, meaning data is receiving from server.
no setter

Methods

activeConnect() → void
Toggle to active connection state.
addConnectStateObserver(SSEConnectObserver observer) → void
Add observer listen connection change More detail state refer ConnectState
addSSEInterceptor(SSEInterceptor interceptor, {bool isOnly = false}) → void
Add SSE interceptor to listen sse dispatch. usually receive sse from cache pool, sse will dispatch to SSEInterceptor.intercept if need to receive from server sse immediately, please refer SSEInterceptor.isPeek parameter. isOnly represent interceptor don't support add multiple times by same SSEInterceptor.name.
clearCache() → void
destroy() → void
disableFastDeliver() → void
enableFastDeliver() → void
Sometime need to load entire message, no need display word by word.
init(SSEProcessorConfig config, Dio dio) → void
Initialization method, which must be called during use config Configuration information used to config such as version number, logFileName, debug mode etc. dio Associated with dio, currently SSEProcessor acts as an interceptor in dio component
isInit() bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(DioException err, ErrorInterceptorHandler handler) → void
Called when an exception was occurred during the request.
onRequest(RequestOptions options, RequestInterceptorHandler handler) → void
Called when the request is about to be sent.
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
openAgentStream(String key, {ISSEStream? agentStream, bool goCachePool = false, bool autoRemove = false, bool supportPeekDispatch = true, ValueChanged<List<ServerSentEvent>>? onDone}) → void
Open agent stream, support set outside stream for dispatch sse. (for example sse from db) key is an identity marker that is associated with the agentStream. agentStream takes on the proxy responsibility and is responsible for the logic of external conversion of SSE streams goCachePool is put in cache pool then deliver sse autoRemove remove agentStream in _agentStreams when stream end supportPeekDispatch Directly distribute to the interceptors that support peek mode, it only take effect when goCachePool is true.
removeConnectStateObserver(SSEConnectObserver observer) → void
Remove connection observer, to free up memory resource, unused observer need to remove.
removeSSEInterceptor(SSEInterceptor interceptor) → void
Remove sse interceptor from SSEInterceptorManager, usually you don't need to care remove invoke, SSEProcessor support automatic remove mechanism. please refer SSEInterceptor.autoClearStrategy parameter.
replaceSSEInCache(bool fromHit(ServerSentEventCache element), ServerSentEvent toEvent) → void
Very rare usage scenario, for example i want to replace some scatter sse to one gathered sse. This function support the story : https://pm.ifitu.co/issues/19143 fromHit is function to remove when match the rule, according return result, true will be delete. toEvent will be insert to sse cache head of SSECacheDeliverer
reset() → void
setAgentStream(String key, ISSEStream agentStream) → void
Set agent stream, support set outside stream for dispatch sse. (for example sse from db)
setDeliverInternal(int sseBufferExtractInterval) → void
Set interval time that deliver sse in cache pool
setDeliverState(DelivererState state, {bool isForce = false}) → void
Set cache deliver state, pause dispatch support. DelivererState.active continue dispatch,DelivererState.pause pause dispatch.
setIdleTimeout(double idleTimeout) → void
Support dynamic change idle timeout value, for show loading time that no data transfer.
setStreamAdapter(StreamAdapter? adapter) → void
Set a stream adapter for resolve raw data from server stream, more details reference to StreamAdapter
suspendConnect() → void
Toggle to suspend connection state. Long time not dispatch sse don't trigger switch to ConnectState.connectIdle and ConnectState.connectException in ConnectState.connectSuspend.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

sseProcessorFactory SSEProcessorFactory?
The application usually uses the sseProcessorFactory object create a SSEProcessor to receive sse events, because the early theater only runs one, usually only one SSEProcessor, so the structure is designed according to the singleton, currently for multiple theater situations, still want to extend the singleton use mode, to avoid major changes.
getter/setter pair

Static Methods

clearProcessorFactory() → void
isInitDelegate() bool
setProcessorFactory(SSEProcessorFactory? factory) → void

Constants

eventStreamOpen → const String
eventStreamOpenLogId → const String
fastLoadInterval → const int
Warning : This value couldn't set too small (maybe 0 or 1), if set too small will lead to stream end quickly, when stream end will remove all interceptors that type is AutoClearStrategy.stream or AutoClearStrategy.streamAndFull these interceptors remove early lead to loss useful data that they want to receive.
jsonEndTag → const String
tag → const String
tagDeliver → const String