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

RoomChat(String roomId, String apiKey, {String? userId, String? userName, String baseURL = 'https://api.cocobase.buzz'})

Properties

apiKey String
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String
final
userId String?
final
userName String?
final

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