testing signaling
parent
479b0507cf
commit
aeaf76b93e
|
@ -2,4 +2,4 @@
|
|||
|
||||
final String baseUrlCore = "http://192.168.86.184:10200";
|
||||
final String baseUrlSignaling = "http://192.168.86.184:10201";
|
||||
final String globalUserId = "u-3d19fb283ddb14fb5c15191438b5b69a";
|
||||
final String globalUserId = "u-fb91825f564a3cc110f11836fedea6f4";
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
import "package:rxdart/rxdart.dart";
|
||||
import "package:flutter_webrtc/webrtc.dart";
|
||||
import 'dart:async' show Stream;
|
||||
import 'package:async/async.dart' show StreamGroup;
|
||||
|
||||
import "../resources/conversation_api_provider.dart";
|
||||
import "../models/user_model.dart";
|
||||
import "../services/peer_manager.dart";
|
||||
import "../../settings.dart";
|
||||
|
||||
class VoiceConnection {
|
||||
final PeerManager _peerManager = PeerManager(globalUserId, "2");
|
||||
final _conversationApiProvider = ConversationApiProvider();
|
||||
final _bottomBarBus = PublishSubject<Map<String, dynamic>>();
|
||||
|
||||
BottomBarBus() {
|
||||
VoiceConnection() {
|
||||
_bottomBarBus.listen((data) => print(data));
|
||||
}
|
||||
|
||||
|
@ -17,6 +23,19 @@ class VoiceConnection {
|
|||
_bottomBarBus.sink.add(message);
|
||||
}
|
||||
|
||||
join(String conversationId) async {
|
||||
List<User> users =
|
||||
await _conversationApiProvider.fetchConversationMembers(conversationId);
|
||||
|
||||
// Add the users to the streams
|
||||
users.forEach((user) {
|
||||
print("hi");
|
||||
_peerManager.addPeer(user.id);
|
||||
});
|
||||
|
||||
List<MediaStream> connectedStreams = _peerManager.streams;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
_bottomBarBus.close();
|
||||
}
|
||||
|
|
|
@ -115,8 +115,9 @@ class PeerConnectionFactory {
|
|||
Future<SignalingResponse> _sendToRemote(String remoteUserId,
|
||||
String remoteDeviceId, Map<String, dynamic> data) async {
|
||||
var response = await http.post(
|
||||
"localhost:10201/user/$remoteUserId/device/$remoteDeviceId",
|
||||
"$baseUrlSignaling/user/$remoteUserId/device/$remoteDeviceId",
|
||||
body: {"data": jsonEncode(data)});
|
||||
|
||||
switch (response.statusCode) {
|
||||
case 200:
|
||||
return SignalingResponse.SUCCESSFULL;
|
||||
|
|
|
@ -19,6 +19,8 @@ class PeerManager {
|
|||
_initialize();
|
||||
}
|
||||
|
||||
List<MediaStream> get streams => _currentStreams;
|
||||
|
||||
_initialize() async {
|
||||
final Map<String, dynamic> mediaConstraints = {
|
||||
"audio": true,
|
||||
|
@ -54,6 +56,12 @@ class PeerManager {
|
|||
_peerConnectionFactory.leavePeerConnection(value);
|
||||
_currentConnections[key] = null;
|
||||
});
|
||||
|
||||
_currentStreams.forEach((stream) {
|
||||
stream.dispose();
|
||||
});
|
||||
|
||||
_currentStreams = [];
|
||||
}
|
||||
|
||||
_signalEventHandler(Map<String, dynamic> data) async {
|
||||
|
|
|
@ -72,7 +72,7 @@ class _BottomBarState extends State<BottomBar> {
|
|||
onPressed: () {
|
||||
print("Pressed close");
|
||||
voiceConnection
|
||||
.publish(<String, dynamic>{"event": "close"});
|
||||
.join("c-6f2ba396fb53961ff8a6ba9c5d286a25");
|
||||
}),
|
||||
])));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue