{"id":22680523,"url":"https://github.com/andrehrferreira/csharp-bytebuffer","last_synced_at":"2025-04-12T15:52:58.994Z","repository":{"id":254494409,"uuid":"822424677","full_name":"andrehrferreira/csharp-bytebuffer","owner":"andrehrferreira","description":"Class for reading and writing binary communication and buffers in C#","archived":false,"fork":false,"pushed_at":"2024-08-23T19:48:16.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T10:21:25.554Z","etag":null,"topics":["bytebuffer","bytebufferpool","bytes","csharp"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrehrferreira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-07-01T06:10:17.000Z","updated_at":"2024-10-11T23:07:24.000Z","dependencies_parsed_at":"2024-08-23T21:13:14.917Z","dependency_job_id":null,"html_url":"https://github.com/andrehrferreira/csharp-bytebuffer","commit_stats":null,"previous_names":["andrehrferreira/csharp-bytebuffer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrehrferreira%2Fcsharp-bytebuffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrehrferreira%2Fcsharp-bytebuffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrehrferreira%2Fcsharp-bytebuffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrehrferreira%2Fcsharp-bytebuffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrehrferreira","download_url":"https://codeload.github.com/andrehrferreira/csharp-bytebuffer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248592086,"owners_count":21130175,"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":["bytebuffer","bytebufferpool","bytes","csharp"],"created_at":"2024-12-09T19:13:56.960Z","updated_at":"2025-04-12T15:52:58.940Z","avatar_url":"https://github.com/andrehrferreira.png","language":"C#","readme":"# Tales Of Shadowland - Byte Buffer C#\r\n\r\n`@tos/bytebuffer` is a lightweight and efficient library for managing binary data in C#. It provides functionalities for reading, writing, queuing, and pooling buffers, along with support for generic network connectors (TCP, UDP, WebSocket).\r\n\r\n## Features\r\n\r\n- Efficient binary data manipulation with `ByteBuffer`.\r\n- Buffer aggregation with `QueueBuffer` to reduce header overhead.\r\n- Buffer pooling with `ByteBufferPool` to optimize memory allocation in high-frequency systems.\r\n- Interface for generic network connectors supporting TCP, UDP, and WebSocket.\r\n\r\n## Usage Example\r\n\r\nHere is a basic example of how to use the API provided by the library for binary buffer manipulation:\r\n\r\n```csharp\r\nusing Server;\r\n\r\nclass Program\r\n{\r\n    static void Main()\r\n    {\r\n        // Initializing a ByteBuffer\r\n        ByteBuffer buffer = new ByteBuffer();\r\n        buffer.PutInt32(1234).PutString(\"Hello, ByteBuffer!\");\r\n\r\n        int num = buffer.GetInt32();\r\n        string str = buffer.GetString();\r\n\r\n        Console.WriteLine(num);  // 1234\r\n        Console.WriteLine(str);  // \"Hello, ByteBuffer!\"\r\n\r\n        // Using ByteBufferPool to manage buffers\r\n        ByteBufferPool pool = new ByteBufferPool();\r\n        ByteBuffer pooledBuffer = ConcurrentByteBufferPool.Acquire();\r\n        pooledBuffer.PutFloat(3.14f);\r\n        ConcurrentByteBufferPool.Release(pooledBuffer);\r\n\r\n        // Aggregating buffers with QueueBuffer (if implemented)\r\n        // This would combine multiple ByteBuffers into one larger buffer\r\n    }\r\n}\r\n```\r\n\r\n## API\r\n\r\n### ByteBuffer\r\nThe main class for managing binary data in C#. It provides methods for reading and writing various types of binary data.\r\n\r\n- **PutInt32(int value): ByteBuffer**: Inserts a 32-bit integer into the buffer.\r\n- **GetInt32(): int**: Reads a 32-bit integer from the buffer.\r\n- **PutString(string value): ByteBuffer**: Inserts a UTF-8 encoded string into the buffer.\r\n- **GetString(): string**: Reads a UTF-8 encoded string from the buffer.\r\n- **Reset(): void**: Resets the buffer's position for reuse and clears its contents.\r\n\r\n### ByteBufferPool\r\nManages a pool of ByteBuffer instances to avoid frequent memory allocations, optimizing performance in high-load systems.\r\n\r\n- **Acquire(): ByteBuffer**: Retrieves a buffer from the pool or creates a new one if necessary.\r\n- **Release(ByteBuffer buffer): void**: Returns a buffer to the pool, making it available for reuse.\r\n\r\n### ConcurrentByteBufferPool\r\nA thread-local buffer pool that optimizes the use of ByteBuffer instances in multithreaded environments.\r\n\r\n- **Acquire(): ByteBuffer**: Acquires a ByteBuffer from the pool, either locally or from the global pool.\r\n- **Release(ByteBuffer buffer): void**: Releases a buffer to the thread-local pool.\r\n- **Merge(): void**: Merges the local buffer pool back into the global pool.\r\n- **Clear(): ByteBuffer**: Clears the global buffer pool and returns the removed buffers.\r\n\r\n### QueueBuffer\r\nAggregates multiple binary buffers to reduce overhead in packet transmissions.\r\n\r\n- **Enqueue(ByteBuffer buffer): void**: Adds a buffer to the queue.\r\n- **Combine(): ByteBuffer**: Combines all enqueued buffers into a single buffer (not implemented in this example but could be added if needed).\r\n\r\n## Contribution\r\n\r\nContributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.\r\n\r\n## License\r\n\r\nThis project is licensed under the [MIT License](LICENSE).\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrehrferreira%2Fcsharp-bytebuffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrehrferreira%2Fcsharp-bytebuffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrehrferreira%2Fcsharp-bytebuffer/lists"}