{"action":"created","comment":{"url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/comments/28808426","id":28808426,"diff_hunk":"@@ -0,0 +1,52 @@\n+#!/usr/bin/env ruby -w\n+require \"socket\"\n+class Server\n+  def initialize(ip = \"localhost\", port = 3000)\n+    @server = TCPServer.open(ip, port)\n+    @connections = Hash.new\n+    @rooms = Hash.new\n+    @clients = Hash.new\n+    @connections[:server] = @server\n+    @connections[:rooms] = @rooms\n+    @connections[:clients] = @clients\n+    run\n+  end\n+\n+  def run\n+    loop do\n+      Thread.start(@server.accept) do |client|\n+        nick_name = register_users(client)\n+        listen_user_messages(nick_name, client)\n+      end\n+    end.join\n+  end\n+\n+  def register_users client\n+    nick_name = client.gets.chomp.to_sym\n+    @connections[:clients].each do |other_name, other_client|\n+      if nick_name == other_name || client == other_client\n+        client.puts \"This username already exist\"\n+        Thread.kill self\n+      end\n+    end\n+    puts \"#{nick_name} #{client}\"\n+    @connections[:clients][nick_name] = client\n+    client.puts \"Connection established, Thank you for joining!\"\n+    nick_name\n+  end\n+\n+","path":"pwalvarado/server.rb","position":38,"original_position":38,"commit_id":"8f415cd1feae23fa9141746058721a3bb097288f","original_commit_id":"8f415cd1feae23fa9141746058721a3bb097288f","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Extra blank line detected.","created_at":"2015-04-21T18:35:07Z","updated_at":"2015-04-21T18:35:07Z","html_url":"https://github.com/CollectiveLearning/SocketChat/pull/2#discussion_r28808426","pull_request_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/comments/28808426"},"html":{"href":"https://github.com/CollectiveLearning/SocketChat/pull/2#discussion_r28808426"},"pull_request":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2","id":33781589,"html_url":"https://github.com/CollectiveLearning/SocketChat/pull/2","diff_url":"https://github.com/CollectiveLearning/SocketChat/pull/2.diff","patch_url":"https://github.com/CollectiveLearning/SocketChat/pull/2.patch","issue_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues/2","number":2,"state":"open","locked":false,"title":"Pedro's solution","user":{"login":"rderoldan1","id":968973,"avatar_url":"https://avatars.githubusercontent.com/u/968973?v=3","gravatar_id":"","url":"https://api.github.com/users/rderoldan1","html_url":"https://github.com/rderoldan1","followers_url":"https://api.github.com/users/rderoldan1/followers","following_url":"https://api.github.com/users/rderoldan1/following{/other_user}","gists_url":"https://api.github.com/users/rderoldan1/gists{/gist_id}","starred_url":"https://api.github.com/users/rderoldan1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rderoldan1/subscriptions","organizations_url":"https://api.github.com/users/rderoldan1/orgs","repos_url":"https://api.github.com/users/rderoldan1/repos","events_url":"https://api.github.com/users/rderoldan1/events{/privacy}","received_events_url":"https://api.github.com/users/rderoldan1/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-21T16:56:59Z","updated_at":"2015-04-21T18:35:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54a0ac9eafc8fdf3a49ecb6ba57afdfdb8f9fb02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2/commits","review_comments_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2/comments","review_comment_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues/2/comments","statuses_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/statuses/8f415cd1feae23fa9141746058721a3bb097288f","head":{"label":"pwalvarado:master","ref":"master","sha":"8f415cd1feae23fa9141746058721a3bb097288f","user":{"login":"pwalvarado","id":5042471,"avatar_url":"https://avatars.githubusercontent.com/u/5042471?v=3","gravatar_id":"","url":"https://api.github.com/users/pwalvarado","html_url":"https://github.com/pwalvarado","followers_url":"https://api.github.com/users/pwalvarado/followers","following_url":"https://api.github.com/users/pwalvarado/following{/other_user}","gists_url":"https://api.github.com/users/pwalvarado/gists{/gist_id}","starred_url":"https://api.github.com/users/pwalvarado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwalvarado/subscriptions","organizations_url":"https://api.github.com/users/pwalvarado/orgs","repos_url":"https://api.github.com/users/pwalvarado/repos","events_url":"https://api.github.com/users/pwalvarado/events{/privacy}","received_events_url":"https://api.github.com/users/pwalvarado/received_events","type":"User","site_admin":false},"repo":{"id":34339549,"name":"SocketChat","full_name":"pwalvarado/SocketChat","owner":{"login":"pwalvarado","id":5042471,"avatar_url":"https://avatars.githubusercontent.com/u/5042471?v=3","gravatar_id":"","url":"https://api.github.com/users/pwalvarado","html_url":"https://github.com/pwalvarado","followers_url":"https://api.github.com/users/pwalvarado/followers","following_url":"https://api.github.com/users/pwalvarado/following{/other_user}","gists_url":"https://api.github.com/users/pwalvarado/gists{/gist_id}","starred_url":"https://api.github.com/users/pwalvarado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwalvarado/subscriptions","organizations_url":"https://api.github.com/users/pwalvarado/orgs","repos_url":"https://api.github.com/users/pwalvarado/repos","events_url":"https://api.github.com/users/pwalvarado/events{/privacy}","received_events_url":"https://api.github.com/users/pwalvarado/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pwalvarado/SocketChat","description":"Simple chat with sockets","fork":true,"url":"https://api.github.com/repos/pwalvarado/SocketChat","forks_url":"https://api.github.com/repos/pwalvarado/SocketChat/forks","keys_url":"https://api.github.com/repos/pwalvarado/SocketChat/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pwalvarado/SocketChat/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pwalvarado/SocketChat/teams","hooks_url":"https://api.github.com/repos/pwalvarado/SocketChat/hooks","issue_events_url":"https://api.github.com/repos/pwalvarado/SocketChat/issues/events{/number}","events_url":"https://api.github.com/repos/pwalvarado/SocketChat/events","assignees_url":"https://api.github.com/repos/pwalvarado/SocketChat/assignees{/user}","branches_url":"https://api.github.com/repos/pwalvarado/SocketChat/branches{/branch}","tags_url":"https://api.github.com/repos/pwalvarado/SocketChat/tags","blobs_url":"https://api.github.com/repos/pwalvarado/SocketChat/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pwalvarado/SocketChat/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pwalvarado/SocketChat/git/refs{/sha}","trees_url":"https://api.github.com/repos/pwalvarado/SocketChat/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pwalvarado/SocketChat/statuses/{sha}","languages_url":"https://api.github.com/repos/pwalvarado/SocketChat/languages","stargazers_url":"https://api.github.com/repos/pwalvarado/SocketChat/stargazers","contributors_url":"https://api.github.com/repos/pwalvarado/SocketChat/contributors","subscribers_url":"https://api.github.com/repos/pwalvarado/SocketChat/subscribers","subscription_url":"https://api.github.com/repos/pwalvarado/SocketChat/subscription","commits_url":"https://api.github.com/repos/pwalvarado/SocketChat/commits{/sha}","git_commits_url":"https://api.github.com/repos/pwalvarado/SocketChat/git/commits{/sha}","comments_url":"https://api.github.com/repos/pwalvarado/SocketChat/comments{/number}","issue_comment_url":"https://api.github.com/repos/pwalvarado/SocketChat/issues/comments{/number}","contents_url":"https://api.github.com/repos/pwalvarado/SocketChat/contents/{+path}","compare_url":"https://api.github.com/repos/pwalvarado/SocketChat/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pwalvarado/SocketChat/merges","archive_url":"https://api.github.com/repos/pwalvarado/SocketChat/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pwalvarado/SocketChat/downloads","issues_url":"https://api.github.com/repos/pwalvarado/SocketChat/issues{/number}","pulls_url":"https://api.github.com/repos/pwalvarado/SocketChat/pulls{/number}","milestones_url":"https://api.github.com/repos/pwalvarado/SocketChat/milestones{/number}","notifications_url":"https://api.github.com/repos/pwalvarado/SocketChat/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pwalvarado/SocketChat/labels{/name}","releases_url":"https://api.github.com/repos/pwalvarado/SocketChat/releases{/id}","created_at":"2015-04-21T16:43:50Z","updated_at":"2015-04-21T18:35:03Z","pushed_at":"2015-04-21T18:35:03Z","git_url":"git://github.com/pwalvarado/SocketChat.git","ssh_url":"git@github.com:pwalvarado/SocketChat.git","clone_url":"https://github.com/pwalvarado/SocketChat.git","svn_url":"https://github.com/pwalvarado/SocketChat","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CollectiveLearning:master","ref":"master","sha":"3c7f32ef5e4f4cb939f87bfcf0f656dabda40ac1","user":{"login":"CollectiveLearning","id":11666950,"avatar_url":"https://avatars.githubusercontent.com/u/11666950?v=3","gravatar_id":"","url":"https://api.github.com/users/CollectiveLearning","html_url":"https://github.com/CollectiveLearning","followers_url":"https://api.github.com/users/CollectiveLearning/followers","following_url":"https://api.github.com/users/CollectiveLearning/following{/other_user}","gists_url":"https://api.github.com/users/CollectiveLearning/gists{/gist_id}","starred_url":"https://api.github.com/users/CollectiveLearning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CollectiveLearning/subscriptions","organizations_url":"https://api.github.com/users/CollectiveLearning/orgs","repos_url":"https://api.github.com/users/CollectiveLearning/repos","events_url":"https://api.github.com/users/CollectiveLearning/events{/privacy}","received_events_url":"https://api.github.com/users/CollectiveLearning/received_events","type":"Organization","site_admin":false},"repo":{"id":34063953,"name":"SocketChat","full_name":"CollectiveLearning/SocketChat","owner":{"login":"CollectiveLearning","id":11666950,"avatar_url":"https://avatars.githubusercontent.com/u/11666950?v=3","gravatar_id":"","url":"https://api.github.com/users/CollectiveLearning","html_url":"https://github.com/CollectiveLearning","followers_url":"https://api.github.com/users/CollectiveLearning/followers","following_url":"https://api.github.com/users/CollectiveLearning/following{/other_user}","gists_url":"https://api.github.com/users/CollectiveLearning/gists{/gist_id}","starred_url":"https://api.github.com/users/CollectiveLearning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CollectiveLearning/subscriptions","organizations_url":"https://api.github.com/users/CollectiveLearning/orgs","repos_url":"https://api.github.com/users/CollectiveLearning/repos","events_url":"https://api.github.com/users/CollectiveLearning/events{/privacy}","received_events_url":"https://api.github.com/users/CollectiveLearning/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CollectiveLearning/SocketChat","description":"Simple chat with sockets","fork":false,"url":"https://api.github.com/repos/CollectiveLearning/SocketChat","forks_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/forks","keys_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/teams","hooks_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/hooks","issue_events_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues/events{/number}","events_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/events","assignees_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/assignees{/user}","branches_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/branches{/branch}","tags_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/tags","blobs_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/git/refs{/sha}","trees_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/statuses/{sha}","languages_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/languages","stargazers_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/stargazers","contributors_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/contributors","subscribers_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/subscribers","subscription_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/subscription","commits_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/commits{/sha}","git_commits_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/git/commits{/sha}","comments_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/comments{/number}","issue_comment_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues/comments{/number}","contents_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/contents/{+path}","compare_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/merges","archive_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/downloads","issues_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues{/number}","pulls_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls{/number}","milestones_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/milestones{/number}","notifications_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/labels{/name}","releases_url":"https://api.github.com/repos/CollectiveLearning/SocketChat/releases{/id}","created_at":"2015-04-16T15:26:47Z","updated_at":"2015-04-16T15:26:47Z","pushed_at":"2015-04-21T18:35:03Z","git_url":"git://github.com/CollectiveLearning/SocketChat.git","ssh_url":"git@github.com:CollectiveLearning/SocketChat.git","clone_url":"https://github.com/CollectiveLearning/SocketChat.git","svn_url":"https://github.com/CollectiveLearning/SocketChat","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2"},"html":{"href":"https://github.com/CollectiveLearning/SocketChat/pull/2"},"issue":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues/2"},"comments":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/CollectiveLearning/SocketChat/statuses/8f415cd1feae23fa9141746058721a3bb097288f"}}}}