Package io.socket.engineio.server
Class EngineIoSocket
java.lang.Object
io.socket.engineio.server.Emitter
io.socket.engineio.server.EngineIoSocket
An engine.io socket.
Objects of this class represents connections to remote clients
one per object.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class io.socket.engineio.server.Emitter
Emitter.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate final ConcurrentHashMap<String, ConcurrentLinkedQueue<EngineIoSocket.SocketedListener>> private Runnableprivate final Objectprivate ScheduledFuture<?> private final Runnableprivate ScheduledFuture<?> private final Runnableprivate final intprivate ReadyStateprivate final ScheduledExecutorServiceprivate final EngineIoServerprivate final Stringprivate Transportprivate final AtomicBooleanprivate final LinkedList<Packet<?>> private static final String -
Constructor Summary
ConstructorsConstructorDescriptionEngineIoSocket(Object lockObject, String sid, int protocolVersion, EngineIoServer server, ScheduledExecutorService scheduledTaskHandler) -
Method Summary
Modifier and TypeMethodDescription(package private) booleancanUpgrade(String transport) Checks whether the socket can be upgraded to another transport.private voidvoidclose()Close this socket.private voidExecutes each of listeners with the given args.private voidflush()(package private) StringGet the name of the current transport.getId()Gets the sid of this socket.Get the headers of the initial HTTP connection.Get the query parameters of the initial HTTP connection.intGets the protocol version of this socket.Gets the ready state of this socket.(package private) voidCalled after instance creation to initialize transport.Removes all listeners of the specified event.off(String event, EngineIoSocket.SocketedListener fn) Removes the listener.on(String event, EngineIoSocket.SocketedListener fn) Listen on the event.private voidprivate voidonError()private voidonOpen()private void(package private) voidonRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handle an HTTP request.private voidresetPingTimeout(long timeout) private voidvoidSend a packet to the remote client.private voidsendPacket(Packet<?> packet) private voidsendPing()private voidsetTransport(Transport transport) (package private) void(package private) voidPerform upgrade to the specified transport.
-
Field Details
-
PAYLOAD_NOOP
-
EMPTY_UPGRADES
-
WEBSOCKET_UPGRADES
-
HANDSHAKE_JSON
- See Also:
-
mSid
-
mProtocolVersion
private final int mProtocolVersion -
mServer
-
mWriteBuffer
-
mCallbacks
private final ConcurrentHashMap<String,ConcurrentLinkedQueue<EngineIoSocket.SocketedListener>> mCallbacks -
mLockObject
-
mScheduledTaskHandler
-
mPingTask
-
mPingTimeoutTask
-
mPingFuture
-
mPingTimeoutFuture
-
mUpgrading
-
mCleanupFunction
-
mReadyState
-
mTransport
-
mInitialQuery
-
mInitialHeaders
-
-
Constructor Details
-
EngineIoSocket
EngineIoSocket(Object lockObject, String sid, int protocolVersion, EngineIoServer server, ScheduledExecutorService scheduledTaskHandler)
-
-
Method Details
-
getId
Gets the sid of this socket. -
getProtocolVersion
public int getProtocolVersion()Gets the protocol version of this socket. -
getReadyState
Gets the ready state of this socket. -
getInitialQuery
Get the query parameters of the initial HTTP connection. -
getInitialHeaders
Get the headers of the initial HTTP connection. -
send
Send a packet to the remote client. Queuing of packets in case of polling transport are handled internally. This method is thread safe.- Parameters:
packet- The packet to send.
-
close
public void close()Close this socket. -
on
Listen on the event. NOTE: Unstable api. Might change in the future.- Parameters:
event- Event namefn- Event listener- Returns:
- A reference to this object
-
off
Removes the listener. NOTE: Unstable api. Might change in the future.- Parameters:
event- an event name.fn- Event listener.- Returns:
- a reference to this object.
-
off
Description copied from class:EmitterRemoves all listeners of the specified event. -
emit
Description copied from class:EmitterExecutes each of listeners with the given args. -
init
Called after instance creation to initialize transport.- Parameters:
transport- The opened transport.
-
updateInitialHeadersFromActiveTransport
void updateInitialHeadersFromActiveTransport() -
onRequest
void onRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Handle an HTTP request.- Parameters:
request- The HTTP request object.response- The HTTP response object.- Throws:
IOException- On IO error.
-
canUpgrade
Checks whether the socket can be upgraded to another transport.- Parameters:
transport- The transport to upgrade to.- Returns:
- Boolean value indicating if upgrade is possible.
-
upgrade
Perform upgrade to the specified transport.- Parameters:
transport- The transport to upgrade to.
-
getCurrentTransportName
String getCurrentTransportName()Get the name of the current transport.- Returns:
- Name of current transport.
-
setTransport
-
closeTransport
private void closeTransport() -
clearTransport
private void clearTransport() -
onOpen
private void onOpen() -
onClose
-
onError
private void onError() -
onPacket
-
sendPacket
-
flush
private void flush() -
sendPing
private void sendPing() -
schedulePing
private void schedulePing() -
resetPingTimeout
private void resetPingTimeout(long timeout)
-