Coder Social home page Coder Social logo

godot-matcha's Introduction

godot-matcha

Easy webrtc matchmaking using WebTorrent tracker.
This project uses webtorrent to do signaling. This allows you to connect players peer2peer without a server!
I plan on improving this library and add more features. Stay tuned!

Installation

  1. Copy addons/matcha to your godot project.
  2. For non browser builds: Install webrtc-native
  3. Done!

Usage

Example (Mesh):

extends Node

var mp1 := MatchaRoom.create_mesh_room({ "identifier": "my-unique-game-identifier" })
var mp2 := MatchaRoom.create_mesh_room({ "identifier": "my-unique-game-identifier" })

func _init():
	mp1.peer_joined.connect(func(_id, peer):
		print("(1) Peer connected: ", peer.peer_id)
	)

	mp1.peer_left.connect(func(_id, peer):
		print("(1) Peer disconnected: ", peer.peer_id)
	)

	mp2.peer_joined.connect(func(_id, peer):
		print("(2) Peer connected: ", peer.peer_id)
	)

	mp2.peer_left.connect(func(_id, peer):
		print("(2) Peer disconnected: ", peer.peer_id)
	)

Example (Server/Client):

extends Node

var server := MatchaRoom.create_server_room()
var client := MatchaRoom.create_client_room(server.room_id) # Client must know the room id

func _init():
	server.peer_joined.connect(func(_id, peer):
		print("(server) Peer connected: ", peer.peer_id)
	)

	server.peer_left.connect(func(_id, peer):
		print("(server) Peer disconnected: ", peer.peer_id)
	)

	client.peer_joined.connect(func(_id, peer):
		print("(client) Peer connected: ", peer.peer_id)
	)

	client.peer_left.connect(func(_id, peer):
		print("(client) Peer disconnected: ", peer.peer_id)
	)

Changelog

29. Dec. 2023

  • Replaced asserts with push_error + Error return value
    • This fixed some nasty invisible bugs
  • Added example for server/client implementation
  • Improved MatchaPeer class
    • Made it extend from WebRTCPeerConnection
  • Improved MatchaRoom class
    • Made it extend from MultiplayerPeer
    • Added peer_joined/peer_left signals for direct access to the peer
    • Changed naming from info_hash to room_id
    • Added client/server/mesh functionality
  • Improved TrackerClient class
    • Proper user-agent for non-web environment
    • Cleaner code
    • More documentation
  • Prepared nostr implementation
    • In the future you can use nostr aswell as webtorrent
  • Prepared lobby implementation
    • In the future you can find/list/create lobbies

26. Dec. 2023

  • Replaces EventEmitter with native Signals
    • EventEmitter did not improve RefCounted reference issue behaviour so replaced it with signals
  • Removed TrackerRoom class
    • Got replaced with MatchaRoom
  • Exposed MatchaRoom class
    • Using multiplayer api
  • Added example game "bobble"
  • Added web export github page for example

23. Dec. 2023

  • Initial commit
  • Exposed TrackerRoom class

Thanks to

I got the idea for using webtorrent for signaling from that project.
Big thanks :)

godot-matcha's People

Contributors

freehuntx avatar

Stargazers

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

Watchers

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

godot-matcha's Issues

Create GodotSteam "Mock"

Technically we could mock the godotsteam api and do all the signaling and networking over mqtt.
This would have the benefit:

  • Easy port to godotsteam
  • More known api
  • More potential compatible libraries (e.g. Godotsteam HL)

Errot when trying the demo.

"
Error
The following features required to run Godot projects on the Web are missing:
Cross Origin Isolation - Check web server configuration (send correct headers)
SharedArrayBuffer - Check web server configuration (send correct headers)
"

seems like the same errors that pop up when you try to upload a html game to the itch io page.

MatchaRoom reference gets lost

This causes after 1-2 connects the matchaRoom reference to count to 0:

	# TODO: Find a cleaner way for this whole cleanup step
	unreference()
	unreference()
	unreference()

Vulnerability report

We are a group of researchers from Leiden University, and we conduct research on vulnerabilities in open-source software. We have discovered and verified a high-severity vulnerability in your project(freehuntx/godot-matcha). Explaining the vulnerability further in this issue could allow malicious users to access details, so we recommend enabling private vulnerability reporting on GitHub to discuss this matter confidentially.
After you have enabled this feature, please add a comment to this issue so we can continue our discussion. If you have any questions, feel free to leave a reply here or send an email to: j.akhoundali [at] liacs.leidenuniv.nl

Rooms with mesh connections

Hi bro!

You did a great job and made a very cool stuff!

Could you please make an example with rooms AND a mesh connection? So that multiple players can connect to one room
(I tested the rooms and I couldn’t get them to work with more than 1 connection)

It would be amazing!

Thanks for the work you've done!

gif_test

RPC calls not being received

Note: Matcha is completely foreign to me, so I don't know if this is expected, or if I made a mistake somewhere. Either way, I'd like some clarification.

if I send an RPC call, nothing happens.
if I send an RPC call on a specific peer ID, it tells me their ID is unknown and the call fails.

image

This was tested in your bobble example, in a fresh godot project. The only thing I changed was adding an RPC to the peer joined method.

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.