{"action":"created","comment":{"url":"https://api.github.com/repos/eugenyk/hpcourse/pulls/comments/181302981","pull_request_review_id":111905438,"id":181302981,"diff_hunk":"@@ -0,0 +1,240 @@\n+using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Text;\n+using System.Threading.Tasks;\n+using System.Net;\n+using System.Net.Configuration;\n+using System.Net.Http;\n+using System.Net.Sockets;\n+using Google.Protobuf;\n+using System.Threading;\n+using Tutorial;\n+\n+public class Server {\n+  private static int port, cThreads;\n+  private static string hostName;\n+  private static List<List<Socket>> connections;\n+  private static bool _exit;\n+\n+  // signals\n+  public static AutoResetEvent allDone = new AutoResetEvent(false);\n+  public static AutoResetEvent sendDone = new AutoResetEvent(false);\n+  public AutoResetEvent receiveDone = new AutoResetEvent(false);\n+  public Message message;\n+\n+  public class StateObject{             \n+    public Socket workSocket = null;\n+    public bool sizeIsKnown=false;\n+    public int messageSize;\n+    public const int BufferSize = 256;\n+    public byte[] buffer = new byte[BufferSize];\n+    public byte[] mainBuffer = new byte[1024];\n+    public byte[] messageSizeBuffer = new byte[4];\n+    public int DataSize = 0;\n+    public int sizeOfMessageSizeBuffer = 0;\n+  }\n+\n+  public Server() {\n+    IPHostEntry host = Dns.GetHostEntry(hostName);\n+    IPAddress ip = host.AddressList[0];\n+    IPEndPoint endPoint = new IPEndPoint(ip, port);\n+    Socket server = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp);\n+\n+    try {\n+      server.Bind(endPoint);\n+      server.Listen(10);\n+\n+      while (true) {\n+        Console.WriteLine(\"Waiting for a connection...\"); \n+        server.BeginAccept(new AsyncCallback(AcceptCallback), server);  \n+        allDone.WaitOne();\n+      }\n+    }\n+    catch (Exception ex) {\n+      Console.Out.WriteLineAsync($\"Server error: {ex.ToString()}\");\n+    }\n+    finally {\n+      Console.ReadLine();\n+    }\n+  }\n+\n+  public static void AcceptCallback(IAsyncResult cbSocket) {\n+    var socket = (Socket)cbSocket.AsyncState;\n+    var tmpSocket = socket.EndAccept(cbSocket);\n+    AddConnection(tmpSocket);\n+  }\n+\n+  public static void AddConnection(Socket socket) {\n+    if (connections.Count < cThreads) {","path":"leti/2304/Sulyaev/chat/server.cs","position":69,"original_position":69,"commit_id":"1867198ee4ea43a7f959860ac56f78d363aa9171","original_commit_id":"1867198ee4ea43a7f959860ac56f78d363aa9171","user":{"login":"RomanSulyaev","id":12670130,"avatar_url":"https://avatars2.githubusercontent.com/u/12670130?v=4","gravatar_id":"","url":"https://api.github.com/users/RomanSulyaev","html_url":"https://github.com/RomanSulyaev","followers_url":"https://api.github.com/users/RomanSulyaev/followers","following_url":"https://api.github.com/users/RomanSulyaev/following{/other_user}","gists_url":"https://api.github.com/users/RomanSulyaev/gists{/gist_id}","starred_url":"https://api.github.com/users/RomanSulyaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomanSulyaev/subscriptions","organizations_url":"https://api.github.com/users/RomanSulyaev/orgs","repos_url":"https://api.github.com/users/RomanSulyaev/repos","events_url":"https://api.github.com/users/RomanSulyaev/events{/privacy}","received_events_url":"https://api.github.com/users/RomanSulyaev/received_events","type":"User","site_admin":false},"body":"да, потому что в таком случае пул разобьется на два списка, содержащих возможные подключения(по 50 на каждый)","created_at":"2018-04-13T07:14:40Z","updated_at":"2018-04-13T07:14:40Z","html_url":"https://github.com/eugenyk/hpcourse/pull/286#discussion_r181302981","pull_request_url":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/eugenyk/hpcourse/pulls/comments/181302981"},"html":{"href":"https://github.com/eugenyk/hpcourse/pull/286#discussion_r181302981"},"pull_request":{"href":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286"}},"in_reply_to_id":178464290},"pull_request":{"url":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286","id":178509985,"html_url":"https://github.com/eugenyk/hpcourse/pull/286","diff_url":"https://github.com/eugenyk/hpcourse/pull/286.diff","patch_url":"https://github.com/eugenyk/hpcourse/pull/286.patch","issue_url":"https://api.github.com/repos/eugenyk/hpcourse/issues/286","number":286,"state":"open","locked":false,"title":"chat","user":{"login":"RomanSulyaev","id":12670130,"avatar_url":"https://avatars2.githubusercontent.com/u/12670130?v=4","gravatar_id":"","url":"https://api.github.com/users/RomanSulyaev","html_url":"https://github.com/RomanSulyaev","followers_url":"https://api.github.com/users/RomanSulyaev/followers","following_url":"https://api.github.com/users/RomanSulyaev/following{/other_user}","gists_url":"https://api.github.com/users/RomanSulyaev/gists{/gist_id}","starred_url":"https://api.github.com/users/RomanSulyaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomanSulyaev/subscriptions","organizations_url":"https://api.github.com/users/RomanSulyaev/orgs","repos_url":"https://api.github.com/users/RomanSulyaev/repos","events_url":"https://api.github.com/users/RomanSulyaev/events{/privacy}","received_events_url":"https://api.github.com/users/RomanSulyaev/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-30T07:32:55Z","updated_at":"2018-04-13T07:14:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6bf9e683f36b0ea5eb3e2ae321128e185b45775c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286/commits","review_comments_url":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286/comments","review_comment_url":"https://api.github.com/repos/eugenyk/hpcourse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eugenyk/hpcourse/issues/286/comments","statuses_url":"https://api.github.com/repos/eugenyk/hpcourse/statuses/1867198ee4ea43a7f959860ac56f78d363aa9171","head":{"label":"RomanSulyaev:master","ref":"master","sha":"1867198ee4ea43a7f959860ac56f78d363aa9171","user":{"login":"RomanSulyaev","id":12670130,"avatar_url":"https://avatars2.githubusercontent.com/u/12670130?v=4","gravatar_id":"","url":"https://api.github.com/users/RomanSulyaev","html_url":"https://github.com/RomanSulyaev","followers_url":"https://api.github.com/users/RomanSulyaev/followers","following_url":"https://api.github.com/users/RomanSulyaev/following{/other_user}","gists_url":"https://api.github.com/users/RomanSulyaev/gists{/gist_id}","starred_url":"https://api.github.com/users/RomanSulyaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomanSulyaev/subscriptions","organizations_url":"https://api.github.com/users/RomanSulyaev/orgs","repos_url":"https://api.github.com/users/RomanSulyaev/repos","events_url":"https://api.github.com/users/RomanSulyaev/events{/privacy}","received_events_url":"https://api.github.com/users/RomanSulyaev/received_events","type":"User","site_admin":false},"repo":{"id":115724019,"name":"hpcourse","full_name":"RomanSulyaev/hpcourse","owner":{"login":"RomanSulyaev","id":12670130,"avatar_url":"https://avatars2.githubusercontent.com/u/12670130?v=4","gravatar_id":"","url":"https://api.github.com/users/RomanSulyaev","html_url":"https://github.com/RomanSulyaev","followers_url":"https://api.github.com/users/RomanSulyaev/followers","following_url":"https://api.github.com/users/RomanSulyaev/following{/other_user}","gists_url":"https://api.github.com/users/RomanSulyaev/gists{/gist_id}","starred_url":"https://api.github.com/users/RomanSulyaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomanSulyaev/subscriptions","organizations_url":"https://api.github.com/users/RomanSulyaev/orgs","repos_url":"https://api.github.com/users/RomanSulyaev/repos","events_url":"https://api.github.com/users/RomanSulyaev/events{/privacy}","received_events_url":"https://api.github.com/users/RomanSulyaev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RomanSulyaev/hpcourse","description":"Repository to store student's practical works on high performance computing course","fork":true,"url":"https://api.github.com/repos/RomanSulyaev/hpcourse","forks_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/forks","keys_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/teams","hooks_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/hooks","issue_events_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/issues/events{/number}","events_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/events","assignees_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/assignees{/user}","branches_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/branches{/branch}","tags_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/tags","blobs_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/git/refs{/sha}","trees_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/statuses/{sha}","languages_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/languages","stargazers_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/stargazers","contributors_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/contributors","subscribers_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/subscribers","subscription_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/subscription","commits_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/commits{/sha}","git_commits_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/git/commits{/sha}","comments_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/comments{/number}","issue_comment_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/issues/comments{/number}","contents_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/contents/{+path}","compare_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/merges","archive_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/downloads","issues_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/issues{/number}","pulls_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/pulls{/number}","milestones_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/milestones{/number}","notifications_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/labels{/name}","releases_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/releases{/id}","deployments_url":"https://api.github.com/repos/RomanSulyaev/hpcourse/deployments","created_at":"2017-12-29T13:20:09Z","updated_at":"2018-03-30T07:31:12Z","pushed_at":"2018-03-30T07:31:08Z","git_url":"git://github.com/RomanSulyaev/hpcourse.git","ssh_url":"git@github.com:RomanSulyaev/hpcourse.git","clone_url":"https://github.com/RomanSulyaev/hpcourse.git","svn_url":"https://github.com/RomanSulyaev/hpcourse","homepage":null,"size":10067,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eugenyk:master","ref":"master","sha":"912e09cfc340dddeea8ac9aad1d23511645d641b","user":{"login":"eugenyk","id":667552,"avatar_url":"https://avatars3.githubusercontent.com/u/667552?v=4","gravatar_id":"","url":"https://api.github.com/users/eugenyk","html_url":"https://github.com/eugenyk","followers_url":"https://api.github.com/users/eugenyk/followers","following_url":"https://api.github.com/users/eugenyk/following{/other_user}","gists_url":"https://api.github.com/users/eugenyk/gists{/gist_id}","starred_url":"https://api.github.com/users/eugenyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugenyk/subscriptions","organizations_url":"https://api.github.com/users/eugenyk/orgs","repos_url":"https://api.github.com/users/eugenyk/repos","events_url":"https://api.github.com/users/eugenyk/events{/privacy}","received_events_url":"https://api.github.com/users/eugenyk/received_events","type":"User","site_admin":false},"repo":{"id":46411508,"name":"hpcourse","full_name":"eugenyk/hpcourse","owner":{"login":"eugenyk","id":667552,"avatar_url":"https://avatars3.githubusercontent.com/u/667552?v=4","gravatar_id":"","url":"https://api.github.com/users/eugenyk","html_url":"https://github.com/eugenyk","followers_url":"https://api.github.com/users/eugenyk/followers","following_url":"https://api.github.com/users/eugenyk/following{/other_user}","gists_url":"https://api.github.com/users/eugenyk/gists{/gist_id}","starred_url":"https://api.github.com/users/eugenyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugenyk/subscriptions","organizations_url":"https://api.github.com/users/eugenyk/orgs","repos_url":"https://api.github.com/users/eugenyk/repos","events_url":"https://api.github.com/users/eugenyk/events{/privacy}","received_events_url":"https://api.github.com/users/eugenyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eugenyk/hpcourse","description":"Repository to store student's practical works on high performance computing course","fork":false,"url":"https://api.github.com/repos/eugenyk/hpcourse","forks_url":"https://api.github.com/repos/eugenyk/hpcourse/forks","keys_url":"https://api.github.com/repos/eugenyk/hpcourse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eugenyk/hpcourse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eugenyk/hpcourse/teams","hooks_url":"https://api.github.com/repos/eugenyk/hpcourse/hooks","issue_events_url":"https://api.github.com/repos/eugenyk/hpcourse/issues/events{/number}","events_url":"https://api.github.com/repos/eugenyk/hpcourse/events","assignees_url":"https://api.github.com/repos/eugenyk/hpcourse/assignees{/user}","branches_url":"https://api.github.com/repos/eugenyk/hpcourse/branches{/branch}","tags_url":"https://api.github.com/repos/eugenyk/hpcourse/tags","blobs_url":"https://api.github.com/repos/eugenyk/hpcourse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eugenyk/hpcourse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eugenyk/hpcourse/git/refs{/sha}","trees_url":"https://api.github.com/repos/eugenyk/hpcourse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eugenyk/hpcourse/statuses/{sha}","languages_url":"https://api.github.com/repos/eugenyk/hpcourse/languages","stargazers_url":"https://api.github.com/repos/eugenyk/hpcourse/stargazers","contributors_url":"https://api.github.com/repos/eugenyk/hpcourse/contributors","subscribers_url":"https://api.github.com/repos/eugenyk/hpcourse/subscribers","subscription_url":"https://api.github.com/repos/eugenyk/hpcourse/subscription","commits_url":"https://api.github.com/repos/eugenyk/hpcourse/commits{/sha}","git_commits_url":"https://api.github.com/repos/eugenyk/hpcourse/git/commits{/sha}","comments_url":"https://api.github.com/repos/eugenyk/hpcourse/comments{/number}","issue_comment_url":"https://api.github.com/repos/eugenyk/hpcourse/issues/comments{/number}","contents_url":"https://api.github.com/repos/eugenyk/hpcourse/contents/{+path}","compare_url":"https://api.github.com/repos/eugenyk/hpcourse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eugenyk/hpcourse/merges","archive_url":"https://api.github.com/repos/eugenyk/hpcourse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eugenyk/hpcourse/downloads","issues_url":"https://api.github.com/repos/eugenyk/hpcourse/issues{/number}","pulls_url":"https://api.github.com/repos/eugenyk/hpcourse/pulls{/number}","milestones_url":"https://api.github.com/repos/eugenyk/hpcourse/milestones{/number}","notifications_url":"https://api.github.com/repos/eugenyk/hpcourse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eugenyk/hpcourse/labels{/name}","releases_url":"https://api.github.com/repos/eugenyk/hpcourse/releases{/id}","deployments_url":"https://api.github.com/repos/eugenyk/hpcourse/deployments","created_at":"2015-11-18T10:26:09Z","updated_at":"2018-04-12T21:39:14Z","pushed_at":"2018-04-12T21:39:09Z","git_url":"git://github.com/eugenyk/hpcourse.git","ssh_url":"git@github.com:eugenyk/hpcourse.git","clone_url":"https://github.com/eugenyk/hpcourse.git","svn_url":"https://github.com/eugenyk/hpcourse","homepage":null,"size":15759,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":184,"mirror_url":null,"archived":false,"open_issues_count":36,"license":null,"forks":184,"open_issues":36,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286"},"html":{"href":"https://github.com/eugenyk/hpcourse/pull/286"},"issue":{"href":"https://api.github.com/repos/eugenyk/hpcourse/issues/286"},"comments":{"href":"https://api.github.com/repos/eugenyk/hpcourse/issues/286/comments"},"review_comments":{"href":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286/comments"},"review_comment":{"href":"https://api.github.com/repos/eugenyk/hpcourse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eugenyk/hpcourse/pulls/286/commits"},"statuses":{"href":"https://api.github.com/repos/eugenyk/hpcourse/statuses/1867198ee4ea43a7f959860ac56f78d363aa9171"}},"author_association":"NONE"}}
{"actor":{"display_login":"RomanSulyaev"}}