peer.js | A multipeer WebRTC client | Chat library
kandi X-RAY | peer.js Summary
kandi X-RAY | peer.js Summary
A multipeer WebRTC client
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of peer.js
peer.js Key Features
peer.js Examples and Code Snippets
Community Discussions
Trending Discussions on peer.js
QUESTION
I am working on a multiplayer game. Each client have a character that moves in a shared environment.
I use socket.io to create rooms and peer.js to create a peer-to-peer connection between clients.
What I am trying to do is to enable each client to update the positions of the characters of the other players in his map.
For that, each client should have the state of the keyboard cursors (arrow keys) of the other players so that he can move their corresponding characters with a walking animation.
P2P: I am thinking of creating duplex streams between the clients so that each client will have the state of the keyboard cursors of the other players, so that he can move their characters with the appropriate animation...
SOCKETS: I can also pass the information via the server using sockets, but i will have to send an update of the cursors state 60 times per second since the game is on 60 fps, which makes a lot of socket messages. I am not sure this is the most efficient way to handle it
What is the most efficient way to keep everybody updated about the state of the other players ? Any suggestion will be appreciated. Thanks.
ANSWER
Answered 2021-Feb-14 at 02:19Actually your game is likely a little demo of a MMORPG game or something like CS/CSGO.
For such a game, we always have a loop in main process (work process) with a frequency like several frames a second(say 20 frame). In every frame, the client will process the packets received from others and the options form the pleyer.
If here is 20 frames, that means every fram can't be more than 50ms, so it will cause some delay if it's in WLAN and some packets drop happend.
If you want to use P2P to synchronized players action, here is a problem: when player number booms, the comlicated of the connection boos too. What's more, you need a reliable connection protocol, that means you need to know how to use something like QUIC or write a reliable UDP by yourself.
So I think the most effcient way may keep use C/S model insetead of P2P only if your game will use in LAN and there is quite a few players.
QUESTION
I'm trying to instantiate an already installed node chaincode on a channel, but it fails with error: failed to invoke chaincode name:"lscc" , error: container exited with 0
What I did up to this point:
- Successfully started a network with 2 organizations with 2 peers for each organization and a raft consensus using
./byfn up -c some-channel -s couchdb -o etcdraft -l node
script from Building your first network (v1.4) tutorial. The network already has one instantiated chaincode namedmycc
. - Connected to the network from my script using Node.js SDK. I am able to successfully invoke read and write chaincode methods of the
mycc
chaincode from my script. - Installed new chaincode on all 4 peers using each organization's admin identities. I am able to confirm that the chaincode is indeed installed by querying installed chaincodes on a peer. Also peer container logs also confirm that the chaincode is installed successfully.
- Tried to instantiate the installed chaincode and encountered the above-mentioned error.
Here is how I'm trying to instantiate my chaincode:
...ANSWER
Answered 2020-Sep-08 at 22:56My suggestion is that you have to use two different channels for two different chaincodes. You can install as much chaincode as you want in every peer but the problems will begin when you try to instantiate chaincode as this process is directly involved with network and channel. Though they change the instantiate process from version >= 2.
For the records:
For running a business, some organizations have to come into a consensus and so they have to create a channel where only permissioned organizational properties have access.
Here within a channel every valid organizational peer hold a physical copy of business transactional records which is known as ledger where the ledger is identical which means every ledger that belongs to same channel must hold the same records.
A ledger consists of two distinct, though related, parts – a world state and a blockchain. The world state – a database that holds current values of a set of ledger states. The blockchain – a transaction log that records all the changes that have resulted in the current the world state.
A chaincode is the business logic that is used to read the records of ledger or to write new records into the ledger or to update existing records.
A chaincode is consist with multiple smart contracts.
So The convention is for each channel, you need an identical chaincode. If you have 2 channel, than it's the convention that you have two different chaincodes.
QUESTION
I am trying to instantiate a Golang chaincode on my Hyperledger Fabric network (setup on cloud) using Fabric Node SDK. However, I am facing the following error while performing the same:
...ANSWER
Answered 2020-Jul-12 at 15:08latest
tag isn't available anymore. you have to use specific tag
. Below is the snippet of dave
comment infabric-maintainers
group.
QUESTION
i hope y'all will be fine,
I am a beginner in webRTC sorry if my question feels like a noob one but i was wondering that is there any proper way to close the connection among peers especially using simple-peer.js, looking forward for your awesome replies
here is my sample react code,
...ANSWER
Answered 2020-Feb-22 at 06:10The function is peer.destroy().
Fyi, if you need to find undocumented API functions in Javascript libraries, you can do this by running your JS file in the browser and pressing F12 to bring up the debugging console. Set a breakpoint after the object that you want to investigate is instantiated:
I set a breakpoint AFTER I instantiated peer1 (line 51). Then I hovered over peer1 (line 50) to pop up a menu of all of the properties (methods and fields) belonging to this object. If you're looking for a particular function as in this case, sometimes you find it immediately in this menu, but often you have to expand the property called __proto__ :
You can see the destroy function located here. It's just a guess whether or not a function found in this manner actually does what you want it to do, but luckily in this case it does what we want.
QUESTION
I successfully installed and instantiated chaincode on my chain. I'm able to enroll the admin and register a user trough nodejs. If I query the chaincode it only returns a correct response around 3 out of 5 times. The rest throws errors that the chaincode can't be found.
The chaincode installed is the basic example from the fabric samples. My js file to query the chaincode (based on the fabcar example):
...ANSWER
Answered 2019-Sep-10 at 18:29Looking at the logs I can see why sometimes you get peer0 and occasionally you get peer1, and that is because the discovery results and processing result in it not being possible to get the list of peers in any particular order so with 2 peers in your org and the fact that this is not a long running app but a short running invocation sometimes peer0 will be first in the list of peers and sometimes peer1. Because you have only installed the chaincode on peer0, peer1 can't honour the evaluate request and return an error.
The node-sdk should detect this and then try peer0 but either you are using an older version of the node-sdk which definitely had an issue where it did not try a different peer or the node-sdk is thinking this is (incorrectly, but may not be able to distinguish) a chaincode response and passes that back to the caller. The solution to avoid the error is to install the chaincode on all the peers.
QUESTION
Running hlf 1.4 and latest explorer in kubernetes. Explorer hangs in the start phase where it tries to reach peers. It doesn't reach the code were it starts web interface.
Peer has chaincode installed, connected to channel, no issues.
I have disabled TLS to make investigation easier and put logs in Channel.js, Peer.js in explorer dependencies to better investigate it.
I have added log to Channel.js in /blockchain-explorer/node_modules/fabric-client/lib/Channel.js to print connect to target and I can see that it shows grpc://localhost:undefined. I believe it tries to send request to invalid address and silently dies. Entire file https://gist.github.com/gad0lin/51384bfea1c207ccf016a0cad8e413b6#file-channel-js-L3474.
...ANSWER
Answered 2019-May-30 at 16:06I found the culprit. There were two issues.
I didn't set environment variable DISCOVERY_AS_LOCALHOST to false in explorer config. That was the reason I saw: localhost.
In peer I had set variable CORE_PEER_GOSSIP_EXTERNALENDPOINT, but without port. That was the reason I saw undefined as port.
QUESTION
I have created an Hyperledger Composer-rest-server from azure Ubuntu server. I tried to connect it with amazon server, I have successfully connected them. The only problem is that I cannot install composer-rest-server from amazon side nor install business card from amazon side. So I opened up composer-rest-server from azure side. But after a while, the server will not giving anymore data. It will give error time out that looks like
...ANSWER
Answered 2018-Dec-20 at 09:29There have been some changes to "grpc" one of the underlying protocols used by Fabric, and this can cause timeout problems.
You can change the default grpc options for the Composer REST Server connection to the peers by modifying the connection.json of the card you are using to start the REST server.
For each peer in the connection.json add the following settings:
QUESTION
I am using PeerJS for audio calling functionality in my project. Their website is down and the cloud servers are no longer working.
The solution I came across is to use peerjs-server library.
I also came across the answer in this question that explains how to use peerjs-server
.
My question is what should I use in path
in the following code:
ANSWER
Answered 2018-Apr-13 at 08:05My question is what should I use in path in the following code
You can find this out yourself by peeking into the code of the repo.
There you can see, that the path
option of PeerServer
will be used as part of an express app, that itself creates a websocket connection:
QUESTION
I am developing a cross-plattform application with peer.js and webrtc. I am using cordova, crosswalk. Additionaly I am using the webrtc adapter (https://github.com/webrtc/adapter)
My code is based on the webrtc-crosswalk sample. (https://github.com/crosswalk-project/crosswalk-samples)
I want to change the videosource of the stream without creating a new call. My approche is to remove the tracks of the stream and add the new tracks of the other camera. The result is that the local video shows the right content, but the callee's remote video freezes.
Probably I am doing a very basic mistake, but i can't find a solution. I am looking forward to your answers and solutions.
My main codefile is attached.
Greez, Leo
...ANSWER
Answered 2018-Apr-04 at 07:35If you remove and then add a new track to a PeerConnection you need to renegotiate the offer-answer to get it working. I will recommend you to use the replaceTrack API to avoid the re-negotiation problem while changing the camera input.
QUESTION
I am getting timeout error from peers while instantiating chaincode on particular peers from fabric node sdk on linux os.
...ANSWER
Answered 2018-Mar-29 at 08:04you are correct about the process. If all the operations are good, then I think the docker file is good. But you have to make sure, you can only instantiate the chain code from the peer in which the chain code is installed. Because the chain code installation will not change the channel config.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install peer.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page