{"action":"created","comment":{"url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/comments/26815306","id":26815306,"diff_hunk":"@@ -0,0 +1,67 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Net;\n+using System.IO;\n+using System.Text;\n+\n+using Newtonsoft.Json.Linq;\n+\n+public class JSONRPC {\n+\tprivate string _endpoint;\n+\n+\t// Basic authentication\n+\tprivate string _username;\n+\tprivate string _password;\n+\n+\tpublic void setEndpoint(string endpoint, string username = null, string password = null) {\n+\t\t_endpoint = endpoint;\n+\t\t_username = username;\n+\t\t_password = password;\n+\t}\n+\n+\tpublic void call(string methodName, JObject parameters, Dictionary<string, string> headers, Action<Exception, JObject> cb) {\n+\t\t// Make sure the endpoint is set\n+\t\tif (string.IsNullOrEmpty(_endpoint)) {\n+\t\t\tcb(new Exception(\"Endpoint has not been set\"), null);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\t// Setup JSON request object\n+\t\tJObject requestObject = new JObject ();\n+\t\trequestObject.Add(\"id\", new JValue(1));\n+\t\trequestObject.Add(\"jsonrpc\", new JValue(\"2.0\"));\n+\t\trequestObject.Add(\"method\", new JValue(methodName));\n+\t\trequestObject.Add(\"params\", parameters);\n+\n+\t\t// Serialize JSON request object into string\n+\t\tstring postData;\n+\t\ttry {\n+\t\t\tpostData = requestObject.ToString ();\n+\t\t} catch (Exception serializeError) {\n+\t\t\tcb(serializeError, null);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\t// Make a copy of the provided headers and add additional required headers\n+\t\tDictionary<string, string> _headers = new Dictionary<string, string>(headers);\n+\t\tif (_username != null && _password != null) {\n+\t\t\tstring authInfo = _username + \":\" + _password;\n+\t\t\tstring encodedAuth = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));\n+\t\t\t_headers.Add(\"Authorization\", \"Basic \" + encodedAuth);\n+\t\t}\n+\n+\t\t// Send HTTP post to JSON rpc endpoint\n+\t\tHTTPRequest.Post (_endpoint, \"application/json\", postData, _headers, (Exception requestError, string responseString) => {\n+\t\t\t// Deserialize the JSON response\n+\t\t\tJObject responseObject;\n+\t\t\ttry {\n+\t\t\t\tresponseObject = JObject.Parse(responseString);","path":"JSONRPC/JSONRPC.cs","position":58,"original_position":58,"commit_id":"6f587c034614543fbbd4e0d339c878be1852c513","original_commit_id":"6f587c034614543fbbd4e0d339c878be1852c513","user":{"login":"ronkorving","id":631240,"avatar_url":"https://avatars.githubusercontent.com/u/631240?v=3","gravatar_id":"","url":"https://api.github.com/users/ronkorving","html_url":"https://github.com/ronkorving","followers_url":"https://api.github.com/users/ronkorving/followers","following_url":"https://api.github.com/users/ronkorving/following{/other_user}","gists_url":"https://api.github.com/users/ronkorving/gists{/gist_id}","starred_url":"https://api.github.com/users/ronkorving/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronkorving/subscriptions","organizations_url":"https://api.github.com/users/ronkorving/orgs","repos_url":"https://api.github.com/users/ronkorving/repos","events_url":"https://api.github.com/users/ronkorving/events{/privacy}","received_events_url":"https://api.github.com/users/ronkorving/received_events","type":"User","site_admin":false},"body":"Where's the parsing of JSONRPC?","created_at":"2015-03-20T02:39:09Z","updated_at":"2015-03-20T02:39:09Z","html_url":"https://github.com/mage/mage-sdk-unity/pull/10#discussion_r26815306","pull_request_url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/comments/26815306"},"html":{"href":"https://github.com/mage/mage-sdk-unity/pull/10#discussion_r26815306"},"pull_request":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10","id":31583845,"html_url":"https://github.com/mage/mage-sdk-unity/pull/10","diff_url":"https://github.com/mage/mage-sdk-unity/pull/10.diff","patch_url":"https://github.com/mage/mage-sdk-unity/pull/10.patch","issue_url":"https://api.github.com/repos/mage/mage-sdk-unity/issues/10","number":10,"state":"open","locked":false,"title":"Add JSON RPC","user":{"login":"daniel-dressler","id":365198,"avatar_url":"https://avatars.githubusercontent.com/u/365198?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-dressler","html_url":"https://github.com/daniel-dressler","followers_url":"https://api.github.com/users/daniel-dressler/followers","following_url":"https://api.github.com/users/daniel-dressler/following{/other_user}","gists_url":"https://api.github.com/users/daniel-dressler/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-dressler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-dressler/subscriptions","organizations_url":"https://api.github.com/users/daniel-dressler/orgs","repos_url":"https://api.github.com/users/daniel-dressler/repos","events_url":"https://api.github.com/users/daniel-dressler/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-dressler/received_events","type":"User","site_admin":false},"body":"This class depends upon HTTPRequest.\r\n\r\nNote that the unity sdk does not support web sockets yet.","created_at":"2015-03-20T02:30:16Z","updated_at":"2015-03-20T02:39:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"597204a63e42dd71332b4b5e130b979934ec34c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10/commits","review_comments_url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10/comments","review_comment_url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mage/mage-sdk-unity/issues/10/comments","statuses_url":"https://api.github.com/repos/mage/mage-sdk-unity/statuses/6f587c034614543fbbd4e0d339c878be1852c513","head":{"label":"daniel-dressler:feature/jsonrpc","ref":"feature/jsonrpc","sha":"6f587c034614543fbbd4e0d339c878be1852c513","user":{"login":"daniel-dressler","id":365198,"avatar_url":"https://avatars.githubusercontent.com/u/365198?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-dressler","html_url":"https://github.com/daniel-dressler","followers_url":"https://api.github.com/users/daniel-dressler/followers","following_url":"https://api.github.com/users/daniel-dressler/following{/other_user}","gists_url":"https://api.github.com/users/daniel-dressler/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-dressler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-dressler/subscriptions","organizations_url":"https://api.github.com/users/daniel-dressler/orgs","repos_url":"https://api.github.com/users/daniel-dressler/repos","events_url":"https://api.github.com/users/daniel-dressler/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-dressler/received_events","type":"User","site_admin":false},"repo":{"id":32447924,"name":"mage-sdk-unity","full_name":"daniel-dressler/mage-sdk-unity","owner":{"login":"daniel-dressler","id":365198,"avatar_url":"https://avatars.githubusercontent.com/u/365198?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-dressler","html_url":"https://github.com/daniel-dressler","followers_url":"https://api.github.com/users/daniel-dressler/followers","following_url":"https://api.github.com/users/daniel-dressler/following{/other_user}","gists_url":"https://api.github.com/users/daniel-dressler/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-dressler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-dressler/subscriptions","organizations_url":"https://api.github.com/users/daniel-dressler/orgs","repos_url":"https://api.github.com/users/daniel-dressler/repos","events_url":"https://api.github.com/users/daniel-dressler/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-dressler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/daniel-dressler/mage-sdk-unity","description":"","fork":true,"url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity","forks_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/forks","keys_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/teams","hooks_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/hooks","issue_events_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/issues/events{/number}","events_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/events","assignees_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/assignees{/user}","branches_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/branches{/branch}","tags_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/tags","blobs_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/git/refs{/sha}","trees_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/statuses/{sha}","languages_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/languages","stargazers_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/stargazers","contributors_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/contributors","subscribers_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/subscribers","subscription_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/subscription","commits_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/commits{/sha}","git_commits_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/git/commits{/sha}","comments_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/comments{/number}","issue_comment_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/issues/comments{/number}","contents_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/contents/{+path}","compare_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/merges","archive_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/downloads","issues_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/issues{/number}","pulls_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/pulls{/number}","milestones_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/milestones{/number}","notifications_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/labels{/name}","releases_url":"https://api.github.com/repos/daniel-dressler/mage-sdk-unity/releases{/id}","created_at":"2015-03-18T08:54:40Z","updated_at":"2014-07-18T08:25:05Z","pushed_at":"2015-03-20T02:27:56Z","git_url":"git://github.com/daniel-dressler/mage-sdk-unity.git","ssh_url":"git@github.com:daniel-dressler/mage-sdk-unity.git","clone_url":"https://github.com/daniel-dressler/mage-sdk-unity.git","svn_url":"https://github.com/daniel-dressler/mage-sdk-unity","homepage":null,"size":80,"stargazers_count":0,"watchers_count":0,"language":null,"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":"develop"}},"base":{"label":"mage:develop","ref":"develop","sha":"77cebcab420ca81b577d7d92ecf440d99baba493","user":{"login":"mage","id":5233560,"avatar_url":"https://avatars.githubusercontent.com/u/5233560?v=3","gravatar_id":"","url":"https://api.github.com/users/mage","html_url":"https://github.com/mage","followers_url":"https://api.github.com/users/mage/followers","following_url":"https://api.github.com/users/mage/following{/other_user}","gists_url":"https://api.github.com/users/mage/gists{/gist_id}","starred_url":"https://api.github.com/users/mage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mage/subscriptions","organizations_url":"https://api.github.com/users/mage/orgs","repos_url":"https://api.github.com/users/mage/repos","events_url":"https://api.github.com/users/mage/events{/privacy}","received_events_url":"https://api.github.com/users/mage/received_events","type":"Organization","site_admin":false},"repo":{"id":21973284,"name":"mage-sdk-unity","full_name":"mage/mage-sdk-unity","owner":{"login":"mage","id":5233560,"avatar_url":"https://avatars.githubusercontent.com/u/5233560?v=3","gravatar_id":"","url":"https://api.github.com/users/mage","html_url":"https://github.com/mage","followers_url":"https://api.github.com/users/mage/followers","following_url":"https://api.github.com/users/mage/following{/other_user}","gists_url":"https://api.github.com/users/mage/gists{/gist_id}","starred_url":"https://api.github.com/users/mage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mage/subscriptions","organizations_url":"https://api.github.com/users/mage/orgs","repos_url":"https://api.github.com/users/mage/repos","events_url":"https://api.github.com/users/mage/events{/privacy}","received_events_url":"https://api.github.com/users/mage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mage/mage-sdk-unity","description":"","fork":false,"url":"https://api.github.com/repos/mage/mage-sdk-unity","forks_url":"https://api.github.com/repos/mage/mage-sdk-unity/forks","keys_url":"https://api.github.com/repos/mage/mage-sdk-unity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mage/mage-sdk-unity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mage/mage-sdk-unity/teams","hooks_url":"https://api.github.com/repos/mage/mage-sdk-unity/hooks","issue_events_url":"https://api.github.com/repos/mage/mage-sdk-unity/issues/events{/number}","events_url":"https://api.github.com/repos/mage/mage-sdk-unity/events","assignees_url":"https://api.github.com/repos/mage/mage-sdk-unity/assignees{/user}","branches_url":"https://api.github.com/repos/mage/mage-sdk-unity/branches{/branch}","tags_url":"https://api.github.com/repos/mage/mage-sdk-unity/tags","blobs_url":"https://api.github.com/repos/mage/mage-sdk-unity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mage/mage-sdk-unity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mage/mage-sdk-unity/git/refs{/sha}","trees_url":"https://api.github.com/repos/mage/mage-sdk-unity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mage/mage-sdk-unity/statuses/{sha}","languages_url":"https://api.github.com/repos/mage/mage-sdk-unity/languages","stargazers_url":"https://api.github.com/repos/mage/mage-sdk-unity/stargazers","contributors_url":"https://api.github.com/repos/mage/mage-sdk-unity/contributors","subscribers_url":"https://api.github.com/repos/mage/mage-sdk-unity/subscribers","subscription_url":"https://api.github.com/repos/mage/mage-sdk-unity/subscription","commits_url":"https://api.github.com/repos/mage/mage-sdk-unity/commits{/sha}","git_commits_url":"https://api.github.com/repos/mage/mage-sdk-unity/git/commits{/sha}","comments_url":"https://api.github.com/repos/mage/mage-sdk-unity/comments{/number}","issue_comment_url":"https://api.github.com/repos/mage/mage-sdk-unity/issues/comments{/number}","contents_url":"https://api.github.com/repos/mage/mage-sdk-unity/contents/{+path}","compare_url":"https://api.github.com/repos/mage/mage-sdk-unity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mage/mage-sdk-unity/merges","archive_url":"https://api.github.com/repos/mage/mage-sdk-unity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mage/mage-sdk-unity/downloads","issues_url":"https://api.github.com/repos/mage/mage-sdk-unity/issues{/number}","pulls_url":"https://api.github.com/repos/mage/mage-sdk-unity/pulls{/number}","milestones_url":"https://api.github.com/repos/mage/mage-sdk-unity/milestones{/number}","notifications_url":"https://api.github.com/repos/mage/mage-sdk-unity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mage/mage-sdk-unity/labels{/name}","releases_url":"https://api.github.com/repos/mage/mage-sdk-unity/releases{/id}","created_at":"2014-07-18T08:25:05Z","updated_at":"2015-03-19T05:57:23Z","pushed_at":"2015-03-20T02:30:16Z","git_url":"git://github.com/mage/mage-sdk-unity.git","ssh_url":"git@github.com:mage/mage-sdk-unity.git","clone_url":"https://github.com/mage/mage-sdk-unity.git","svn_url":"https://github.com/mage/mage-sdk-unity","homepage":null,"size":294,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10"},"html":{"href":"https://github.com/mage/mage-sdk-unity/pull/10"},"issue":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/issues/10"},"comments":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/mage/mage-sdk-unity/statuses/6f587c034614543fbbd4e0d339c878be1852c513"}}}}