Compare commits
3 Commits
bobbyd-sho
...
f387d9ea48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f387d9ea48 | ||
| 96ea7d56f9 | |||
| bf3eb0ae9f |
2
README.md
Normal file
2
README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Intro
|
||||
Dandelion is an experimental social network designed to let you build online communites that will last for 100 years.
|
||||
@@ -149,10 +149,11 @@ export class PeerManager {
|
||||
if (!peerConnection) {
|
||||
let remotePeerID = message.from;
|
||||
let newPeer = new PeerConnection(this, remotePeerID, this.websocketSendPeerMessage.bind(this));
|
||||
if (this._isBootstrapPeer) {
|
||||
newPeer.setPolite(false);
|
||||
}
|
||||
|
||||
newPeer.setPoliteFromID(remotePeerID, true);
|
||||
|
||||
peerConnection = newPeer;
|
||||
|
||||
this.peers.set(newPeer.remotePeerID, newPeer);
|
||||
|
||||
this.onConnectRequest(newPeer);
|
||||
@@ -580,6 +581,12 @@ class PeerConnection {
|
||||
this.polite = polite;
|
||||
}
|
||||
|
||||
setPoliteFromID(peerID: PeerID, remote = false) {
|
||||
let polite = (parseInt(peerID.charAt(peerID.length-1), 16) % 2 == 0) && !remote;
|
||||
|
||||
this.setPolite(polite);
|
||||
}
|
||||
|
||||
setupDataChannel() {
|
||||
if (!this.dataChannel) {
|
||||
throw new Error();
|
||||
@@ -713,6 +720,7 @@ class PeerConnection {
|
||||
|
||||
try {
|
||||
this.makingOffer = true;
|
||||
this.setPoliteFromID(this.peerManager.peerID);
|
||||
await this.rtcPeer.setLocalDescription();
|
||||
|
||||
if (!this.rtcPeer.localDescription) {
|
||||
|
||||
@@ -82,9 +82,7 @@ export class PeerManager {
|
||||
if (!peerConnection) {
|
||||
let remotePeerID = message.from;
|
||||
let newPeer = new PeerConnection(this, remotePeerID, this.websocketSendPeerMessage.bind(this));
|
||||
if (this._isBootstrapPeer) {
|
||||
newPeer.setPolite(false);
|
||||
}
|
||||
newPeer.setPoliteFromID(remotePeerID, true);
|
||||
peerConnection = newPeer;
|
||||
this.peers.set(newPeer.remotePeerID, newPeer);
|
||||
this.onConnectRequest(newPeer);
|
||||
@@ -417,6 +415,10 @@ class PeerConnection {
|
||||
setPolite(polite) {
|
||||
this.polite = polite;
|
||||
}
|
||||
setPoliteFromID(peerID, remote = false) {
|
||||
let polite = (parseInt(peerID.charAt(peerID.length - 1), 16) % 2 == 0) && !remote;
|
||||
this.setPolite(polite);
|
||||
}
|
||||
setupDataChannel() {
|
||||
if (!this.dataChannel) {
|
||||
throw new Error();
|
||||
@@ -513,6 +515,7 @@ class PeerConnection {
|
||||
}
|
||||
try {
|
||||
this.makingOffer = true;
|
||||
this.setPoliteFromID(this.peerManager.peerID);
|
||||
await this.rtcPeer.setLocalDescription();
|
||||
if (!this.rtcPeer.localDescription) {
|
||||
return;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user