{"id":17055936,"url":"https://github.com/mazyod/phoenixsharp","last_synced_at":"2026-02-14T13:05:49.504Z","repository":{"id":13536792,"uuid":"74701066","full_name":"Mazyod/PhoenixSharp","owner":"Mazyod","description":"C# Phoenix Channels client. Unity Compatible.","archived":false,"fork":false,"pushed_at":"2026-01-30T15:18:13.000Z","size":842,"stargazers_count":171,"open_issues_count":2,"forks_count":28,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-01-31T07:06:50.711Z","etag":null,"topics":["csharp","networking","phoenix","phoenix-framework","presence","realtime","unity","unity3d","websockets"],"latest_commit_sha":null,"homepage":"","language":"C#","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/Mazyod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-11-24T19:47:16.000Z","updated_at":"2026-01-30T15:18:17.000Z","dependencies_parsed_at":"2025-07-03T19:35:30.328Z","dependency_job_id":"4c493700-9124-4202-9af5-c93c86857596","html_url":"https://github.com/Mazyod/PhoenixSharp","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Mazyod/PhoenixSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mazyod%2FPhoenixSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mazyod%2FPhoenixSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mazyod%2FPhoenixSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mazyod%2FPhoenixSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mazyod","download_url":"https://codeload.github.com/Mazyod/PhoenixSharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mazyod%2FPhoenixSharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29444108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T12:43:28.304Z","status":"ssl_error","status_checked_at":"2026-02-14T12:43:14.160Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["csharp","networking","phoenix","phoenix-framework","presence","realtime","unity","unity3d","websockets"],"created_at":"2024-10-14T10:22:46.951Z","updated_at":"2026-02-14T13:05:49.499Z","avatar_url":"https://github.com/Mazyod.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"340\" height=\"271\" alt=\"phoenix-sharp-splash\" src=\"https://github.com/user-attachments/assets/3977a485-02cb-49a4-b484-b3320d21355a\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Mazyod/PhoenixSharp/actions/workflows/dotnet.yml\"\u003e\u003cimg src=\"https://github.com/Mazyod/PhoenixSharp/actions/workflows/dotnet.yml/badge.svg\" alt=\".NET\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/Mazyod/PhoenixSharp\"\u003e\u003cimg src=\"https://codecov.io/gh/Mazyod/PhoenixSharp/branch/master/graph/badge.svg\" alt=\"codecov\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.nuget.org/packages/PhoenixSharp\"\u003e\u003cimg src=\"https://img.shields.io/nuget/v/PhoenixSharp\" alt=\"NuGet\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://openupm.com/packages/io.level3.phoenixsharp/\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/io.level3.phoenixsharp?label=openupm\u0026registry_uri=https://package.openupm.com\" alt=\"OpenUPM\" /\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/netstandard-2.0-blue\" alt=\"netstandard 2.0\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eA C# client for Phoenix Channels.\u003c/strong\u003e\u003cbr\u003e\n  Unity compatible. Powering \u003ca href=\"http://level3.io\"\u003eDama King\u003c/a\u003e.\n\u003c/p\u003e\n\n---\n\n## Features\n\n- Full [Phoenix Channels](https://hexdocs.pm/phoenix/channels.html) protocol support\n- Modern async/await API with cancellation support\n- Automatic reconnection and channel rejoin\n- Presence tracking\n- Customizable WebSocket and JSON implementations\n- Unity and .NET Standard 2.0 compatible\n\n## Installation\n\n### NuGet\n\n```bash\ndotnet add package PhoenixSharp\n```\n\n### Unity (OpenUPM)\n\nInstall via [openupm-cli](https://github.com/openupm/openupm-cli#openupm-cli):\n\n```bash\nopenupm add io.level3.phoenixsharp\n```\n\nOr add manually to `Packages/manifest.json`:\n\n```json\n{\n  \"scopedRegistries\": [\n    {\n      \"name\": \"package.openupm.com\",\n      \"url\": \"https://package.openupm.com\",\n      \"scopes\": [\"io.level3\"]\n    }\n  ],\n  \"dependencies\": {\n    \"io.level3.phoenixsharp\": \"1.3.1\"\n  }\n}\n```\n\nAlternatively, download the source and add it to your project, or use a Git submodule.\n\n## Quick Start\n\n```csharp\n// Create and connect a socket\nvar socket = new Socket(\n    \"wss://example.com/socket\",\n    new Socket.Options(new JsonMessageSerializer())\n);\nsocket.Connect();\n\n// Join a channel\nvar channel = socket.Channel(\"room:lobby\", new { userId = \"123\" });\nchannel.Join();\n\n// Listen for events\nchannel.On(\"new_message\", message =\u003e {\n    var payload = message.Payload.Unbox\u003cChatMessage\u003e();\n    Console.WriteLine($\"Received: {payload.Text}\");\n});\n\n// Send messages\nchannel.Push(\"send_message\", new { text = \"Hello!\" });\n```\n\n### Async API\n\n```csharp\nawait socket.ConnectAsync();\n\nvar result = await channel.JoinAsync();\nif (result.IsSuccess)\n{\n    var response = await channel.PushAsync\u003cChatMessage\u003e(\n        \"send_message\",\n        new { text = \"Hello!\" }\n    );\n    if (response.IsSuccess)\n        Console.WriteLine($\"Sent with id: {response.Response.Id}\");\n}\n\nawait channel.LeaveAsync();\n```\n\n## Documentation\n\n- [Migration Guide](https://github.com/Mazyod/PhoenixSharp/blob/master/Migration.md) - Upgrading from older versions\n- [Integration Tests](PhoenixTests/IntegrationTests.cs) - Complete usage examples\n\n### WebSocket Implementation\n\nThe library requires an `IWebsocket` implementation. Sample implementations are available in [`PhoenixTests/WebSocketImpl`](PhoenixTests/WebSocketImpl).\n\n```csharp\nvar factory = new MyWebSocketFactory();\nvar socket = new Socket(address, null, factory, options);\n```\n\n**Recommended implementations:**\n- **BestHTTP** (Unity) - See [`Reference/Unity/BestHTTP`](Reference/Unity/BestHTTP)\n- **WebSocketSharp** - Good cross-platform option\n- **System.Net.WebSockets** - Built-in .NET option\n\n### JSON Serialization\n\nThe default `JsonMessageSerializer` uses [Newtonsoft.Json](https://www.newtonsoft.com/json) with the [Phoenix V2 serialization format](https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/socket/serializers/v2_json_serializer.ex). To use a different serializer, implement `IMessageSerializer` and `IJsonBox`.\n\n```csharp\nvar options = new Socket.Options(new MyCustomSerializer());\n```\n\n### Presence\n\n```csharp\nvar presence = new Presence(channel);\n\npresence.OnJoin += (key, current, newPresence) =\u003e {\n    Console.WriteLine($\"{key} joined\");\n};\n\npresence.OnLeave += (key, current, leftPresence) =\u003e {\n    Console.WriteLine($\"{key} left\");\n};\n\n// Wait for initial state (async)\nawait presence.WaitForInitialSyncAsync();\n```\n\n## Unity Notes\n\nFor background on Unity's .NET support, see [Microsoft's Unity scripting documentation](https://docs.microsoft.com/en-us/visualstudio/gamedev/unity/unity-scripting-upgrade).\n\n### Threading\n\nBy default, callbacks use `System.Threading.Tasks` which works with Unity's `SynchronizationContext`. For more control, implement `IDelayedExecutor` (or use [UniTask](https://github.com/Cysharp/UniTask) for better performance):\n\n```csharp\nvar options = new Socket.Options(serializer)\n{\n    DelayedExecutor = new CoroutineDelayedExecutor()\n};\n```\n\nSee [`Reference/Unity`](Reference/Unity) for a coroutine-based implementation.\n\n### Recommended Libraries\n\n- **[BestHTTP](https://assetstore.unity.com/packages/tools/network/best-http-2-155981)** - Handles threading automatically\n- **[com.unity.nuget.newtonsoft-json](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.2/manual/index.html)** - Unity's official Newtonsoft.Json package\n\n## API Reference\n\n### Socket\n\n| Method | Description |\n|--------|-------------|\n| `Connect()` | Connect to the server |\n| `ConnectAsync()` | Connect asynchronously |\n| `Disconnect()` | Disconnect from the server |\n| `DisconnectAsync()` | Disconnect asynchronously |\n| `Channel(topic, params)` | Create a channel |\n\n### Channel\n\n| Method | Description |\n|--------|-------------|\n| `Join()` | Join the channel |\n| `JoinAsync()` | Join asynchronously, returns `JoinResult` |\n| `Leave()` | Leave the channel |\n| `LeaveAsync()` | Leave asynchronously |\n| `Push(event, payload)` | Send a message |\n| `PushAsync(event, payload)` | Send asynchronously, returns `PushResult` |\n| `PushAsync\u003cT\u003e(event, payload)` | Send with typed response |\n| `On(event, callback)` | Subscribe to events |\n| `Off(event)` | Unsubscribe from events |\n| `WaitForEventAsync(event)` | Wait for a single event |\n\n### Presence\n\n| Method | Description |\n|--------|-------------|\n| `OnJoin` | Event fired when a user joins |\n| `OnLeave` | Event fired when a user leaves |\n| `OnSync` | Event fired on state sync |\n| `WaitForInitialSyncAsync()` | Wait for initial presence state |\n| `WaitForUserAsync(key, timeout)` | Wait for a specific user |\n\n## Running Tests\n\n```bash\n# All tests\ndotnet test\n\n# Unit tests only\ndotnet test --filter \"Category!=Integration\"\n\n# Integration tests (requires server)\ndotnet test --filter \"Category=Integration\"\n```\n\nIntegration tests run against `phoenix-sharp.level3.io:3080`. Server source: [phoenix-integration-tester](https://github.com/Mazyod/phoenix-integration-tester)\n\n## Contributing\n\nIssues and pull requests are welcome!\n\n## License\n\nMIT\n\n## Author\n\nMaz (Mazyad Alabduljaleel)\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003csub\u003eLogo is a mix of Unity and Phoenix logos. Please don't sue me.\u003c/sub\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazyod%2Fphoenixsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmazyod%2Fphoenixsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazyod%2Fphoenixsharp/lists"}