{"id":14961763,"url":"https://github.com/alfredbaudisch/godotphoenixchannels","last_synced_at":"2025-07-08T10:08:22.696Z","repository":{"id":48257078,"uuid":"184647374","full_name":"alfredbaudisch/GodotPhoenixChannels","owner":"alfredbaudisch","description":"GDScript and Godot client for real-time Phoenix Framework Channels","archived":false,"fork":false,"pushed_at":"2023-07-29T06:44:17.000Z","size":201,"stargazers_count":291,"open_issues_count":7,"forks_count":16,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-07T15:18:14.160Z","etag":null,"topics":["elixir","gdscript","godot","phoenix-channels","realtime","websocket"],"latest_commit_sha":null,"homepage":"","language":"GDScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alfredbaudisch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-05-02T20:30:38.000Z","updated_at":"2025-06-17T04:06:21.000Z","dependencies_parsed_at":"2024-04-18T20:45:51.152Z","dependency_job_id":null,"html_url":"https://github.com/alfredbaudisch/GodotPhoenixChannels","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alfredbaudisch/GodotPhoenixChannels","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredbaudisch%2FGodotPhoenixChannels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredbaudisch%2FGodotPhoenixChannels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredbaudisch%2FGodotPhoenixChannels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredbaudisch%2FGodotPhoenixChannels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alfredbaudisch","download_url":"https://codeload.github.com/alfredbaudisch/GodotPhoenixChannels/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredbaudisch%2FGodotPhoenixChannels/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264247859,"owners_count":23579055,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","gdscript","godot","phoenix-channels","realtime","websocket"],"created_at":"2024-09-24T13:27:00.834Z","updated_at":"2025-07-08T10:08:22.663Z","avatar_url":"https://github.com/alfredbaudisch.png","language":"GDScript","funding_links":["https://www.paypal.com/donate?hosted_button_id=FC5FTRRE3548C","https://www.patreon.com/alfredbaudisch","https://ko-fi.com/alfredbaudisch'"],"categories":[],"sub_categories":[],"readme":"# Phoenix Channels Client for Godot and GDScript ![Godot 3.*](https://img.shields.io/badge/godot-v3.*-%23478cbf) ![Godot 4.0](https://img.shields.io/badge/godot-v4.0-%23478cbf)\n\n[![Donate using PayPal](https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/badges/Donate-PayPal-green.svg)](https://www.paypal.com/donate?hosted_button_id=FC5FTRRE3548C) [![Become a patron](https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/badges/Patreon-Badge.svg)](https://www.patreon.com/alfredbaudisch) \u003ca href='https://ko-fi.com/alfredbaudisch' target='_blank'\u003e\u003cimg height='22' style='border:0px;height:22px;' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' title='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"512\" height=\"512\" src=\"https://i.imgur.com/h75l4l7.png\"\u003e\n\u003c/p\u003e\n\nGodotPhoenixChannels is a GDScript and [Godot Engine](https://godotengine.org) implementation for the Channels API of the [Phoenix Framework](http://www.phoenixframework.org/). It enables Godot projects and games to connect to Phoenix Channels to leverage the connected massive real-time capabilities of Elixir and Phoenix backends. Compatible with Godot 3.* and Godot 4.0.\n\n## Links\n### Godot 4\n- Addon source-code in the [4.0 branch](https://github.com/alfredbaudisch/GodotPhoenixChannels/tree/4.0)\n- [AssetLib](https://godotengine.org/asset-library/asset/1831)\n- [Demo](https://github.com/alfredbaudisch/GodotPhoenixChannels-Demo/tree/4.0)\n\n### Godot 3\n- Addon source-code in the [3.x branch](https://github.com/alfredbaudisch/GodotPhoenixChannels/tree/3.x)\n- [AssetLib](https://godotengine.org/asset-library/asset/1843)\n- [Demo](https://github.com/alfredbaudisch/GodotPhoenixChannels-Demo)\n\n## Installation\n- Install with the [Godot Asset Library for Godot 4](https://godotengine.org/asset-library/asset/1831) or [Godot Asset Library for Godot 3](https://godotengine.org/asset-library/asset/1843).\n- Or clone/download this repository, from the correct branch (see links above).\n\n## Introduction\nBefore diving in, if you want to see some crazy numbers about the scalability of Phoenix, check [The Road to 2 Million Websocket Connections in Phoenix](https://phoenixframework.org/blog/the-road-to-2-million-websocket-connections) and [How Discord Scaled Elixir to 5,000,000 Concurrent Users](https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b).\n\n## What is Elixir?\n[Elixir](https://elixir-lang.org/) is a dynamic, functional language designed for building scalable and maintainable applications.\n\nElixir leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems, while also being successfully used in web development and the embedded software domain.\n\n## What is Phoenix?\n[Phoenix](https://phoenixframework.org/) is a web and real-time framework built with Elixir. Phoenix leverages the Erlang VM ability to handle millions of connections alongside Elixir's beautiful syntax and productive tooling for building fault-tolerant systems.\n\n### What are Phoenix Channels?\n[Channels](https://hexdocs.pm/phoenix/channels.html) are an exciting part of Phoenix that enable soft real-time communication with and between millions of connected clients. Some possible use cases include:\n\n- Chat rooms and APIs for messaging apps\n- Breaking news, like \"a goal was scored\" or \"an earthquake is coming\"\n- Tracking trains, trucks, or race participants on a map\n- Events in multiplayer games\n- Monitoring sensors and controlling lights\n\n## Implementation\n\nThis library tries to follow the same design patterns of the official [Phoenix JavaScript client](https://hexdocs.pm/phoenix/js/), but important changes had to be made regarding events, in order to accommodate to GDScript. Godot's [WebSocketClient](https://docs.godotengine.org/en/3.1/classes/class_websocketclient.html) is used as the transport.\n\n### Features\nAlmost every feature from the JS official client are implemented:\n\n- Main features of Phoenix Socket (connect, heartbeats, reconnect timers, errors)\n- Main features of Phoenix Channel (join, leave, push, receive, rejoin timers, errors)\n- All features of Presence\n- Automatic disconnection and channel leaving on Node freeing\n\n# Examples\n\n## Example Godot Project\n\n- For usage examples see the demo repository project: [https://github.com/alfredbaudisch/GodotPhoenixChannels-Demo](https://github.com/alfredbaudisch/GodotPhoenixChannels-Demo).\n- [Godello](https://github.com/alfredbaudisch/Godello) is a complex project made with Godot, GDScript and Elixir, and uses this library.\n\n## Example Elixir Project\n\nA simple Elixir server is available in [Demo/server](https://github.com/alfredbaudisch/GodotPhoenixChannels-Demo/tree/master/Demo/server) in the demo repository.\n\nTo run it, have Elixir installed, then:\n```\ncd Demo/server\nmix deps.get\niex -S mix phx.server\n```\n\nAfter the server is running, you can run the Godot demo and in the Host field put:\n`ws://localhost:4000/socket`.\n\n## Example Usage\n```gdscript\nvar socket : PhoenixSocket\nvar channel : PhoenixChannel\nvar presence : PhoenixPresence\n\nsocket = PhoenixSocket.new(\"ws://localhost:4000/socket\", {\n  params = {user_id = 10, token = \"some_token\"}\n})\n\n# Subscribe to Socket events\nsocket.connect(\"on_open\", self, \"_on_Socket_open\")\nsocket.connect(\"on_close\", self, \"_on_Socket_close\")\nsocket.connect(\"on_error\", self, \"_on_Socket_error\")\nsocket.connect(\"on_connecting\", self, \"_on_Socket_connecting\")\n\n# If you want to track Presence\npresence = PhoenixPresence.new()\n\n# Subscribe to Presence events (sync_diff and sync_state are also implemented)\npresence.connect(\"on_join\", self, \"_on_Presence_join\")\npresence.connect(\"on_leave\", self, \"_on_Presence_leave\")\n\n# Create a Channel\nchannel = socket.channel(\"game:abc\", {}, presence)\n\n# Subscribe to Channel events\nchannel.connect(\"on_event\", self, \"_on_Channel_event\")\nchannel.connect(\"on_join_result\", self, \"_on_Channel_join_result\")\nchannel.connect(\"on_error\", self, \"_on_Channel_error\")\nchannel.connect(\"on_close\", self, \"_on_Channel_close\")\n\ncall_deferred(\"add_child\", socket, true)\n\n# Connect!\nsocket.connect_socket()\n```\n\nThen you implement the listeners:\n```gdscript\n#\n# Socket events\n#\n\nfunc _on_Socket_open(payload):\n\tchannel.join()\n\tprint(\"_on_Socket_open: \", \" \", payload)\n\nfunc _on_Socket_close(payload):\n\tprint(\"_on_Socket_close: \", \" \", payload)\n\nfunc _on_Socket_error(payload):\n\tprint(\"_on_Socket_error: \", \" \", payload)\n\nfunc _on_Socket_connecting(is_connecting):\n\tprint(\"_on_Socket_connecting: \", \" \", is_connecting)\n\n#\n# Channel events\n#\n\nfunc _on_Channel_event(event, payload, status):\n\tprint(\"_on_Channel_event:  \", event, \", \", status, \", \", payload)\n\nfunc _on_Channel_join_result(status, result):\n\tprint(\"_on_Channel_join_result:  \", status, result)\n\nfunc _on_Channel_error(error):\n\tprint(\"_on_Channel_error: \" + str(error))\n\nfunc _on_Channel_close(closed):\n\tprint(\"_on_Channel_close: \" + str(closed))\n\n#\n# Presence events\n#\n\nfunc _on_Presence_join(joins):\n\tprint(\"_on_Presence_join: \" + str(joins))\n\nfunc _on_Presence_leave(leaves):\n\tprint(\"_on_Presence_leave: \" + str(leaves))\n\n```\n\nPush messages to the server:\n```gdscript\nchannel.push(\"event_name\", {some: \"param\"})\n```\n\nBroadcasts and push replies are received in the event `PhoenixChannel.on_event`:\n```gdscript\nchannel.connect(\"on_event\", self, \"_on_Channel_event\")\n\nfunc _on_Channel_event(event, payload, status):\n\tprint(\"_on_channel_event:  \", event, \", \", status, \", \", payload)\n```\n\n## TODO\nSee the [issues](https://github.com/alfredbaudisch/GodotPhoenixChannels/issues), but mostly:\n- [ ] Game example\n- [ ] Channel push buffer\n- [ ] Socket push buffer\n\n## Additional facts about Elixir\n\nAs it was shown above, Elixir leverages [Erlang](https://en.wikipedia.org/wiki/Erlang_(programming_language)), which itself is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance.\n\nErlang is some 30 years old, built by Ericsson. To give you some context: Ericsson has 45% of the mobile satellite infrastructure in the world. If you are using data in your mobile phone you are certainly in some stage of the day using an equipment that uses Erlang ([Source](https://www.youtube.com/watch?v=Zf51VOjIVCQ)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfredbaudisch%2Fgodotphoenixchannels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfredbaudisch%2Fgodotphoenixchannels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfredbaudisch%2Fgodotphoenixchannels/lists"}