Package com.adobe.granite.socketio
Interface SocketIOEmitter
-
- All Known Subinterfaces:
SocketIONamespace
,SocketIOSocket
@ProviderType public interface SocketIOEmitter
Socket.io event emitter. Examples: <xmp> namespace.emit(); // all sockets in namespace namespace.to(r1).emit(); // all sockets in room 'r1' namepsace.broadcast().emit(); // same as above socket.emit(); // only to self socket.broadcast().emit(); // to all sockets excluding self socket.broadcast().to(r1).emit(); // to all sockets in room 'r1', excluding self socket.to(r1).emit(); // to all sockets in room 'r1', including self </xmp>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SocketIOEmitter
emit(String eventName, Object... arguments)
Emits an event to the socket identified by the string name.SocketIOEmitter
emit(String eventName, JSONArray arguments)
Emits an event to the socket identified by the string name.SocketIOEmitter
to(String... room)
Sets a modifier for a subsequent event emission that the event will only be broadcast to sockets that have joined the given room.
-
-
-
Method Detail
-
emit
@Nonnull SocketIOEmitter emit(@Nonnull String eventName, @Nonnull Object... arguments) throws IOException
Emits an event to the socket identified by the string name. Any other parameters can be included.- Parameters:
eventName
- name of the eventarguments
- optional arguments- Returns:
- emitter
- Throws:
IOException
- error
-
emit
@Nonnull SocketIOEmitter emit(@Nonnull String eventName, @Nonnull JSONArray arguments) throws IOException
Emits an event to the socket identified by the string name. Any other parameters can be included.- Parameters:
eventName
- name of the eventarguments
- optional arguments- Returns:
- emitter
- Throws:
IOException
- error
-
to
@Nonnull SocketIOEmitter to(@Nonnull String... room)
Sets a modifier for a subsequent event emission that the event will only be broadcast to sockets that have joined the given room. To emit to multiple rooms, you can call to several times.- Parameters:
room
- name of the room- Returns:
- a new emitter that will broadcast the events
-
-