britzl / defnet Goto Github PK
View Code? Open in Web Editor NEWDefold networking examples
License: MIT License
Defold networking examples
License: MIT License
Hello, working on a multiplayer game and I noticed there is no protocol negotiation in the tcp_server. If you build for HTML5 and try to connect to a server you get:
WebSocket connection to 'ws://localhost:8190/' failed: Error during WebSocket handshake: net::ERR_INVALID_HTTP_RESPONSE
Do I need to set up my own negotiation to use this library? Or am I missing something?
Thanks!
How to handle websocket disconnection event (originated from server side)?
Hi, I've noticed that DefNet had a breaking change since the version 6.0.0, and that also create some issues to the p2p_discovery example.
When running the p2p_discovery example, after the client found a host, the logo instead of doing the animation, it's flying up through the screen.
My suggestion is to add self.p2p.stop
in the current example, and create a new example without the stop function after the client found a server, so that people can decide whether or not they need to use the stop function in their project (or in which scenario that they might need).
NM
Hi Britzl,
I have used your defnet library to discover hosts in a given network. It turned out that for me, the typical usecase was a little different, so I use some changes in a fork of your code. If you feel that they are useful, I would be glad if you considered them for the defnet upstream version:
If I am not mistaken, you stop the discovering process after detecting the first remote host. I would prefer to allow for more than just a single host to communicate with the player. With the callback function, the application can stop the discovery process at any time it sees fit, but this change allows for finding more than one peer if needed.
When searching for peers, you send a string to identify the type of host you wish to discover. Typically, to me, that would be the name/id of the game. However, I find it useful for every peer to be able to include some unique data, as well (e.g. each player's individual callsign). So instead of a test for equality of the id/name string, it is more flexible to check if the transmitted string only starts with the right string. That way, it can contain additional data that can then be evaluated by the application in the callback method.
To me, these trivial changes have been very helpful.
Please let me know what you think.
Regards,
Lutz
Defnet master currently differs from the latest release 5.0.1:
https://github.com/britzl/defnet/compare/5.0.1...master?short_path=04c6e90#diff-04c6e90faac2675aa89e2176d2eec7d8
master has a major bugfix in it that allows servers to send messages to clients - without it, you can't get the client object out and so can only broadcast to all clients.
Defnet should have a new release to get this bugfix into a tagged version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.