BlueProtocol 0.4.0
See the version list below for details.
dotnet add package BlueProtocol --version 0.4.0
NuGet\Install-Package BlueProtocol -Version 0.4.0
<PackageReference Include="BlueProtocol" Version="0.4.0" />
<PackageVersion Include="BlueProtocol" Version="0.4.0" />
<PackageReference Include="BlueProtocol" />
paket add BlueProtocol --version 0.4.0
#r "nuget: BlueProtocol, 0.4.0"
#:package BlueProtocol@0.4.0
#addin nuget:?package=BlueProtocol&version=0.4.0
#tool nuget:?package=BlueProtocol&version=0.4.0
๐ต BlueProtocol
BlueProtocol is a C# library designed to provide a high-level interface for TCP communication, particularly recommended in domains where speed is a critical factor, not necessarily limited to video games. It offers a lightweight, bidirectional request system that maintains a persistent connection between peers to minimize response times. The library is currently being developed to function in a decentralized network.
โ Why BlueProtocol and not HTTP?
HTTP, while widely used, is not optimized for real-time communication required in many video games. BlueProtocol provides a more efficient, low-latency communication mechanism tailored for interactive applications. By maintaining persistent connections and using lightweight requests and events, BlueProtocol reduces overhead and improves responsiveness.
โ๏ธ How does BlueProtocol work?
BlueProtocol allows communication between clients and servers through two main components: requests and events. Clients send requests for specific actions to the server, which processes these requests and sends back responses indicating success or failure. Events are used by the server to notify clients of changes, ensuring all clients remain synchronized.
๐ Async vs. Sync: Differences and Recommendations
- AsyncClient: Used on the server-side, executes code asynchronously upon receiving a request using
Task.Run - to avoid blocking the main thread.
- SyncClient: Used on the client-side, stores incoming requests in a thread-safe list and processes them during the
Updatecall, making it suitable for Unityโs main thread.
๐ก Recommendation:
Use AsyncClient for server-side operations to handle multiple client requests efficiently without blocking.
UseSyncClient on the client-side to ensure smooth integration with Unityโs single-threaded update loop.
๐ Communication Between Peers
- Requests: A client sends a request to the server to perform an action.
- The server processes the request and returns a response.
- Events: The server sends events to clients to notify them of changes or updates (e.g., a game element moving).
- Clients handle these events to stay synchronized.
๐ค Requests vs. Events
- Request: A message sent from a client to the server that expects a response. Used for actions where confirmation is needed.
- Event: A one-way message sent from the server to clients. No response is expected. Used for notifications or updates.
๐น๏ธ What is a Controller and How Does it Work?
A Controller is a class that handles specific types of requests and events.
It contains methods marked with [OnRequest] or [OnEvent] attributes to process incoming messages.
When a request or event is received, the corresponding method in the controller is invoked to handle it.
๐ฆ Installation
To install the BlueProtocol library, follow these steps:
Using .NET CLI: Run the following command to add the BlueProtocol package to your project.
dotnet add package BlueProtocol --version latestUsing GitHub Releases: Visit the Releases page on the BlueProtocol GitHub repository. Download the latest release package and follow the instructions provided in the release notes to add it to your project manually.
These methods ensure that you have the latest version of BlueProtocol installed and ready to use in your .NET project.
๐ Example Projects
SimpleCount
SimpleCount demonstrates the use of the BlueProtocol library for TCP communication between a server and a client. The server listens for incoming messages and logs each received message, while the client sends a series of count requests to the server.
SimpleRepeat
SimpleRepeat demonstrates the use of the BlueProtocol library for TCP communication between multiple "bots". Each bot connects directly to other bots, sends and receives messages, and prints the received messages to the console via a port scan starting from the StartingPort defined in the configuration.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
[+] Server-side shields