{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/product-iots/pulls/comments/71152485","id":71152485,"diff_hunk":"@@ -0,0 +1,241 @@\n+/*\n+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ * WSO2 Inc. licenses this file to you under the Apache License,\n+ * Version 2.0 (the \"License\"); you may not use this file except\n+ * in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util.xmpp;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.jivesoftware.smack.ConnectionConfiguration;\n+import org.jivesoftware.smack.PacketListener;\n+import org.jivesoftware.smack.SmackConfiguration;\n+import org.jivesoftware.smack.XMPPConnection;\n+import org.jivesoftware.smack.XMPPException;\n+import org.jivesoftware.smack.filter.AndFilter;\n+import org.jivesoftware.smack.filter.FromContainsFilter;\n+import org.jivesoftware.smack.filter.PacketFilter;\n+import org.jivesoftware.smack.filter.PacketTypeFilter;\n+import org.jivesoftware.smack.packet.Message;\n+import org.jivesoftware.smack.packet.Packet;\n+import org.wso2.carbon.device.mgt.common.DeviceManagementException;\n+\n+/**\n+ * This class contains the Agent specific implementation for all the XMPP functionality. This\n+ * includes connecting to a XMPP Server & Login using the device's XMPP-Account, Setting\n+ * listeners and filters on incoming XMPP messages and Sending XMPP replies for control signals\n+ * received. Makes use of the 'Smack-XMPP' library provided by jivesoftware/igniterealtime.\n+ * <p/>\n+ * It is an abstract class with an abstract method 'processXMPPMessage' allowing the user to have\n+ * their own implementation of the actions to be taken upon receiving an appropriate XMPP message.\n+ */\n+public abstract class XMPPClient {\n+\tprivate static final Log log = LogFactory.getLog(XMPPClient.class);\n+\n+\tprivate int replyTimeoutInterval = 500;    // millis\n+\tprivate String server;\n+\tprivate int port;\n+\tprivate ConnectionConfiguration config;\n+\tprivate XMPPConnection connection;\n+\tprivate PacketFilter filter;\n+\tprivate PacketListener listener;\n+\n+\t/**\n+\t * Constructor for XMPPClient passing server-IP and the XMPP-port.\n+\t *\n+\t * @param server the IP of the XMPP server.\n+\t * @param port   the XMPP server's port to connect to. (default - 5222)\n+\t */\n+\tpublic XMPPClient(String server, int port) {\n+\t\tthis.server = server;\n+\t\tthis.port = port;\n+\t\tinitXMPPClient();\n+\t}\n+\n+\t/**\n+\t * Initializes the XMPP Client.\n+\t * Sets the time-out-limit whilst waiting for XMPP-replies from server. Creates the XMPP\n+\t * configurations to connect to the server and creates the XMPPConnection object used for\n+\t * connecting and Logging-In.\n+\t */\n+\tprivate void initXMPPClient() {\n+\t\tlog.info(String.format(\n+\t\t\t\t\"Initializing connection to XMPP Server at %1$s via port %2$d......\", server,\n+\t\t\t\tport));\n+\t\tSmackConfiguration.setPacketReplyTimeout(replyTimeoutInterval);\n+\t\tconfig = new ConnectionConfiguration(server, port);\n+//\t\tTODO:: Need to enable SASL-Authentication appropriately\n+\t\tconfig.setSASLAuthenticationEnabled(false);\n+\t\tconfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);\n+\t\tconnection = new XMPPConnection(config);\n+\t}\n+\n+\t/**\n+\t * Connects to the XMPP-Server and if successfully established connection, then tries to Log\n+\t * in using the device's XMPP Account credentials. (The XMPP-Account specific to the device is\n+\t * created in the XMPP server whilst downloading the Agent from the IoT Server) .\n+\t *\n+\t * @param username the username of the device's XMPP-Account.\n+\t * @param password the password of the device's XMPP-Account.\n+\t * @param resource the resource the resource, specific to the XMPP-Account to which the login\n+\t *                 is made to\n+\t * @throws DeviceManagementException in the event of 'Connecting to' or 'Logging into' the\n+\t *                                     XMPP server fails.\n+\t */\n+\tpublic void connectAndLogin(String username, String password, String resource)\n+\t\t\tthrows DeviceManagementException {\n+\t\ttry {\n+\t\t\tconnection.connect();\n+\t\t\tlog.info(String.format(\n+\t\t\t\t\t\"Connection to XMPP Server at %1$s established successfully......\", server));\n+\n+\t\t} catch (XMPPException xmppExcepion) {\n+\t\t\tString errorMsg =\n+\t\t\t\t\t\"Connection attempt to the XMPP Server at \" + server + \" via port \" + port +","path":"modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/xmpp/XMPPClient.java","position":107,"original_position":107,"commit_id":"7f83f1361d7c8fe22232e8bb0757197cc896f568","original_commit_id":"454a403a22717b753e049c4981ce99684af70316","user":{"login":"DilanUA","id":8347682,"avatar_url":"https://avatars.githubusercontent.com/u/8347682?v=3","gravatar_id":"","url":"https://api.github.com/users/DilanUA","html_url":"https://github.com/DilanUA","followers_url":"https://api.github.com/users/DilanUA/followers","following_url":"https://api.github.com/users/DilanUA/following{/other_user}","gists_url":"https://api.github.com/users/DilanUA/gists{/gist_id}","starred_url":"https://api.github.com/users/DilanUA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DilanUA/subscriptions","organizations_url":"https://api.github.com/users/DilanUA/orgs","repos_url":"https://api.github.com/users/DilanUA/repos","events_url":"https://api.github.com/users/DilanUA/events{/privacy}","received_events_url":"https://api.github.com/users/DilanUA/received_events","type":"User","site_admin":false},"body":"fix formatting issues on indentation.","created_at":"2016-07-18T14:05:35Z","updated_at":"2016-07-18T14:05:35Z","html_url":"https://github.com/wso2/product-iots/pull/7#discussion_r71152485","pull_request_url":"https://api.github.com/repos/wso2/product-iots/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/comments/71152485"},"html":{"href":"https://github.com/wso2/product-iots/pull/7#discussion_r71152485"},"pull_request":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/product-iots/pulls/7","id":47492982,"html_url":"https://github.com/wso2/product-iots/pull/7","diff_url":"https://github.com/wso2/product-iots/pull/7.diff","patch_url":"https://github.com/wso2/product-iots/pull/7.patch","issue_url":"https://api.github.com/repos/wso2/product-iots/issues/7","number":7,"state":"closed","locked":false,"title":"Build pack","user":{"login":"charithag","id":3184302,"avatar_url":"https://avatars.githubusercontent.com/u/3184302?v=3","gravatar_id":"","url":"https://api.github.com/users/charithag","html_url":"https://github.com/charithag","followers_url":"https://api.github.com/users/charithag/followers","following_url":"https://api.github.com/users/charithag/following{/other_user}","gists_url":"https://api.github.com/users/charithag/gists{/gist_id}","starred_url":"https://api.github.com/users/charithag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charithag/subscriptions","organizations_url":"https://api.github.com/users/charithag/orgs","repos_url":"https://api.github.com/users/charithag/repos","events_url":"https://api.github.com/users/charithag/events{/privacy}","received_events_url":"https://api.github.com/users/charithag/received_events","type":"User","site_admin":false},"body":"Merging build-pack changes with master. Form this point master will be the default build branch for product IoT Server, integrated with DAS, ES and APIM","created_at":"2015-10-13T05:40:28Z","updated_at":"2016-07-18T14:05:35Z","closed_at":"2015-10-13T05:41:07Z","merged_at":"2015-10-13T05:41:07Z","merge_commit_sha":"45f952aeecc20895449d4c7b3b8442e3c72e8017","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/product-iots/pulls/7/commits","review_comments_url":"https://api.github.com/repos/wso2/product-iots/pulls/7/comments","review_comment_url":"https://api.github.com/repos/wso2/product-iots/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/product-iots/issues/7/comments","statuses_url":"https://api.github.com/repos/wso2/product-iots/statuses/7f83f1361d7c8fe22232e8bb0757197cc896f568","head":{"label":"wso2:build-pack","ref":"build-pack","sha":"7f83f1361d7c8fe22232e8bb0757197cc896f568","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":42174888,"name":"product-iots","full_name":"wso2/product-iots","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/product-iots","description":"Welcome to the WSO2 IoT Server source code! For info on working with the WSO2 IoT Server repository and contributing code, click the link below.","fork":false,"url":"https://api.github.com/repos/wso2/product-iots","forks_url":"https://api.github.com/repos/wso2/product-iots/forks","keys_url":"https://api.github.com/repos/wso2/product-iots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/product-iots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/product-iots/teams","hooks_url":"https://api.github.com/repos/wso2/product-iots/hooks","issue_events_url":"https://api.github.com/repos/wso2/product-iots/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/product-iots/events","assignees_url":"https://api.github.com/repos/wso2/product-iots/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/product-iots/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/product-iots/tags","blobs_url":"https://api.github.com/repos/wso2/product-iots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/product-iots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/product-iots/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/product-iots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/product-iots/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/product-iots/languages","stargazers_url":"https://api.github.com/repos/wso2/product-iots/stargazers","contributors_url":"https://api.github.com/repos/wso2/product-iots/contributors","subscribers_url":"https://api.github.com/repos/wso2/product-iots/subscribers","subscription_url":"https://api.github.com/repos/wso2/product-iots/subscription","commits_url":"https://api.github.com/repos/wso2/product-iots/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/product-iots/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/product-iots/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/product-iots/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/product-iots/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/product-iots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/product-iots/merges","archive_url":"https://api.github.com/repos/wso2/product-iots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/product-iots/downloads","issues_url":"https://api.github.com/repos/wso2/product-iots/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/product-iots/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/product-iots/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/product-iots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/product-iots/labels{/name}","releases_url":"https://api.github.com/repos/wso2/product-iots/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/product-iots/deployments","created_at":"2015-09-09T11:39:56Z","updated_at":"2016-07-11T04:47:51Z","pushed_at":"2016-07-18T09:16:15Z","git_url":"git://github.com/wso2/product-iots.git","ssh_url":"git@github.com:wso2/product-iots.git","clone_url":"https://github.com/wso2/product-iots.git","svn_url":"https://github.com/wso2/product-iots","homepage":"http://wso2.github.io/","size":102201,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":0,"forks":23,"open_issues":0,"watchers":5,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"6d856ae975be54cd5506e9150d981a5f9e54cdc5","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":42174888,"name":"product-iots","full_name":"wso2/product-iots","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/product-iots","description":"Welcome to the WSO2 IoT Server source code! For info on working with the WSO2 IoT Server repository and contributing code, click the link below.","fork":false,"url":"https://api.github.com/repos/wso2/product-iots","forks_url":"https://api.github.com/repos/wso2/product-iots/forks","keys_url":"https://api.github.com/repos/wso2/product-iots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/product-iots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/product-iots/teams","hooks_url":"https://api.github.com/repos/wso2/product-iots/hooks","issue_events_url":"https://api.github.com/repos/wso2/product-iots/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/product-iots/events","assignees_url":"https://api.github.com/repos/wso2/product-iots/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/product-iots/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/product-iots/tags","blobs_url":"https://api.github.com/repos/wso2/product-iots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/product-iots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/product-iots/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/product-iots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/product-iots/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/product-iots/languages","stargazers_url":"https://api.github.com/repos/wso2/product-iots/stargazers","contributors_url":"https://api.github.com/repos/wso2/product-iots/contributors","subscribers_url":"https://api.github.com/repos/wso2/product-iots/subscribers","subscription_url":"https://api.github.com/repos/wso2/product-iots/subscription","commits_url":"https://api.github.com/repos/wso2/product-iots/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/product-iots/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/product-iots/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/product-iots/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/product-iots/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/product-iots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/product-iots/merges","archive_url":"https://api.github.com/repos/wso2/product-iots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/product-iots/downloads","issues_url":"https://api.github.com/repos/wso2/product-iots/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/product-iots/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/product-iots/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/product-iots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/product-iots/labels{/name}","releases_url":"https://api.github.com/repos/wso2/product-iots/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/product-iots/deployments","created_at":"2015-09-09T11:39:56Z","updated_at":"2016-07-11T04:47:51Z","pushed_at":"2016-07-18T09:16:15Z","git_url":"git://github.com/wso2/product-iots.git","ssh_url":"git@github.com:wso2/product-iots.git","clone_url":"https://github.com/wso2/product-iots.git","svn_url":"https://github.com/wso2/product-iots","homepage":"http://wso2.github.io/","size":102201,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":0,"forks":23,"open_issues":0,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/7"},"html":{"href":"https://github.com/wso2/product-iots/pull/7"},"issue":{"href":"https://api.github.com/repos/wso2/product-iots/issues/7"},"comments":{"href":"https://api.github.com/repos/wso2/product-iots/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/product-iots/statuses/7f83f1361d7c8fe22232e8bb0757197cc896f568"}}}}
{"actor":{"display_login":"DilanUA"}}