{"action":"created","comment":{"url":"https://api.github.com/repos/cuberite/cuberite/pulls/comments/73449302","id":73449302,"diff_hunk":"@@ -0,0 +1,210 @@\n+// ChannelManager.cpp\n+\n+// Implements the cChannelManager class which stores and calls channel callbacks\n+\n+#include \"Globals.h\"  // NOTE: MSVC stupidness requires this to be the same across all modules\n+\n+#include <algorithm>\n+\n+#include \"ChannelManager.h\"\n+#include \"ChannelCallback.h\"\n+#include \"ClientHandle.h\"\n+#include \"Entities/Player.h\"\n+#include \"OSSupport/CriticalSection.h\"\n+#include \"World.h\"\n+\n+\n+class cChannelBroadcastCallback : public cPlayerListCallback\n+{\n+\tAString m_Channel;\n+\tAString m_Data;\n+public:\n+\tcChannelBroadcastCallback(const AString & a_Channel, const AString & a_Data)\n+\t: m_Channel(a_Channel), m_Data(a_Data){}\n+\n+\tvirtual bool Item(cPlayer * a_Type)\n+\t{\n+\t\tcClientHandle * Handle = a_Type->GetClientHandle();\n+\t\tif (Handle->HasPluginChannel(m_Channel))\n+\t\t{\n+\t\t\tHandle->SendPluginMessage(m_Channel, m_Data);\n+\t\t}\n+\t\treturn false;\n+\t}\n+};\n+\n+\n+\n+\n+\n+bool cChannelManager::RegisterChannel(const AString & a_Channel, cChannelCallbackPtr a_Callback)\n+{\n+\tcCSLock Lock(m_CSCallbacks);\n+\tif (m_ChannelCallbacks.find(a_Channel) == m_ChannelCallbacks.end())\n+\t{\n+\t\tm_ChannelCallbacks.insert(std::make_pair(a_Channel, a_Callback));\n+\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n+\n+\n+\n+\n+\n+bool cChannelManager::RemoveChannel(const AString & a_Channel)\n+{\n+\tcCSLock Lock(m_CSCallbacks);\n+\tauto callback = m_ChannelCallbacks.find(a_Channel);\n+\tif (callback != m_ChannelCallbacks.end())\n+\t{\n+\t\tm_ChannelCallbacks.erase(callback);\n+\t\treturn true;\n+\t}\n+\treturn false;\n+}\n+\n+\n+\n+\n+\n+void cChannelManager::AddClientToChannel(cClientHandle & a_Client, const AString & a_Channel)\n+{\n+\ta_Client.RegisterChannel(a_Channel);\n+\ta_Client.SendPluginMessage(\"REGISTER\", a_Channel);\n+}\n+\n+\n+\n+\n+\n+void cChannelManager::AddClientToChannels(cClientHandle & a_Client, const AString & a_Channels)\n+{\n+\tauto channels = BreakApartChannels(a_Channels);\n+\ta_Client.RegisterChannels(channels);\n+}\n+\n+\n+\n+\n+\n+void cChannelManager::RemoveClientFromChannel(cClientHandle & a_Client, const AString & a_Channel)\n+{\n+\ta_Client.UnregisterChannel(a_Channel);\n+\ta_Client.SendPluginMessage(\"UNREGISTER\", a_Channel);\n+}\n+\n+\n+\n+\n+\n+void cChannelManager::RemoveClientFromChannels(cClientHandle & a_Client, const AString & a_Channels)\n+{\n+\tauto channels = BreakApartChannels(a_Channels);\n+\ta_Client.UnregisterChannels(channels);\n+}\n+\n+\n+\n+\n+\n+bool cChannelManager::ClientHasChannel(cClientHandle & a_Client, const AString & a_Channel)","path":"src/ChannelManager.cpp","position":112,"original_position":112,"commit_id":"d2306da1ac055e5c0fe5abf4bbe67b4ca158c519","original_commit_id":"d2306da1ac055e5c0fe5abf4bbe67b4ca158c519","user":{"login":"SamJBarney","id":1827860,"avatar_url":"https://avatars.githubusercontent.com/u/1827860?v=3","gravatar_id":"","url":"https://api.github.com/users/SamJBarney","html_url":"https://github.com/SamJBarney","followers_url":"https://api.github.com/users/SamJBarney/followers","following_url":"https://api.github.com/users/SamJBarney/following{/other_user}","gists_url":"https://api.github.com/users/SamJBarney/gists{/gist_id}","starred_url":"https://api.github.com/users/SamJBarney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamJBarney/subscriptions","organizations_url":"https://api.github.com/users/SamJBarney/orgs","repos_url":"https://api.github.com/users/SamJBarney/repos","events_url":"https://api.github.com/users/SamJBarney/events{/privacy}","received_events_url":"https://api.github.com/users/SamJBarney/received_events","type":"User","site_admin":false},"body":"Well, the majority of this code was written to be a halfway point. Right now it just merely wraps code in cClientHandle. However, someone was working on moving cClientHandles to being managed by the server, and I wanted to move all channel related code and data into cChannelManager. I don't know if that move has been accomplished or not, so I wanted to leave it at this halfway point until I know for certain.","created_at":"2016-08-04T01:14:44Z","updated_at":"2016-08-04T01:14:44Z","html_url":"https://github.com/cuberite/cuberite/pull/3292#discussion_r73449302","pull_request_url":"https://api.github.com/repos/cuberite/cuberite/pulls/3292","_links":{"self":{"href":"https://api.github.com/repos/cuberite/cuberite/pulls/comments/73449302"},"html":{"href":"https://github.com/cuberite/cuberite/pull/3292#discussion_r73449302"},"pull_request":{"href":"https://api.github.com/repos/cuberite/cuberite/pulls/3292"}}},"pull_request":{"url":"https://api.github.com/repos/cuberite/cuberite/pulls/3292","id":79772821,"html_url":"https://github.com/cuberite/cuberite/pull/3292","diff_url":"https://github.com/cuberite/cuberite/pull/3292.diff","patch_url":"https://github.com/cuberite/cuberite/pull/3292.patch","issue_url":"https://api.github.com/repos/cuberite/cuberite/issues/3292","number":3292,"state":"open","locked":false,"title":"Channel management","user":{"login":"SamJBarney","id":1827860,"avatar_url":"https://avatars.githubusercontent.com/u/1827860?v=3","gravatar_id":"","url":"https://api.github.com/users/SamJBarney","html_url":"https://github.com/SamJBarney","followers_url":"https://api.github.com/users/SamJBarney/followers","following_url":"https://api.github.com/users/SamJBarney/following{/other_user}","gists_url":"https://api.github.com/users/SamJBarney/gists{/gist_id}","starred_url":"https://api.github.com/users/SamJBarney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamJBarney/subscriptions","organizations_url":"https://api.github.com/users/SamJBarney/orgs","repos_url":"https://api.github.com/users/SamJBarney/repos","events_url":"https://api.github.com/users/SamJBarney/events{/privacy}","received_events_url":"https://api.github.com/users/SamJBarney/received_events","type":"User","site_admin":false},"body":"Allows lua plugins to register handles for channel messages.\r\n* Only one handle can be registered for one channel at a time.\r\n* Plugins can also add and remove clients from channels, sending the appropriate packet to the client","created_at":"2016-08-02T17:10:28Z","updated_at":"2016-08-04T01:14:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73f5782481364f9de3b41dee7a79b491623d8e84","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cuberite/cuberite/pulls/3292/commits","review_comments_url":"https://api.github.com/repos/cuberite/cuberite/pulls/3292/comments","review_comment_url":"https://api.github.com/repos/cuberite/cuberite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cuberite/cuberite/issues/3292/comments","statuses_url":"https://api.github.com/repos/cuberite/cuberite/statuses/d2306da1ac055e5c0fe5abf4bbe67b4ca158c519","head":{"label":"cuberite:ChannelManagement","ref":"ChannelManagement","sha":"d2306da1ac055e5c0fe5abf4bbe67b4ca158c519","user":{"login":"cuberite","id":8973961,"avatar_url":"https://avatars.githubusercontent.com/u/8973961?v=3","gravatar_id":"","url":"https://api.github.com/users/cuberite","html_url":"https://github.com/cuberite","followers_url":"https://api.github.com/users/cuberite/followers","following_url":"https://api.github.com/users/cuberite/following{/other_user}","gists_url":"https://api.github.com/users/cuberite/gists{/gist_id}","starred_url":"https://api.github.com/users/cuberite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuberite/subscriptions","organizations_url":"https://api.github.com/users/cuberite/orgs","repos_url":"https://api.github.com/users/cuberite/repos","events_url":"https://api.github.com/users/cuberite/events{/privacy}","received_events_url":"https://api.github.com/users/cuberite/received_events","type":"Organization","site_admin":false},"repo":{"id":11693709,"name":"cuberite","full_name":"cuberite/cuberite","owner":{"login":"cuberite","id":8973961,"avatar_url":"https://avatars.githubusercontent.com/u/8973961?v=3","gravatar_id":"","url":"https://api.github.com/users/cuberite","html_url":"https://github.com/cuberite","followers_url":"https://api.github.com/users/cuberite/followers","following_url":"https://api.github.com/users/cuberite/following{/other_user}","gists_url":"https://api.github.com/users/cuberite/gists{/gist_id}","starred_url":"https://api.github.com/users/cuberite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuberite/subscriptions","organizations_url":"https://api.github.com/users/cuberite/orgs","repos_url":"https://api.github.com/users/cuberite/repos","events_url":"https://api.github.com/users/cuberite/events{/privacy}","received_events_url":"https://api.github.com/users/cuberite/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cuberite/cuberite","description":"A custom Minecraft compatible game server written in C++","fork":false,"url":"https://api.github.com/repos/cuberite/cuberite","forks_url":"https://api.github.com/repos/cuberite/cuberite/forks","keys_url":"https://api.github.com/repos/cuberite/cuberite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cuberite/cuberite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cuberite/cuberite/teams","hooks_url":"https://api.github.com/repos/cuberite/cuberite/hooks","issue_events_url":"https://api.github.com/repos/cuberite/cuberite/issues/events{/number}","events_url":"https://api.github.com/repos/cuberite/cuberite/events","assignees_url":"https://api.github.com/repos/cuberite/cuberite/assignees{/user}","branches_url":"https://api.github.com/repos/cuberite/cuberite/branches{/branch}","tags_url":"https://api.github.com/repos/cuberite/cuberite/tags","blobs_url":"https://api.github.com/repos/cuberite/cuberite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cuberite/cuberite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cuberite/cuberite/git/refs{/sha}","trees_url":"https://api.github.com/repos/cuberite/cuberite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cuberite/cuberite/statuses/{sha}","languages_url":"https://api.github.com/repos/cuberite/cuberite/languages","stargazers_url":"https://api.github.com/repos/cuberite/cuberite/stargazers","contributors_url":"https://api.github.com/repos/cuberite/cuberite/contributors","subscribers_url":"https://api.github.com/repos/cuberite/cuberite/subscribers","subscription_url":"https://api.github.com/repos/cuberite/cuberite/subscription","commits_url":"https://api.github.com/repos/cuberite/cuberite/commits{/sha}","git_commits_url":"https://api.github.com/repos/cuberite/cuberite/git/commits{/sha}","comments_url":"https://api.github.com/repos/cuberite/cuberite/comments{/number}","issue_comment_url":"https://api.github.com/repos/cuberite/cuberite/issues/comments{/number}","contents_url":"https://api.github.com/repos/cuberite/cuberite/contents/{+path}","compare_url":"https://api.github.com/repos/cuberite/cuberite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cuberite/cuberite/merges","archive_url":"https://api.github.com/repos/cuberite/cuberite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cuberite/cuberite/downloads","issues_url":"https://api.github.com/repos/cuberite/cuberite/issues{/number}","pulls_url":"https://api.github.com/repos/cuberite/cuberite/pulls{/number}","milestones_url":"https://api.github.com/repos/cuberite/cuberite/milestones{/number}","notifications_url":"https://api.github.com/repos/cuberite/cuberite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cuberite/cuberite/labels{/name}","releases_url":"https://api.github.com/repos/cuberite/cuberite/releases{/id}","deployments_url":"https://api.github.com/repos/cuberite/cuberite/deployments","created_at":"2013-07-26T19:56:59Z","updated_at":"2016-08-01T19:22:09Z","pushed_at":"2016-08-03T09:48:11Z","git_url":"git://github.com/cuberite/cuberite.git","ssh_url":"git@github.com:cuberite/cuberite.git","clone_url":"https://github.com/cuberite/cuberite.git","svn_url":"https://github.com/cuberite/cuberite","homepage":"http://cuberite.org","size":161066,"stargazers_count":1399,"watchers_count":1399,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":319,"mirror_url":null,"open_issues_count":520,"forks":319,"open_issues":520,"watchers":1399,"default_branch":"master"}},"base":{"label":"cuberite:master","ref":"master","sha":"032dafd7fdfedeab15e54d8737fffb10e9437198","user":{"login":"cuberite","id":8973961,"avatar_url":"https://avatars.githubusercontent.com/u/8973961?v=3","gravatar_id":"","url":"https://api.github.com/users/cuberite","html_url":"https://github.com/cuberite","followers_url":"https://api.github.com/users/cuberite/followers","following_url":"https://api.github.com/users/cuberite/following{/other_user}","gists_url":"https://api.github.com/users/cuberite/gists{/gist_id}","starred_url":"https://api.github.com/users/cuberite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuberite/subscriptions","organizations_url":"https://api.github.com/users/cuberite/orgs","repos_url":"https://api.github.com/users/cuberite/repos","events_url":"https://api.github.com/users/cuberite/events{/privacy}","received_events_url":"https://api.github.com/users/cuberite/received_events","type":"Organization","site_admin":false},"repo":{"id":11693709,"name":"cuberite","full_name":"cuberite/cuberite","owner":{"login":"cuberite","id":8973961,"avatar_url":"https://avatars.githubusercontent.com/u/8973961?v=3","gravatar_id":"","url":"https://api.github.com/users/cuberite","html_url":"https://github.com/cuberite","followers_url":"https://api.github.com/users/cuberite/followers","following_url":"https://api.github.com/users/cuberite/following{/other_user}","gists_url":"https://api.github.com/users/cuberite/gists{/gist_id}","starred_url":"https://api.github.com/users/cuberite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuberite/subscriptions","organizations_url":"https://api.github.com/users/cuberite/orgs","repos_url":"https://api.github.com/users/cuberite/repos","events_url":"https://api.github.com/users/cuberite/events{/privacy}","received_events_url":"https://api.github.com/users/cuberite/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cuberite/cuberite","description":"A custom Minecraft compatible game server written in C++","fork":false,"url":"https://api.github.com/repos/cuberite/cuberite","forks_url":"https://api.github.com/repos/cuberite/cuberite/forks","keys_url":"https://api.github.com/repos/cuberite/cuberite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cuberite/cuberite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cuberite/cuberite/teams","hooks_url":"https://api.github.com/repos/cuberite/cuberite/hooks","issue_events_url":"https://api.github.com/repos/cuberite/cuberite/issues/events{/number}","events_url":"https://api.github.com/repos/cuberite/cuberite/events","assignees_url":"https://api.github.com/repos/cuberite/cuberite/assignees{/user}","branches_url":"https://api.github.com/repos/cuberite/cuberite/branches{/branch}","tags_url":"https://api.github.com/repos/cuberite/cuberite/tags","blobs_url":"https://api.github.com/repos/cuberite/cuberite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cuberite/cuberite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cuberite/cuberite/git/refs{/sha}","trees_url":"https://api.github.com/repos/cuberite/cuberite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cuberite/cuberite/statuses/{sha}","languages_url":"https://api.github.com/repos/cuberite/cuberite/languages","stargazers_url":"https://api.github.com/repos/cuberite/cuberite/stargazers","contributors_url":"https://api.github.com/repos/cuberite/cuberite/contributors","subscribers_url":"https://api.github.com/repos/cuberite/cuberite/subscribers","subscription_url":"https://api.github.com/repos/cuberite/cuberite/subscription","commits_url":"https://api.github.com/repos/cuberite/cuberite/commits{/sha}","git_commits_url":"https://api.github.com/repos/cuberite/cuberite/git/commits{/sha}","comments_url":"https://api.github.com/repos/cuberite/cuberite/comments{/number}","issue_comment_url":"https://api.github.com/repos/cuberite/cuberite/issues/comments{/number}","contents_url":"https://api.github.com/repos/cuberite/cuberite/contents/{+path}","compare_url":"https://api.github.com/repos/cuberite/cuberite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cuberite/cuberite/merges","archive_url":"https://api.github.com/repos/cuberite/cuberite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cuberite/cuberite/downloads","issues_url":"https://api.github.com/repos/cuberite/cuberite/issues{/number}","pulls_url":"https://api.github.com/repos/cuberite/cuberite/pulls{/number}","milestones_url":"https://api.github.com/repos/cuberite/cuberite/milestones{/number}","notifications_url":"https://api.github.com/repos/cuberite/cuberite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cuberite/cuberite/labels{/name}","releases_url":"https://api.github.com/repos/cuberite/cuberite/releases{/id}","deployments_url":"https://api.github.com/repos/cuberite/cuberite/deployments","created_at":"2013-07-26T19:56:59Z","updated_at":"2016-08-01T19:22:09Z","pushed_at":"2016-08-03T09:48:11Z","git_url":"git://github.com/cuberite/cuberite.git","ssh_url":"git@github.com:cuberite/cuberite.git","clone_url":"https://github.com/cuberite/cuberite.git","svn_url":"https://github.com/cuberite/cuberite","homepage":"http://cuberite.org","size":161066,"stargazers_count":1399,"watchers_count":1399,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":319,"mirror_url":null,"open_issues_count":520,"forks":319,"open_issues":520,"watchers":1399,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cuberite/cuberite/pulls/3292"},"html":{"href":"https://github.com/cuberite/cuberite/pull/3292"},"issue":{"href":"https://api.github.com/repos/cuberite/cuberite/issues/3292"},"comments":{"href":"https://api.github.com/repos/cuberite/cuberite/issues/3292/comments"},"review_comments":{"href":"https://api.github.com/repos/cuberite/cuberite/pulls/3292/comments"},"review_comment":{"href":"https://api.github.com/repos/cuberite/cuberite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cuberite/cuberite/pulls/3292/commits"},"statuses":{"href":"https://api.github.com/repos/cuberite/cuberite/statuses/d2306da1ac055e5c0fe5abf4bbe67b4ca158c519"}}}}
{"actor":{"display_login":"SamJBarney"}}