-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from inkrement/dev
Dev
- Loading branch information
Showing
11 changed files
with
100 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/WebRTCMessenger/src/signaling/jscallbacksignaling.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* JSCallbacksignaling | ||
* | ||
* simple example for a bidirectional signaling channel based on some undefined js technology | ||
* | ||
* @author Christian Hotz-Behofsits <[email protected]> | ||
*/ | ||
|
||
part of messenger.signaling; | ||
|
||
class JSCallbackSignaling extends SignalingChannel{ | ||
|
||
|
||
void recCallback(String message){ | ||
newMessageController.add(new NewMessageEvent(Message.fromString(message))); | ||
} | ||
|
||
/** | ||
* connect | ||
* | ||
* @ TODO: add custom Exceptions | ||
* * prevent self-connections | ||
*/ | ||
void connect(var options){ | ||
// register callback | ||
context.callMethod('JSRegisterRecCallback', [recCallback]); | ||
} | ||
|
||
/** | ||
* send message | ||
*/ | ||
send(Message message) => context.callMethod('JSSignalingsend', [Message.serialize(message)]); | ||
|
||
/** | ||
* close | ||
*/ | ||
close(){ | ||
connection_completer.complete("connection closed"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
name: webrtcmessenger | ||
version: 0.0.1 | ||
version: 0.0.2 | ||
author: Christian Hotz-Behofsits <[email protected]> | ||
description: A Webrtc Messenger | ||
homepage: https://github.com/inkrement/messenger | ||
homepage: https://github.com/inkrement/WebRTCMessenger | ||
environment: | ||
sdk: '>0.8.7' | ||
dependencies: | ||
browser: ">=0.10.0 <0.11.0" | ||
json: ">=0.9.1 <0.10.0" | ||
browser: '>=0.10.0 <0.11.0' | ||
json: '>=0.9.1 <0.10.0' | ||
dev_dependencies: | ||
logging: any | ||
unittest: any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,54 @@ | ||
//import 'dart:html'; | ||
import "package:WebRTCMessenger/WebRTCMessenger/messenger.dart"; | ||
import "package:WebRTCMessenger/WebRTCMessenger/webrtcmessenger.dart"; | ||
import 'package:logging/logging.dart'; | ||
|
||
|
||
void main() { | ||
|
||
/** | ||
* TODO | ||
* test call function to inspect js-output | ||
*/ | ||
|
||
Messenger msg = new Messenger(); | ||
/* | ||
Peer alice = new Peer("alice_c"); | ||
Peer bob = new Peer("bob_c"); | ||
//setup signaling channel | ||
MessagePassing alice_sc = new MessagePassing(); | ||
MessagePassing bob_sc = new MessagePassing(); | ||
//connect signaling channel | ||
alice_sc.connect(bob_sc.identityMap()); | ||
bob_sc.connect(alice_sc.identityMap()); | ||
//connect peer | ||
JsDataChannelConnection alice_c = new JsDataChannelConnection(bob_sc); | ||
JsDataChannelConnection bob_c = new JsDataChannelConnection(alice_sc); | ||
Stream<NewConnectionEvent> s_a = alice.listen(alice_c); | ||
Stream<NewConnectionEvent> s_b = bob.connect(bob_c); | ||
*/ | ||
|
||
|
||
Peer alice = new Peer("alice_s3"); | ||
Peer bob = new Peer("bob_s3"); | ||
Peer clark = new Peer("clark_s3"); | ||
|
||
//setup signaling channels | ||
JSCallbackSignaling alice_bob_sc = new JSCallbackSignaling(); | ||
|
||
alice_bob_sc.connect(null); | ||
|
||
|
||
//set callbacks | ||
|
||
String s_alice = "some random string from alice"; | ||
Message tm_alice = new Message(s_alice); | ||
|
||
|
||
//each sould receive two messages | ||
alice.onReceive.listen((NewMessageEvent mevent){ | ||
print("alice revceived message: " + mevent.getMessage().toString()); | ||
}); | ||
|
||
/* | ||
* send messages | ||
*/ | ||
alice.newConnectionController.stream.listen((_){ | ||
if(alice.connections.length == 1){ | ||
alice.multicast(tm_alice); | ||
} | ||
}); | ||
|
||
|
||
/* | ||
* create connections | ||
*/ | ||
WebRtcDataChannel a_b_c = new WebRtcDataChannel(alice_bob_sc); | ||
|
||
//connect alice/bob bob/alice | ||
alice.listen(a_b_c); | ||
//bob.connect(a_b_c); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters