RoomChat class
Room-based chat for real-time communication
Create or join chat rooms with event-based messaging and automatic reconnection.
Example:
final room = RoomChat(
'room-123',
apiKey,
userId: 'user-123',
userName: 'John Doe'
);
// Listen to events
room.on('connected', (data) {
print('Connected to room');
});
room.on('message', (data) {
print('New message: ${data['content']}');
});
room.on('user_joined', (data) {
print('User joined: ${data['user_name']}');
});
// Create a new room
room.create(roomTitle: 'My Chat Room');
// Or join an existing room
// room.join();
// Send messages
room.sendMessage({'text': 'Hello everyone!'});
// Leave when done
room.leave();
Constructors
Properties
Methods
-
create(
{String? roomTitle}) → void - Create a new room
-
join(
) → void - Join an existing room
-
leave(
) → void - Leave the room
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on(
String event, Listener callback) → void - Listen for specific events
-
sendMessage(
Map< String, dynamic> content) → void - Send a message to the room
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited