{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/SignalR/pulls/comments/216759906","pull_request_review_id":154307820,"id":216759906,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNjc1OTkwNg==","diff_hunk":"@@ -32,41 +35,105 @@ public TransferFormat getTransferFormat() {\n     }\n \n     @Override\n-    public HubMessage[] parseMessages(String payload) {\n+    public HubMessage[] parseMessages(String payload, InvocationBinder binder) throws Exception {\n         String[] messages = payload.split(RECORD_SEPARATOR);\n         List<HubMessage> hubMessages = new ArrayList<>();\n-        for (String splitMessage : messages) {\n+        for (String str : messages) {\n+            HubMessageType messageType = null;\n+            String invocationId = null;\n+            String target = null;\n+            String error = null;\n+            ArrayList<Object> arguments = null;\n+            JsonArray argumentsToken = null;\n+\n+            JsonReader reader = new JsonReader(new StringReader(str));\n+            reader.beginObject();\n+\n+            do {\n+                String name = reader.nextName();\n+                switch (name) {\n+                    case \"type\":\n+                        messageType = HubMessageType.values()[reader.nextInt() - 1];\n+                        break;\n+                    case \"invocationId\":\n+                        invocationId = reader.nextString();\n+                        break;\n+                    case \"target\":\n+                        target = reader.nextString();\n+                        break;\n+                    case \"error\":\n+                        error = reader.nextString();\n+                        break;\n+                    case \"result\":\n+                        reader.skipValue();\n+                        break;\n+                    case \"item\":\n+                        reader.skipValue();\n+                        break;\n+                    case \"arguments\":\n+                        if (target != null) {\n+                            reader.beginArray();\n+                            List<Class<?>> types = binder.GetParameterTypes(target);\n+                            if (types != null && types.size() >= 1) {\n+                                arguments = new ArrayList<>();\n+                                for (int i = 0; i < types.size(); i++) {\n+                                    arguments.add(gson.fromJson(reader, types.get(i)));\n+                                }\n+                            }\n+                            reader.endArray();\n+                        } else {\n+                            argumentsToken = (JsonArray)jsonParser.parse(reader);\n+                        }\n+                        break;\n+                    case \"headers\":\n+                        throw new HubException(\"Headers not implemented yet.\");\n+                    default:\n+                        // Skip unknown property, allows new clients to still work with old protocols\n+                        reader.skipValue();\n+                        break;\n+                }\n+            } while (reader.hasNext());\n+\n+            reader.endObject();\n+            reader.close();\n \n-            JsonObject jsonMessage = jsonParser.parse(splitMessage).getAsJsonObject();\n-            HubMessageType messageType = HubMessageType.values()[jsonMessage.get(\"type\").getAsInt() -1];\n             switch (messageType) {\n                 case INVOCATION:\n-                    //Invocation Message\n-                    String target = jsonMessage.get(\"target\").getAsString();\n-                    JsonElement args = jsonMessage.get(\"arguments\");\n-                    hubMessages.add(new InvocationMessage(target, new Object[] {args}));\n+                    if (argumentsToken != null) {\n+                        List<Class<?>> types = binder.GetParameterTypes(target);\n+                        if (types != null && types.size() >= 1) {\n+                            arguments = new ArrayList<>();\n+                            for (int i = 0; i < types.size(); i++) {\n+                                arguments.add(gson.fromJson(argumentsToken.get(i), types.get(i)));\n+                            }\n+                        }\n+                    }\n+                    if (arguments == null) {\n+                        hubMessages.add(new InvocationMessage(target, new Object[0]));\n+                    } else {\n+                        hubMessages.add(new InvocationMessage(target, arguments.toArray()));\n+                    }\n                     break;\n+                case STREAM_INVOCATION:\n                 case STREAM_ITEM:\n                 case COMPLETION:\n-                case STREAM_INVOCATION:\n                 case CANCEL_INVOCATION:\n                     throw new UnsupportedOperationException(String.format(\"The message type %s is not supported yet.\", messageType));\n                 case PING:\n-                    //Ping\n                     hubMessages.add(new PingMessage());","path":"clients/java/signalr/src/main/java/com/microsoft/aspnet/signalr/JsonHubProtocol.java","position":118,"original_position":118,"commit_id":"56ea88958c77f8f5ae608a1e9831513c4175d2c2","original_commit_id":"56ea88958c77f8f5ae608a1e9831513c4175d2c2","user":{"login":"anurse","id":7574,"node_id":"MDQ6VXNlcjc1NzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/7574?v=4","gravatar_id":"","url":"https://api.github.com/users/anurse","html_url":"https://github.com/anurse","followers_url":"https://api.github.com/users/anurse/followers","following_url":"https://api.github.com/users/anurse/following{/other_user}","gists_url":"https://api.github.com/users/anurse/gists{/gist_id}","starred_url":"https://api.github.com/users/anurse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anurse/subscriptions","organizations_url":"https://api.github.com/users/anurse/orgs","repos_url":"https://api.github.com/users/anurse/repos","events_url":"https://api.github.com/users/anurse/events{/privacy}","received_events_url":"https://api.github.com/users/anurse/received_events","type":"User","site_admin":false},"body":"While you're here can you quickly bash up a singleton for this? [Looks like](https://www.journaldev.com/1377/java-singleton-design-pattern-best-practices-examples) the java pattern would be: \r\n\r\n```java\r\nclass PingMessage\r\n{\r\n    private static final PingMessage instance = new PingMessage();\r\n    \r\n    private PingMessage()\r\n    {\r\n    }\r\n\r\n    public static PingMessage getInstance(){\r\n        return instance;\r\n    }\r\n}","created_at":"2018-09-11T17:48:19Z","updated_at":"2018-09-11T17:52:12Z","html_url":"https://github.com/aspnet/SignalR/pull/2940#discussion_r216759906","pull_request_url":"https://api.github.com/repos/aspnet/SignalR/pulls/2940","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/aspnet/SignalR/pulls/comments/216759906"},"html":{"href":"https://github.com/aspnet/SignalR/pull/2940#discussion_r216759906"},"pull_request":{"href":"https://api.github.com/repos/aspnet/SignalR/pulls/2940"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/SignalR/pulls/2940","id":214458391,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0NDU4Mzkx","html_url":"https://github.com/aspnet/SignalR/pull/2940","diff_url":"https://github.com/aspnet/SignalR/pull/2940.diff","patch_url":"https://github.com/aspnet/SignalR/pull/2940.patch","issue_url":"https://api.github.com/repos/aspnet/SignalR/issues/2940","number":2940,"state":"open","locked":false,"title":"[Java] De-Serializing Custom Types","user":{"login":"BrennanConroy","id":7574801,"node_id":"MDQ6VXNlcjc1NzQ4MDE=","avatar_url":"https://avatars0.githubusercontent.com/u/7574801?v=4","gravatar_id":"","url":"https://api.github.com/users/BrennanConroy","html_url":"https://github.com/BrennanConroy","followers_url":"https://api.github.com/users/BrennanConroy/followers","following_url":"https://api.github.com/users/BrennanConroy/following{/other_user}","gists_url":"https://api.github.com/users/BrennanConroy/gists{/gist_id}","starred_url":"https://api.github.com/users/BrennanConroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrennanConroy/subscriptions","organizations_url":"https://api.github.com/users/BrennanConroy/orgs","repos_url":"https://api.github.com/users/BrennanConroy/repos","events_url":"https://api.github.com/users/BrennanConroy/events{/privacy}","received_events_url":"https://api.github.com/users/BrennanConroy/received_events","type":"User","site_admin":false},"body":"De-Serializing Custom Types #2582\r\nMove De-serialization logic into HubProtocol #2587\r\n\r\nGo \"easy\". First time writing Java.","created_at":"2018-09-10T22:08:03Z","updated_at":"2018-09-11T17:52:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b49278035322a7dbf4a0261c7f68571003591b5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/SignalR/pulls/2940/commits","review_comments_url":"https://api.github.com/repos/aspnet/SignalR/pulls/2940/comments","review_comment_url":"https://api.github.com/repos/aspnet/SignalR/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/SignalR/issues/2940/comments","statuses_url":"https://api.github.com/repos/aspnet/SignalR/statuses/56ea88958c77f8f5ae608a1e9831513c4175d2c2","head":{"label":"aspnet:brecon/javaComplex","ref":"brecon/javaComplex","sha":"56ea88958c77f8f5ae608a1e9831513c4175d2c2","user":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":71159589,"node_id":"MDEwOlJlcG9zaXRvcnk3MTE1OTU4OQ==","name":"SignalR","full_name":"aspnet/SignalR","owner":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/SignalR","description":"Incredibly simple real-time web for ASP.NET Core","fork":false,"url":"https://api.github.com/repos/aspnet/SignalR","forks_url":"https://api.github.com/repos/aspnet/SignalR/forks","keys_url":"https://api.github.com/repos/aspnet/SignalR/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/SignalR/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/SignalR/teams","hooks_url":"https://api.github.com/repos/aspnet/SignalR/hooks","issue_events_url":"https://api.github.com/repos/aspnet/SignalR/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/SignalR/events","assignees_url":"https://api.github.com/repos/aspnet/SignalR/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/SignalR/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/SignalR/tags","blobs_url":"https://api.github.com/repos/aspnet/SignalR/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/SignalR/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/SignalR/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/SignalR/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/SignalR/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/SignalR/languages","stargazers_url":"https://api.github.com/repos/aspnet/SignalR/stargazers","contributors_url":"https://api.github.com/repos/aspnet/SignalR/contributors","subscribers_url":"https://api.github.com/repos/aspnet/SignalR/subscribers","subscription_url":"https://api.github.com/repos/aspnet/SignalR/subscription","commits_url":"https://api.github.com/repos/aspnet/SignalR/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/SignalR/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/SignalR/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/SignalR/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/SignalR/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/SignalR/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/SignalR/merges","archive_url":"https://api.github.com/repos/aspnet/SignalR/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/SignalR/downloads","issues_url":"https://api.github.com/repos/aspnet/SignalR/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/SignalR/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/SignalR/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/SignalR/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/SignalR/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/SignalR/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/SignalR/deployments","created_at":"2016-10-17T16:39:15Z","updated_at":"2018-09-11T10:06:31Z","pushed_at":"2018-09-11T17:39:14Z","git_url":"git://github.com/aspnet/SignalR.git","ssh_url":"git@github.com:aspnet/SignalR.git","clone_url":"https://github.com/aspnet/SignalR.git","svn_url":"https://github.com/aspnet/SignalR","homepage":null,"size":10380,"stargazers_count":2166,"watchers_count":2166,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":375,"mirror_url":null,"archived":false,"open_issues_count":176,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":375,"open_issues":176,"watchers":2166,"default_branch":"release/2.2"}},"base":{"label":"aspnet:release/2.2","ref":"release/2.2","sha":"adc5706bcb2b3cb85e98e303999eb9a778426f7c","user":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":71159589,"node_id":"MDEwOlJlcG9zaXRvcnk3MTE1OTU4OQ==","name":"SignalR","full_name":"aspnet/SignalR","owner":{"login":"aspnet","id":6476660,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY0NzY2NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/6476660?v=4","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/SignalR","description":"Incredibly simple real-time web for ASP.NET Core","fork":false,"url":"https://api.github.com/repos/aspnet/SignalR","forks_url":"https://api.github.com/repos/aspnet/SignalR/forks","keys_url":"https://api.github.com/repos/aspnet/SignalR/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/SignalR/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/SignalR/teams","hooks_url":"https://api.github.com/repos/aspnet/SignalR/hooks","issue_events_url":"https://api.github.com/repos/aspnet/SignalR/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/SignalR/events","assignees_url":"https://api.github.com/repos/aspnet/SignalR/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/SignalR/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/SignalR/tags","blobs_url":"https://api.github.com/repos/aspnet/SignalR/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/SignalR/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/SignalR/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/SignalR/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/SignalR/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/SignalR/languages","stargazers_url":"https://api.github.com/repos/aspnet/SignalR/stargazers","contributors_url":"https://api.github.com/repos/aspnet/SignalR/contributors","subscribers_url":"https://api.github.com/repos/aspnet/SignalR/subscribers","subscription_url":"https://api.github.com/repos/aspnet/SignalR/subscription","commits_url":"https://api.github.com/repos/aspnet/SignalR/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/SignalR/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/SignalR/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/SignalR/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/SignalR/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/SignalR/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/SignalR/merges","archive_url":"https://api.github.com/repos/aspnet/SignalR/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/SignalR/downloads","issues_url":"https://api.github.com/repos/aspnet/SignalR/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/SignalR/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/SignalR/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/SignalR/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/SignalR/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/SignalR/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/SignalR/deployments","created_at":"2016-10-17T16:39:15Z","updated_at":"2018-09-11T10:06:31Z","pushed_at":"2018-09-11T17:39:14Z","git_url":"git://github.com/aspnet/SignalR.git","ssh_url":"git@github.com:aspnet/SignalR.git","clone_url":"https://github.com/aspnet/SignalR.git","svn_url":"https://github.com/aspnet/SignalR","homepage":null,"size":10380,"stargazers_count":2166,"watchers_count":2166,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":375,"mirror_url":null,"archived":false,"open_issues_count":176,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":375,"open_issues":176,"watchers":2166,"default_branch":"release/2.2"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/SignalR/pulls/2940"},"html":{"href":"https://github.com/aspnet/SignalR/pull/2940"},"issue":{"href":"https://api.github.com/repos/aspnet/SignalR/issues/2940"},"comments":{"href":"https://api.github.com/repos/aspnet/SignalR/issues/2940/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/SignalR/pulls/2940/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/SignalR/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/SignalR/pulls/2940/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/SignalR/statuses/56ea88958c77f8f5ae608a1e9831513c4175d2c2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"anurse"}}