@@ -23,8 +23,8 @@ class WebsocketEmitter {
2323 /// ```
2424 /// emitter.room('ABC');
2525 /// ```
26- WebsocketEmitter room (dynamic id ) {
27- _roomId = id ;
26+ WebsocketEmitter room (dynamic room ) {
27+ _roomId = room ;
2828 return this ;
2929 }
3030
@@ -35,8 +35,13 @@ class WebsocketEmitter {
3535 void emitToSender (String event, dynamic message) {
3636 WebsocketInfo ? info = _storage.getWebSocketInfo (sender);
3737 if (info != null ) {
38- WebsocketEmitEvent emitEvent =
39- WebsocketEmitEvent (sender, _roomId, message, event, []);
38+ WebsocketEmitEvent emitEvent = WebsocketEmitEvent (
39+ senderId: sender,
40+ roomId: _roomId,
41+ message: message,
42+ event: event,
43+ exclude: [],
44+ );
4045
4146 /// we do not need to send via adaptor
4247 /// since sender will be always on the same isolate
@@ -45,22 +50,27 @@ class WebsocketEmitter {
4550 }
4651 }
4752
48- /// set message except the sender
53+ /// sent message except the sender
4954 /// ```
5055 /// emitter.emitExceptSender('event', message);
5156 /// ```
5257 void emitExceptSender (String event, dynamic message) {
5358 emit (event, message, exclude: < String > [sender]);
5459 }
5560
56- /// set message to everyone in the room
61+ /// sent message to everyone in the room
5762 /// ```
5863 /// emitter.emit('event', message);
5964 /// ```
6065 void emit (String event, dynamic message,
6166 {List <String > exclude = const < String > []}) {
62- WebsocketEmitEvent emitEvent =
63- WebsocketEmitEvent (sender, _roomId, message, event, exclude);
67+ WebsocketEmitEvent emitEvent = WebsocketEmitEvent (
68+ senderId: sender,
69+ roomId: _roomId,
70+ message: message,
71+ event: event,
72+ exclude: exclude,
73+ );
6474
6575 WebsocketAdapterInterface ? adapter = WebsocketServer ().getAdapter ();
6676
@@ -70,7 +80,6 @@ class WebsocketEmitter {
7080 emitEventToSockets (emitEvent);
7181 return ;
7282 }
73-
7483 adapter.emit (emitEvent);
7584 }
7685
0 commit comments