publish method
Implementation
void publish(Request_Request event, Map<String, dynamic>? incomingData) {
Request message = Request();
Map<Request_Request, VoidCallback> requestMap = {
Request_Request.connectRoom: () =>
message.connectRoom = ConnectRoom(roomId: incomingData?['roomId']),
Request_Request.createTransport: () =>
message.createTransport = CreateTransport(
sctpCapabilities: incomingData?['sctpCapabilities'],
transportType: incomingData?['transportType'],
),
Request_Request.connectTransport: () =>
message.connectTransport = ConnectTransport(
transportType: incomingData?['transportType'],
dtlsParameters: incomingData?['dtlsParameters'],
),
Request_Request.produce: () => message.produce = Produce(
label: incomingData?['label'],
kind: incomingData?['kind'],
rtpParameters: incomingData?['rtpParameters'],
paused: incomingData?['paused'],
appData: incomingData?['appData'],
),
Request_Request.consume: () => message.consume = Consume(
producerId: incomingData?['producerId'],
producerPeerId: incomingData?['producerPeerId'],
appData: incomingData?['appData'],
),
Request_Request.resumeConsumer: () =>
message.resumeConsumer = ResumeConsumer(
consumerId: incomingData?['consumerId'],
producerPeerId: incomingData?['producerPeerId'],
),
Request_Request.restartTransportIce: () =>
message.restartTransportIce = RestartTransportIce(
transportType: incomingData?['transportType'],
transportId: incomingData?['transportId'],
),
Request_Request.updateRoomMetadata: () => message.updateRoomMetadata =
UpdateRoomMetadata(metadata: incomingData?['metadata']),
Request_Request.updateRoomControls: () =>
message.updateRoomControls = UpdateRoomControls(),
Request_Request.closeStreamOfLabel: () =>
message.closeStreamOfLabel = CloseStreamOfLabel(
label: incomingData?['label'],
peerIds: incomingData?['peerIds'],
),
Request_Request.sendData: () => message.sendData = SendData(
to: incomingData?['to'],
payload: incomingData?['payload'],
label: incomingData?['label'],
),
Request_Request.acceptLobbyPeer: () => message.acceptLobbyPeer =
AcceptLobbyPeer(peerId: incomingData?['peerId']),
Request_Request.denyLobbyPeer: () => message.denyLobbyPeer =
DenyLobbyPeer(peerId: incomingData?['peerId']),
Request_Request.kickPeer: () =>
message.kickPeer = KickPeer(peerId: incomingData?['peerId']),
Request_Request.closeRoom: () => message.closeRoom = CloseRoom(),
Request_Request.updatePeerRole: () =>
message.updatePeerRole = UpdatePeerRole(
peerId: incomingData?['peerId'],
role: incomingData?['role'],
),
Request_Request.updatePeerMetadata: () =>
message.updatePeerMetadata = UpdatePeerMetadata(
peerId: incomingData?['peerId'],
metadata: incomingData?['metadata'],
),
Request_Request.syncMeetingState: () =>
message.syncMeetingState = SyncMeetingState(),
Request_Request.closeProducer: () => message.closeProducer =
CloseProducer(producerId: incomingData?['producerId']),
Request_Request.createDataConsumer: () => message.createDataConsumer =
CreateDataConsumer(label: incomingData?['label']),
};
if (requestMap.containsKey(event)) {
Function()? eventFunc = requestMap[event];
if (eventFunc != null) {
eventFunc();
}
} else {
throw ArgumentError('Invalid request case: $event');
}
Uint8List binaryData = message.writeToBuffer();
ws?.innerWebSocket?.add(binaryData);
}