{"id":21296922,"url":"https://github.com/reddec/notify","last_synced_at":"2025-03-15T17:27:43.871Z","repository":{"id":81702641,"uuid":"38937161","full_name":"reddec/notify","owner":"reddec","description":"Multicast notification library on C","archived":false,"fork":false,"pushed_at":"2015-07-12T10:19:22.000Z","size":296,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-09T00:06:40.015Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reddec.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}},"created_at":"2015-07-11T19:05:01.000Z","updated_at":"2015-07-11T19:44:48.000Z","dependencies_parsed_at":"2023-03-13T20:07:37.062Z","dependency_job_id":null,"html_url":"https://github.com/reddec/notify","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/reddec%2Fnotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fnotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fnotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fnotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reddec","download_url":"https://codeload.github.com/reddec/notify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243765035,"owners_count":20344524,"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-11-21T14:31:00.009Z","updated_at":"2025-03-15T17:27:43.838Z","avatar_url":"https://github.com/reddec.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# notify\nMulticast notification library on C\n\nSee full documentation in doc/html or by `man notify.h`.\n\n\nExample (in examples/example.cpp):\n\nSend notification\n\n```C\n// Allocate buffer for `title` field\nchar title[__NOTIFY_MAX_TITLE_LEN];\n// Allocate buffer for `format` field\nchar format[__NOTIFY_MAX_FORMAT_LEN];\n// Allocate buffer for `payload\nchar data[__NOTIFY_MAX_DATA_LEN];\nstd::cout \u003c\u003c \"Format: \";\n// Read `format` from stdin (console input)\nstd::cin \u003e\u003e format;\nstd::cout \u003c\u003c \"Title: \";\n// Read `title` from stdin (console input)\nstd::cin \u003e\u003e title;\nstd::cout \u003c\u003c \"Data: \";\n// Read payload from stdin (console input)\nstd::cin \u003e\u003e data;\n// Create UDP socket\nint sender = socket(AF_INET, SOCK_DGRAM, 0);\nnotify_setup_emitter(sender, 0, 19999);\n// Send notification (as text)\nssize_t bytes = notify_text(sender, format, title, data);\nstd::clog \u003c\u003c \"Sent \" \u003c\u003c bytes \u003c\u003c \" bytes\" \u003c\u003c std::endl;\n// Close socket\nclose(sender);\n```\n\nReceive notification\n\n```C\n// Allocate buffer for packet\nchar buffer[__NOTIFY_PACKET_LIMIT];\nssize_t pack_size;\n// Set timeout (5 seconds)\nsize_t tm_ms = 5000;\n// Create UDP socket\nint listener = socket(AF_INET, SOCK_DGRAM, 0);\n// Prepare socket\nnotify_setup_listener(listener, 0, 19999);\n// Read one by one packet till timeout exception or internal socket error\nwhile ((pack_size = notify_collect(listener, tm_ms, buffer, sizeof(buffer))) \u003e 0) {\n    std::cout \u003c\u003c \"Packet size: \" \u003c\u003c pack_size \u003c\u003c std::endl;\n    // Parse packet to structure\n    notify_packet_t pp = notify_parse_packet(buffer, pack_size);\n    std::cout \u003c\u003c \"Format: \";\n    // Check field `format`. If packet not contains this filed (or it has incorrect end symbol), it will be NULL\n    if (pp.format != NULL)\n        std::cout \u003c\u003c pp.format \u003c\u003c std::endl;\n    else\n        std::cout \u003c\u003c \"\u003cno format field\u003e\" \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Title: \";\n    // Check field `title`. If packet not contains this filed (or it has incorrect end symbol), it will be NULL\n    if (pp.title != NULL)\n        std::cout \u003c\u003c pp.title \u003c\u003c std::endl;\n    else\n        std::cout \u003c\u003c \"\u003cno title field\u003e\" \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Data (\" \u003c\u003c pp.data_size \u003c\u003c \" bytes): \";\n    std::cout.write(pp.data, pp.data_size);\n    std::cout \u003c\u003c std::endl;\n}\n// Close socket\nclose(listener);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freddec%2Fnotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freddec%2Fnotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freddec%2Fnotify/lists"}