Coder Social home page Coder Social logo

ran3d / foglet-core Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 6.0 19.22 MB

Easy use of WebRTC Networks with embedded network management and simple communication primitives

License: MIT License

JavaScript 86.27% HTML 13.73%
browser-to-browser peer-to-peer random-peer-sampling webrtc

foglet-core's People

Contributors

callidon avatar chat-wane avatar folkvir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

foglet-core's Issues

Unicast support based on existing broadcast support

Currently, if I want to use unicast with Foglet, I need to use Chat-Wane Unicast module and plug it to the Spray network inside the Foglet. It could me nice to have access to methods in Foglet API to perform unicast send/receive on a Hight level API.

A little use case:

const foglet = new Foglet(options);

// init & connection ....

// send to a peer using unicast
const peerId = getIdOfRandomNeighbour();
foglet.unicast('hello w/ unicast', peerId);

// send using broadcast
foglet.broadcast('hello w/ boradcast');

// receive from unicast
// id = id of the peer who send the message, i.e. the sender
// message = The message received
foglet.onUnicast((id, message) => {
  console.log('message ' + message + ' from peer @' + id);
});

// receive from broadcast
// message = The message received
foglet.onBroadcast(message => {
  console.log('broadcast message ' + message);
});

A function to get a list of neighbour's ids could be useful when sending using unicast

const ids = foglet.getPeers();
console.log(ids);
// could print: [ '@id1', '@id2', '@id3']
foglet.unicast('hello deer friend', ids[0]);

Complete documentation

A proper release needs a proper documentation

  • Rely on self-documenting code when possible (i.e. do not spam comments in code)
  • Write all missing JSDoc for:
    • classes
    • methods
    • callbacks used by various methods/functions with understandable names (onBroadcastfor example)
    • types of messages used by each component (FBroadcast for example)
  • Write examples for classes/methods usage.
  • check typos :octocat:

Tests Enhancements

Cause of the growing number of tests. Tests become very huge and heavy to run on browsers due to the number of WebRTC connections on the same page.

Karma is working on a parallel solution to run parallel tests but meanwhile we reach test problems with the growing number of webRTC connections.

My idea to minimize the number of foglets loaded during tests and minimize the number of webrtc connection is to load a fixed number of foglets before tests and ONLY use them for testing purposes.

Think this would be a good idea to work like this.

Another solution is to split tests and apply each karma-test on each file in order to have a single page by test file and minimize the number of webrtc connection by pages.
This leads to problems:

  • global coverage become unavailable.
  • tests duration is longer than the previous solution

Need to quickly find a solution.

If someone has a better idea, comment here.

Enforce tests & coverage

Currently, tests only cover on pratical use cases and a lot of possible errors and unwanted behaviours are left aside.

Time to fix this ! ๐Ÿ’ฏ

In a dream world, let's try to hit 100% code coverage ๐Ÿ˜‹

Cross-Domain errors

Add a warning when we are in HTTPs domains if signaling or ssh server are in HTTP. Vice versa.

Distinct streams are causaly dependent

Using streamBroadcast() function in Communication, if we sent two distinct streams successively, they are causally dependent by default, since, by default, FIFO broadcast is used in the class Broadcast.

Running foglet-core on nodejs

Hi,

Not sure if this project is inactive, because its not updated for almost years, if this is the case its sad because its really cool project.

Anyway I run the project on the browser and its great, but I really would like to have nodes running on node, I know that project uses webrtc but now that is a the https://github.com/node-webrtc/node-webrtc (I have tested with simple-peer) and it works fine.

I am not sure if it would be possible to use it with this project, I tried to look at the code but I didn't figure out how I could do it.

Thanks.

Remote control through "_ssh"

Cause of the non-existence of _log function, need to remove this listener.

Tempory fix if you have this error: foglet._ssh.removeAllListeners('logs')

Broadcast a message to a subset of the network

Broadcasting a message to a subset of the network will not work. Each peer has to register a common Communication in order to route messages.
If you create the following network

  • A -> B; B -> C; (if you want to test youself, add these options to the rps.options config object:
    new Foglet({rps: { options: {delta: 10000000, a: 0, b: 0 }}}))
  • A and C create a channel on the protocol 1
  • A send a broadcast message, B will receive the message but will not route the message to C correctly because B did not register the protocol.

If you really want to broadcast a message to a subset of the network. Just register a common protocol and filter messages in your application. Or create a new Foglet for this specific subset network with new WebRTC connections.

Question on node comunications and signal server

Hi,

I am experimenting doing a p2p queue (https://github.com/fsvieira/p2pqueue) its still on proof-of-concept phase, I still need to work on stats.

I have a question, can I send a message from node A to node Z, if they are not neighbors something like this,
A -> B -> ... -> X, Z , where B ... X nodes that connect A to Z, how this works on foglet-core ?

Another question is that I am getting same node but with suffix -I and -O, from what I understand they are the same but some are out view and in view, the problem is that I get both when I call getNeighbours(limit), for example If I have only two nodes, and request a limit=4 I get same id with id-I and id-O , I would like to get only one id because when I send a message to all the neighbors on the list I am duplicating messages sent. Or is this feature ? If network changes they will still be able to send message ?

Another question, I saw this https://ran3d.github.io/foglet-core/class/src/fprotocol/answer-queue.js~AnswerQueue.html on the docs but I don't understand it, what is it for and how to use it ?

An issue that I had following the docs was using the floget-scripts, it doenst work because signal server version is to old. So I had to install "foglet-signaling-server": "^1.0.3" directly.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.