Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 08 01:15

    Arenukvern on on-host-disconnected

    (compare)

  • Sep 08 01:05

    Arenukvern on gh-pages

    update (compare)

  • Sep 08 01:03

    dimitrovs on main

    feat: host disconnected excepti… refactor: example with HostDisc… chore: uhst to 3.4.0 and 2 more (compare)

  • Sep 08 01:03
    dimitrovs closed #21
  • Sep 07 20:56
    Arenukvern review_requested #21
  • Sep 07 20:56
    Arenukvern assigned #21
  • Sep 07 20:56
    Arenukvern opened #21
  • Sep 07 20:55

    Arenukvern on on-host-disconnected

    fix: changelog (compare)

  • Sep 07 20:55

    Arenukvern on on-host-disconnected

    chore: uhst to 3.4.0 (compare)

  • Sep 07 20:52

    Arenukvern on on-host-disconnected

    refactor: example with HostDisc… (compare)

  • Sep 07 20:50

    Arenukvern on on-host-disconnected

    feat: host disconnected excepti… (compare)

  • Aug 29 22:05

    Arenukvern on gh-pages

    update (compare)

  • Aug 29 22:04

    Arenukvern on gh-pages

    update (compare)

  • Aug 29 22:03

    Arenukvern on main

    fix: readme links (compare)

  • Aug 29 22:02

    Arenukvern on main

    fix: example relayUrl (compare)

  • Aug 29 21:51

    Arenukvern on gh-pages

    update (compare)

  • Aug 29 21:50

    Arenukvern on exceptions-handler

    (compare)

  • Aug 29 21:50

    Arenukvern on main

    feat: close event fix: send message exception fix: subscribe to messages comp… and 21 more (compare)

  • Aug 29 21:50
    Arenukvern closed #20
  • Aug 29 21:49
    Arenukvern synchronize #20
Anton Malofeev
@Arenukvern

Hi @dimitrovs ! Could you please explain, what is actual purpose to reload connection with timeout in the example below?

setTimeout(function () {
     location.reload();
 }, 15000);

here is source

Stefan Dimitrov
@dimitrovs
Very good question, the purpose is that the hostId may be taken, if you just test and then reload the connection hasn’t dropped yet so the second attempt to connect with the same hostId will get error 400. This just causes it to wait for the connection to drop and then try again.
Probably don’t need this for flutter or if you don’t pass a hostId and just let the relay generate a random hostId
Anton Malofeev
@Arenukvern
@dimitrovs thank you!
Next question: in what moment relay is generating new hostId if it's empty and how we can show it to user? Is it needs to be done on client side or we need to wait it in payload from server side?
Stefan Dimitrov
@dimitrovs
It’s generated during initHost and it is available in the response from that method alongside the token
Even if user sends a hostId during initHost the relay is not guaranteed to respect that hostId and may generate a different one, so user should always use the one from the initHost response
Anton Malofeev
@Arenukvern

@dimitrovs Cannot find such implementation in uhst-client-js :(
are you mean this method?
or this one?

If it's not these, can you share link to code implementation please?

About initHost response, for today if I'm sending a request with empty hostId during initHost such as

http://localhost:3000/?action=host&hostId=

I'm receiving response with no hostId such as

hostId: ""
hostToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ....."

Is it ok or will be changed in future releases?

Anton Malofeev
@Arenukvern

Relative post Q&A to keep all in one place:
Question:
Is it correct, that RelaySocket file is needed to use with centralized server and it will be not p2p but every peer will needed to connect to server and only after that - to peer?

Answer:
With WebRTC the relay server is used for signalling, every peer connects to the relay server. With WebRTC the peers exchange their ICE candidates over the relay connection and then establish a direct p2p connection over WebRTC (https://github.com/uhst/uhst-server-node/wiki/Signalling-Protocol). Without WebRTC (with RelaySocket), the peers communicate through the relay and there is no direct p2p connection. I think the implementation of the Relay will be most helpful to understand how it works: https://github.com/uhst/uhst-server-node/blob/master/src/controllers/api.ts . Let's say there are 3 peers: A, B, C. A connects to Relay as a host and gets a "hostId" which is a unique identifier. B and C also connect to the same Relay using A's hostId. A. B and C each have an EventStream (GET) connection to the relay which is used for incoming data (Relay to peer). When A wants to send a message to B or C it sends it to the relay (POST) and the relay forwards it over the EventStream to B and C. If B wants to send a message to A it sends it to the relay (POST) and the relay forwards it to A. If B wants to send a message to C it sends it to the relay which forwards it to A then A sends it back to the relay which forwards it to C (because this is a star network where A is the host, not a mesh network). In UHST 2.0 (current version) A can send a "broadcast" message to the relay which will be forwarded to all clients registered with the hostId. In UHST 3.0 (next) there is a public relay directory so the app doesn't need to know the URL of a relay to connect (currently there is only one active relay demo.uhst.io but there will be many more once UHST 3.0 is released). In one of the next versions (most likely UHST 4.0) there will be end-to-end encryption so the relay will not be able to see what data it is passing between the peers, this will be done through RSA and AES (for broadcast). A, B and C each will have a public and private key. The relay will store the host public key (used for encryption) but not the private keys (which only the peers have and are used for decryption). Note that the other similar project: https://gun.eco also uses the concept of a relay when there is no WebRTC. The main difference between UHST and Gun is that UHST is star network while Gun is mesh network.

Stefan Dimitrov
@dimitrovs
Empty hostId is a bug, thanks for finding it, I will add to GitHub. But if you don’t specify a hostId param at all (not empty value) then you will get a random id.
Anton Malofeev
@Arenukvern

The code is here on the server side: https://github.com/uhst/uhst-server-node/blob/master/src/controllers/api.ts

Found, thank you very much!

Stefan Dimitrov
@dimitrovs
  • @route POST /?action=host[&hostId=<optional-host-id>]
    */
    export const initHost = (req: Request, res: Response) => {
    const hostId = req.query.hostId as string ?? uuidv4();
    if (isHostConnected(hostId)) {
     res.sendStatus(400);
This error 400 is what requires the reload on the HTML example
Anton Malofeev
@Arenukvern
@dimitrovs hello! just to share information - Flutter 2.0 is out
https://siliconangle.com/2021/03/03/google-announces-flutter-2-support-web-desktop-apps/
Stefan Dimitrov
@dimitrovs
Thanks, yes I read the change list also
Stefan Dimitrov
@dimitrovs
universal_html just added nullsafety: dint-dev/universal_html#30
I am planning to work on a new echo mode for UHST which will exist alongside host & join. Echo is a simple way to exchange messages between users: every message sent by a user is automatically forwarded to all other users. This approach makes it much easier to get started with UHST.
Anton Malofeev
@Arenukvern
very cool approach! will you do it in flutter only or in ts version too?
came here to write about universal_html null safety:)