{"id":22202243,"url":"https://github.com/rumkin/poe","last_synced_at":"2025-06-25T19:39:10.225Z","repository":{"id":32380538,"uuid":"35956871","full_name":"rumkin/poe","owner":"rumkin","description":"Experimental TCP server","archived":false,"fork":false,"pushed_at":"2015-05-25T14:06:20.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T03:26:21.519Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rumkin.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}},"created_at":"2015-05-20T15:30:54.000Z","updated_at":"2015-05-20T15:31:58.000Z","dependencies_parsed_at":"2022-08-07T17:15:58.851Z","dependency_job_id":null,"html_url":"https://github.com/rumkin/poe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fpoe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fpoe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fpoe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fpoe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rumkin","download_url":"https://codeload.github.com/rumkin/poe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245383118,"owners_count":20606265,"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":[],"created_at":"2024-12-02T16:12:53.414Z","updated_at":"2025-03-25T01:42:27.359Z","avatar_url":"https://github.com/rumkin.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Poe is experimental data transport with customizable protocol. It allow to support\ndifferent data encodings and to switch protocol on the fly. It use asynchronous\nmode.\n\nCallback based example:\n\n```cpp\nPoe::Server * server = new Poe::Server([](Poe::Request * req, Poe::Response * res){\n    res.Write(\"Hello\", 5);\n});\n\nserver-\u003eStart(7000); // Start listening localhost port\n```\n\nFor example it allow to use some text protocol for connection establish and then\nto awitch connection to use HTTP:\n\n```cpp\nPoe::Server * server = new Poe::Server();\n\nserver-\u003eOnConnect([](Poe::Server * server, Poe::Connection * conn) {\n    conn-\u003eSetCodec(new Poe::Codec);\n});\n\nserver-\u003eOnDisconnect([](Poe::Server * server, Poe::Connection * conn) {\n    delete conn-\u003eGetCodec();\n});\n\nserver-\u003eStart(7000);\n\nwhile(server-\u003eIsRunning()) {\n    while(server-\u003eHasRequest()) {\n        Poe::Request req = server-\u003eGetRequest();\n        \n        if (req-\u003econn-\u003ecounter == 1) { // Switch after the first request\n            Poe::Pack * pack = reinterpret_cast\u003cPoe::Pack*\u003e(req-\u003edata);\n            \n            std::string str(pack-\u003edata, pack-\u003esize);\n            \n            if (str.compare(\"secret-value\") != 0) {\n                req-\u003econn-\u003eClose();\n                break;\n            }\n            \n            // Switch codec\n            delete req-\u003econn-\u003eGetCodec();\n            req-\u003econn-\u003eSetCodec(new HttpCodec());\n        } else {\n            HttpData * http = reinterpret_cast\u003cHttpData*\u003e(req-\u003edata);\n            \n            // Do something with HttpPackage\n            http-\u003eOnData([](char * data, size_t len) {\n                // Do something with http data\n            });\n            \n            http-\u003eOnEnd([](HttpData * data) {\n                delete data;\n            });\n        }\n        \n        delete req; // Destroy request object when unnecessary\n    }\n}\n\n```\n\nWhile HttpCodec is not implemented yet it only support default fixed length\ndata protocol encoding. In the future it became streaming and will support \nnested codecs to support multiple protocols incapsulation. For example\npack HTML or video stream into CBOR which wrapped into fixed length encoding.\n\n## Building\n\nFetch and build deps:\n\n```bash\nmake deps # Fetch dependencies\nmake build\n```\n\nOr build example:\n\n```bash\nmake deps\nmake example\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fpoe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frumkin%2Fpoe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fpoe/lists"}