4
2
Fork 0

fixed all the bugs with sending signaling data

pull/31/head
Sudharshan S. 2019-02-20 15:19:44 +08:00
parent 1e25a4885c
commit fa2b2b001a
Signed by: sudharshan
GPG Key ID: C861C97AAF3D9559
3 changed files with 7 additions and 10 deletions

View File

@ -1,5 +1,5 @@
// Overall sensible settings for development
final String baseUrlCore = "http://192.168.86.184:10200";
final String baseUrlSignaling = "http://192.168.86.184:10201";
final String baseUrlCore = "http://localhost:10200";
final String baseUrlSignaling = "http://localhost:10201";
final String globalUserId = "u-fb91825f564a3cc110f11836fedea6f4";

View File

@ -116,11 +116,9 @@ class PeerConnectionFactory {
String remoteDeviceId, Map<String, dynamic> data) async {
var response = await http.post(
"$baseUrlSignaling/user/$remoteUserId/device/$remoteDeviceId",
body: jsonEncode({"data": "hi"}));
headers: {"Content-Type": "application/json"},
body: jsonEncode({"data": data}));
print(response.statusCode);
print(remoteUserId);
print(remoteDeviceId);
switch (response.statusCode) {
case 200:
return SignalingResponse.SUCCESSFULL;

View File

@ -12,8 +12,8 @@ class PeerManager {
PeerConnectionFactory _peerConnectionFactory;
MediaStream _localStream;
List<MediaStream> _currentStreams;
Map<String, RTCPeerConnection> _currentConnections;
List<MediaStream> _currentStreams = [];
Map<String, RTCPeerConnection> _currentConnections = {};
PeerManager(this._selfUserId, this._selfDeviceId) {
_initialize();
@ -35,7 +35,6 @@ class PeerManager {
addPeer(String userId) async {
var response = await http.get("$baseUrlSignaling/user/$userId/devices");
List<dynamic> deviceIds = jsonDecode(response.body);
deviceIds.forEach((deviceId) async {
RTCPeerConnection connection =
await _peerConnectionFactory.newPeerConnection(userId, deviceId);
@ -46,7 +45,7 @@ class PeerManager {
(stream) => _currentStreams.removeWhere((it) => stream.id == it.id);
// Add peer connection to the map
_currentConnections["$userId-$deviceId"] = connection;
_currentConnections.addAll({"$userId-$deviceId": connection});
});
}