[
  {
    "path": ".gitignore",
    "content": "# Created by .ignore support plugin (hsz.mobi)\n### Java template\n# Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Package Files #\n*.jar\n*.war\n*.ear\n*.zip\n*.tar.gz\n*.rar\n\n# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml\nhs_err_pid*\n### JetBrains template\n# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm\n# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839\n\n# User-specific stuff:\n.idea/**/workspace.xml\n.idea/**/tasks.xml\n.idea/dictionaries\n\n# Sensitive or high-churn files:\n.idea/**/dataSources/\n.idea/**/dataSources.ids\n.idea/**/dataSources.xml\n.idea/**/dataSources.local.xml\n.idea/**/sqlDataSources.xml\n.idea/**/dynamic.xml\n.idea/**/uiDesigner.xml\n\n# Gradle:\n.idea/**/gradle.xml\n.idea/**/libraries\n\n# CMake\ncmake-build-debug/\n\n# Mongo Explorer plugin:\n.idea/**/mongoSettings.xml\n\n## File-based project format:\n*.iws\n\n## Plugin-specific files:\n\n# IntelliJ\nout/\n\n# mpeltonen/sbt-idea plugin\n.idea_modules/\n\n# JIRA plugin\natlassian-ide-plugin.xml\n\n# Cursive Clojure plugin\n.idea/replstate.xml\n\n# Crashlytics plugin (for Android Studio and IntelliJ)\ncom_crashlytics_export_strings.xml\ncrashlytics.properties\ncrashlytics-build.properties\nfabric.properties\n### Eclipse template\n\n.metadata\nbin/\ntmp/\n*.tmp\n*.bak\n*.swp\n*~.nib\nlocal.properties\n.settings/\n.loadpath\n.recommenders\n\n# External tool builders\n.externalToolBuilders/\n\n# Locally stored \"Eclipse launch configurations\"\n*.launch\n\n# PyDev specific (Python IDE for Eclipse)\n*.pydevproject\n\n# CDT-specific (C/C++ Development Tooling)\n.cproject\n\n# Java annotation processor (APT)\n.factorypath\n\n# PDT-specific (PHP Development Tools)\n.buildpath\n\n# sbteclipse plugin\n.target\n\n# Tern plugin\n.tern-project\n\n# TeXlipse plugin\n.texlipse\n\n# STS (Spring Tool Suite)\n.springBeans\n\n# Code Recommenders\n.recommenders/\n\n# Scala IDE specific (Scala & Java development for Eclipse)\n.cache-main\n.scala_dependencies\n.worksheet\n\n\n/client/target/\n/server/target/\n.idea/\nJavaFx.iml\n/server/server.iml\n/client/client.iml\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n\n    JavaFX-Chat - A Java FX Chat Client which communicates via sockets\n    Copyright (C) 2016  Dominic Heal www.dominicheal.com - www.github.com/DomHeal\n    \n        This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "README.md",
    "content": "# JavaFx-SocketChat\n\nA small application which using JavaFX for a GUI chat application.\n\nCurrently in Development.\n<p align=\"center\">\n<img src=\"https://github.com/DomHeal/JavaFX-Chat/blob/master/screenshots/Animation.gif?raw=true\"/>\n</p>\n<p align=\"center\">\n<img src=\"https://github.com/DomHeal/JavaFX-Chat/blob/master/screenshots/Animation3.gif?raw=true\"/>\n</br>\n<img src=\"http://i.imgur.com/2UvHIJb.png\"/>\n</p>\nNotifications using Tray-Notifications Library\n<p align=\"center\">\n<img src=\"http://i.imgur.com/Ckww6DW.png\"/>\n</p>\n\n<h3> To-Do </h3>\n<ul>\n  <li><strike>Multi-Client Support</strike></li>\n  <li><strike>Username Selection</strike></li>\n  <li><strike>MOTD on Connect</strike></li>\n  <li><strike>Connected Userlist</strike></li>\n  <li><strike>Basic Animation</strike></li>\n  <li>Profile Picture (<strike>Presets</strike> / Upload)</li>\n  <li><strike>Able to Set Status (Away / Busy / Online)</strike></li>\n  <li><strike>Voice Communication</strike></li>\n  <li>Sounds & External CSS</li>\n  <li>Server GUI</li>\n</ul>\n\n<h3> New Features! - Voice Messages </h3>\n<img src=\"https://github.com/DomHeal/JavaFX-Chat/blob/master/screenshots/voicemessage.png?raw=true\"/>\n"
  },
  {
    "path": "client/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n    <parent>\n        <groupId>groupId</groupId>\n        <artifactId>JavaFx</artifactId>\n        <version>1.0-SNAPSHOT</version>\n    </parent>\n    <artifactId>client</artifactId>\n    <packaging>jar</packaging>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-jar-plugin</artifactId>\n                <configuration>\n                    <archive>\n                        <manifest>\n                            <addClasspath>true</addClasspath>\n                            <mainClass>com.client.login.MainLauncher</mainClass>\n                        </manifest>\n                    </archive>\n                </configuration>\n            </plugin>\n\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-assembly-plugin</artifactId>\n                <version>2.4.1</version>\n                <configuration>\n                    <!-- get all project dependencies -->\n                    <descriptorRefs>\n                        <descriptorRef>jar-with-dependencies</descriptorRef>\n                    </descriptorRefs>\n                    <!-- MainClass in mainfest make a executable jar -->\n                    <archive>\n                        <manifest>\n                            <mainClass>com.client.login.MainLauncher</mainClass>\n                        </manifest>\n                    </archive>\n\n                </configuration>\n                <executions>\n                    <execution>\n                        <id>make-assembly</id>\n                        <!-- bind to the packaging phase -->\n                        <phase>package</phase>\n                        <goals>\n                            <goal>single</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n    <properties>\n        <slf4jVersion>1.6.1</slf4jVersion>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.fxmisc.richtext</groupId>\n            <artifactId>richtextfx</artifactId>\n            <version>0.6.10</version>\n        </dependency>\n        <dependency>\n            <groupId>org.controlsfx</groupId>\n            <artifactId>controlsfx</artifactId>\n            <version>8.40.10</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-api</artifactId>\n            <version>1.5.6</version>\n            <type>jar</type>\n        </dependency>\n        <dependency>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-simple</artifactId>\n            <version>1.5.6</version>\n        </dependency>\n    </dependencies>\n</project>"
  },
  {
    "path": "client/src/main/java/com/client/chatwindow/CellRenderer.java",
    "content": "package com.client.chatwindow;\n\nimport com.messages.User;\nimport javafx.geometry.Pos;\nimport javafx.scene.control.ListCell;\nimport javafx.scene.control.ListView;\nimport javafx.scene.image.Image;\nimport javafx.scene.image.ImageView;\nimport javafx.scene.layout.HBox;\nimport javafx.scene.text.Text;\nimport javafx.util.Callback;\n\n/**\n * A Class for Rendering users images / name on the userlist.\n */\nclass CellRenderer implements Callback<ListView<User>,ListCell<User>>{\n        @Override\n    public ListCell<User> call(ListView<User> p) {\n\n        ListCell<User> cell = new ListCell<User>(){\n\n            @Override\n            protected void updateItem(User user, boolean bln) {\n                super.updateItem(user, bln);\n                setGraphic(null);\n                setText(null);\n                if (user != null) {\n                    HBox hBox = new HBox();\n\n                    Text name = new Text(user.getName());\n\n                    ImageView statusImageView = new ImageView();\n                    Image statusImage = new Image(getClass().getClassLoader().getResource(\"images/\" + user.getStatus().toString().toLowerCase() + \".png\").toString(), 16, 16,true,true);\n                    statusImageView.setImage(statusImage);\n\n                    ImageView pictureImageView = new ImageView();\n                    Image image = new Image(getClass().getClassLoader().getResource(\"images/\" + user.getPicture().toLowerCase() + \".png\").toString(),50,50,true,true);\n                    pictureImageView.setImage(image);\n\n                    hBox.getChildren().addAll(statusImageView, pictureImageView, name);\n                    hBox.setAlignment(Pos.CENTER_LEFT);\n\n                    setGraphic(hBox);\n                }\n            }\n        };\n        return cell;\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/client/chatwindow/ChatController.java",
    "content": "package com.client.chatwindow;\n\nimport com.client.login.MainLauncher;\nimport com.client.util.VoicePlayback;\nimport com.client.util.VoiceRecorder;\nimport com.client.util.VoiceUtil;\nimport com.messages.Message;\nimport com.messages.MessageType;\nimport com.messages.Status;\nimport com.messages.User;\nimport com.messages.bubble.BubbleSpec;\nimport com.messages.bubble.BubbledLabel;\nimport com.traynotifications.animations.AnimationType;\nimport com.traynotifications.notification.TrayNotification;\nimport javafx.application.Platform;\nimport javafx.beans.value.ChangeListener;\nimport javafx.beans.value.ObservableValue;\nimport javafx.collections.FXCollections;\nimport javafx.collections.ObservableList;\nimport javafx.concurrent.Task;\nimport javafx.fxml.FXML;\nimport javafx.fxml.FXMLLoader;\nimport javafx.fxml.Initializable;\nimport javafx.geometry.Pos;\nimport javafx.scene.Cursor;\nimport javafx.scene.Parent;\nimport javafx.scene.Scene;\nimport javafx.scene.control.*;\nimport javafx.scene.image.Image;\nimport javafx.scene.image.ImageView;\nimport javafx.scene.input.KeyCode;\nimport javafx.scene.input.KeyEvent;\nimport javafx.scene.layout.*;\nimport javafx.scene.media.Media;\nimport javafx.scene.media.MediaPlayer;\nimport javafx.scene.paint.Color;\nimport javafx.scene.paint.Paint;\nimport javafx.stage.Stage;\nimport javafx.util.Duration;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\nimport java.io.IOException;\nimport java.net.URL;\nimport java.util.ResourceBundle;\n\n\npublic class ChatController implements Initializable {\n\n    @FXML private TextArea messageBox;\n    @FXML private Label usernameLabel;\n    @FXML private Label onlineCountLabel;\n    @FXML private ListView userList;\n    @FXML private ImageView userImageView;\n    @FXML private Button recordBtn;\n    @FXML ListView chatPane;\n    @FXML ListView statusList;\n    @FXML BorderPane borderPane;\n    @FXML ComboBox statusComboBox;\n    @FXML ImageView microphoneImageView;\n\n    Image microphoneActiveImage = new Image(getClass().getClassLoader().getResource(\"images/microphone-active.png\").toString());\n    Image microphoneInactiveImage = new Image(getClass().getClassLoader().getResource(\"images/microphone.png\").toString());\n\n    private double xOffset;\n    private double yOffset;\n    Logger logger = LoggerFactory.getLogger(ChatController.class);\n\n\n    public void sendButtonAction() throws IOException {\n        String msg = messageBox.getText();\n        if (!messageBox.getText().isEmpty()) {\n            Listener.send(msg);\n            messageBox.clear();\n        }\n    }\n\n    public void recordVoiceMessage() throws IOException {\n        if (VoiceUtil.isRecording()) {\n            Platform.runLater(() -> {\n                microphoneImageView.setImage(microphoneInactiveImage);\n                    }\n            );\n            VoiceUtil.setRecording(false);\n        } else {\n            Platform.runLater(() -> {\n                microphoneImageView.setImage(microphoneActiveImage);\n\n                    }\n            );\n            VoiceRecorder.captureAudio();\n        }\n    }\n\n\n    public synchronized void addToChat(Message msg) {\n        Task<HBox> othersMessages = new Task<HBox>() {\n            @Override\n            public HBox call() throws Exception {\n                Image image = new Image(getClass().getClassLoader().getResource(\"images/\" + msg.getPicture().toLowerCase() + \".png\").toString());\n                ImageView profileImage = new ImageView(image);\n                profileImage.setFitHeight(32);\n                profileImage.setFitWidth(32);\n                BubbledLabel bl6 = new BubbledLabel();\n                if (msg.getType() == MessageType.VOICE){\n                    ImageView imageview = new ImageView(new Image(getClass().getClassLoader().getResource(\"images/sound.png\").toString()));\n                    bl6.setGraphic(imageview);\n                    bl6.setText(\"Sent a voice message!\");\n                    VoicePlayback.playAudio(msg.getVoiceMsg());\n                }else {\n                    bl6.setText(msg.getName() + \": \" + msg.getMsg());\n                }\n                bl6.setBackground(new Background(new BackgroundFill(Color.WHITE,null, null)));\n                HBox x = new HBox();\n                bl6.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);\n                x.getChildren().addAll(profileImage, bl6);\n                logger.debug(\"ONLINE USERS: \" + Integer.toString(msg.getUserlist().size()));\n                setOnlineLabel(Integer.toString(msg.getOnlineCount()));\n                return x;\n            }\n        };\n\n        othersMessages.setOnSucceeded(event -> {\n            chatPane.getItems().add(othersMessages.getValue());\n        });\n\n        Task<HBox> yourMessages = new Task<HBox>() {\n            @Override\n            public HBox call() throws Exception {\n                Image image = userImageView.getImage();\n                ImageView profileImage = new ImageView(image);\n                profileImage.setFitHeight(32);\n                profileImage.setFitWidth(32);\n\n                BubbledLabel bl6 = new BubbledLabel();\n                if (msg.getType() == MessageType.VOICE){\n                    bl6.setGraphic(new ImageView(new Image(getClass().getClassLoader().getResource(\"images/sound.png\").toString())));\n                    bl6.setText(\"Sent a voice message!\");\n                    VoicePlayback.playAudio(msg.getVoiceMsg());\n                }else {\n                    bl6.setText(msg.getMsg());\n                }\n                bl6.setBackground(new Background(new BackgroundFill(Color.LIGHTGREEN,\n                        null, null)));\n                HBox x = new HBox();\n                x.setMaxWidth(chatPane.getWidth() - 20);\n                x.setAlignment(Pos.TOP_RIGHT);\n                bl6.setBubbleSpec(BubbleSpec.FACE_RIGHT_CENTER);\n                x.getChildren().addAll(bl6, profileImage);\n\n                setOnlineLabel(Integer.toString(msg.getOnlineCount()));\n                return x;\n            }\n        };\n        yourMessages.setOnSucceeded(event -> chatPane.getItems().add(yourMessages.getValue()));\n\n        if (msg.getName().equals(usernameLabel.getText())) {\n            Thread t2 = new Thread(yourMessages);\n            t2.setDaemon(true);\n            t2.start();\n        } else {\n            Thread t = new Thread(othersMessages);\n            t.setDaemon(true);\n            t.start();\n        }\n    }\n    public void setUsernameLabel(String username) {\n        this.usernameLabel.setText(username);\n    }\n\n    public void setImageLabel() throws IOException {\n        this.userImageView.setImage(new Image(getClass().getClassLoader().getResource(\"images/dominic.png\").toString()));\n    }\n\n    public void setOnlineLabel(String usercount) {\n        Platform.runLater(() -> onlineCountLabel.setText(usercount));\n    }\n\n    public void setUserList(Message msg) {\n        logger.info(\"setUserList() method Enter\");\n        Platform.runLater(() -> {\n            ObservableList<User> users = FXCollections.observableList(msg.getUsers());\n            userList.setItems(users);\n            userList.setCellFactory(new CellRenderer());\n            setOnlineLabel(String.valueOf(msg.getUserlist().size()));\n        });\n        logger.info(\"setUserList() method Exit\");\n    }\n\n    /* Displays Notification when a user joins */\n    public void newUserNotification(Message msg) {\n        Platform.runLater(() -> {\n            Image profileImg = new Image(getClass().getClassLoader().getResource(\"images/\" + msg.getPicture().toLowerCase() +\".png\").toString(),50,50,false,false);\n            TrayNotification tray = new TrayNotification();\n            tray.setTitle(\"A new user has joined!\");\n            tray.setMessage(msg.getName() + \" has joined the JavaFX Chatroom!\");\n            tray.setRectangleFill(Paint.valueOf(\"#2C3E50\"));\n            tray.setAnimationType(AnimationType.POPUP);\n            tray.setImage(profileImg);\n            tray.showAndDismiss(Duration.seconds(5));\n            try {\n                Media hit = new Media(getClass().getClassLoader().getResource(\"sounds/notification.wav\").toString());\n                MediaPlayer mediaPlayer = new MediaPlayer(hit);\n                mediaPlayer.play();\n            } catch (Exception e) {\n                e.printStackTrace();\n            }\n\n        });\n    }\n\n    public void sendMethod(KeyEvent event) throws IOException {\n        if (event.getCode() == KeyCode.ENTER) {\n            sendButtonAction();\n        }\n    }\n\n    @FXML\n    public void closeApplication() {\n        Platform.exit();\n        System.exit(0);\n    }\n\n    /* Method to display server messages */\n    public synchronized void addAsServer(Message msg) {\n        Task<HBox> task = new Task<HBox>() {\n            @Override\n            public HBox call() throws Exception {\n                BubbledLabel bl6 = new BubbledLabel();\n                bl6.setText(msg.getMsg());\n                bl6.setBackground(new Background(new BackgroundFill(Color.ALICEBLUE,\n                        null, null)));\n                HBox x = new HBox();\n                bl6.setBubbleSpec(BubbleSpec.FACE_BOTTOM);\n                x.setAlignment(Pos.CENTER);\n                x.getChildren().addAll(bl6);\n                return x;\n            }\n        };\n        task.setOnSucceeded(event -> {\n            chatPane.getItems().add(task.getValue());\n        });\n\n        Thread t = new Thread(task);\n        t.setDaemon(true);\n        t.start();\n    }\n\n    @Override\n    public void initialize(URL location, ResourceBundle resources) {\n        try {\n            setImageLabel();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n                /* Drag and Drop */\n        borderPane.setOnMousePressed(event -> {\n            xOffset = MainLauncher.getPrimaryStage().getX() - event.getScreenX();\n            yOffset = MainLauncher.getPrimaryStage().getY() - event.getScreenY();\n            borderPane.setCursor(Cursor.CLOSED_HAND);\n        });\n\n        borderPane.setOnMouseDragged(event -> {\n            MainLauncher.getPrimaryStage().setX(event.getScreenX() + xOffset);\n            MainLauncher.getPrimaryStage().setY(event.getScreenY() + yOffset);\n\n        });\n\n        borderPane.setOnMouseReleased(event -> {\n            borderPane.setCursor(Cursor.DEFAULT);\n        });\n\n        statusComboBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {\n            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {\n                try {\n                    Listener.sendStatusUpdate(Status.valueOf(newValue.toUpperCase()));\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n            }\n        });\n\n        /* Added to prevent the enter from adding a new line to inputMessageBox */\n        messageBox.addEventFilter(KeyEvent.KEY_PRESSED, ke -> {\n            if (ke.getCode().equals(KeyCode.ENTER)) {\n                try {\n                    sendButtonAction();\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n                ke.consume();\n            }\n        });\n\n    }\n\n    public void setImageLabel(String selectedPicture) {\n        switch (selectedPicture) {\n            case \"Dominic\":\n                this.userImageView.setImage(new Image(getClass().getClassLoader().getResource(\"images/dominic.png\").toString()));\n                break;\n            case \"Sarah\":\n                this.userImageView.setImage(new Image(getClass().getClassLoader().getResource(\"images/sarah.png\").toString()));\n                break;\n            case \"Default\":\n                this.userImageView.setImage(new Image(getClass().getClassLoader().getResource(\"images/default.png\").toString()));\n                break;\n        }\n    }\n\n    public void logoutScene() {\n        Platform.runLater(() -> {\n            FXMLLoader fmxlLoader = new FXMLLoader(getClass().getResource(\"/views/LoginView.fxml\"));\n            Parent window = null;\n            try {\n                window = (Pane) fmxlLoader.load();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n            Stage stage = MainLauncher.getPrimaryStage();\n            Scene scene = new Scene(window);\n            stage.setMaxWidth(350);\n            stage.setMaxHeight(420);\n            stage.setResizable(false);\n            stage.setScene(scene);\n            stage.centerOnScreen();\n        });\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/client/chatwindow/Listener.java",
    "content": "package com.client.chatwindow;\n\nimport com.client.login.LoginController;\nimport com.messages.Message;\nimport com.messages.MessageType;\nimport com.messages.Status;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\nimport java.io.*;\nimport java.net.Socket;\n\nimport static com.messages.MessageType.CONNECTED;\n\npublic class Listener implements Runnable{\n\n    private static final String HASCONNECTED = \"has connected\";\n\n    private static String picture;\n    private Socket socket;\n    public String hostname;\n    public int port;\n    public static String username;\n    public ChatController controller;\n    private static ObjectOutputStream oos;\n    private InputStream is;\n    private ObjectInputStream input;\n    private OutputStream outputStream;\n    Logger logger = LoggerFactory.getLogger(Listener.class);\n\n    public Listener(String hostname, int port, String username, String picture, ChatController controller) {\n        this.hostname = hostname;\n        this.port = port;\n        Listener.username = username;\n        Listener.picture = picture;\n        this.controller = controller;\n    }\n\n    public void run() {\n        try {\n            socket = new Socket(hostname, port);\n            LoginController.getInstance().showScene();\n            outputStream = socket.getOutputStream();\n            oos = new ObjectOutputStream(outputStream);\n            is = socket.getInputStream();\n            input = new ObjectInputStream(is);\n        } catch (IOException e) {\n            LoginController.getInstance().showErrorDialog(\"Could not connect to server\");\n            logger.error(\"Could not Connect\");\n        }\n        logger.info(\"Connection accepted \" + socket.getInetAddress() + \":\" + socket.getPort());\n\n        try {\n            connect();\n            logger.info(\"Sockets in and out ready!\");\n            while (socket.isConnected()) {\n                Message message = null;\n                message = (Message) input.readObject();\n\n                if (message != null) {\n                    logger.debug(\"Message recieved:\" + message.getMsg() + \" MessageType:\" + message.getType() + \"Name:\" + message.getName());\n                    switch (message.getType()) {\n                        case USER:\n                            controller.addToChat(message);\n                            break;\n                        case VOICE:\n                            controller.addToChat(message);\n                            break;\n                        case NOTIFICATION:\n                            controller.newUserNotification(message);\n                            break;\n                        case SERVER:\n                            controller.addAsServer(message);\n                            break;\n                        case CONNECTED:\n                            controller.setUserList(message);\n                            break;\n                        case DISCONNECTED:\n                            controller.setUserList(message);\n                            break;\n                        case STATUS:\n                            controller.setUserList(message);\n                            break;\n                    }\n                }\n            }\n        } catch (IOException | ClassNotFoundException e) {\n            e.printStackTrace();\n            controller.logoutScene();\n        }\n    }\n\n    /* This method is used for sending a normal Message\n     * @param msg - The message which the user generates\n     */\n    public static void send(String msg) throws IOException {\n        Message createMessage = new Message();\n        createMessage.setName(username);\n        createMessage.setType(MessageType.USER);\n        createMessage.setStatus(Status.AWAY);\n        createMessage.setMsg(msg);\n        createMessage.setPicture(picture);\n        oos.writeObject(createMessage);\n        oos.flush();\n    }\n\n    /* This method is used for sending a voice Message\n * @param msg - The message which the user generates\n */\n    public static void sendVoiceMessage(byte[] audio) throws IOException {\n        Message createMessage = new Message();\n        createMessage.setName(username);\n        createMessage.setType(MessageType.VOICE);\n        createMessage.setStatus(Status.AWAY);\n        createMessage.setVoiceMsg(audio);\n        createMessage.setPicture(picture);\n        oos.writeObject(createMessage);\n        oos.flush();\n    }\n\n    /* This method is used for sending a normal Message\n * @param msg - The message which the user generates\n */\n    public static void sendStatusUpdate(Status status) throws IOException {\n        Message createMessage = new Message();\n        createMessage.setName(username);\n        createMessage.setType(MessageType.STATUS);\n        createMessage.setStatus(status);\n        createMessage.setPicture(picture);\n        oos.writeObject(createMessage);\n        oos.flush();\n    }\n\n    /* This method is used to send a connecting message */\n    public static void connect() throws IOException {\n        Message createMessage = new Message();\n        createMessage.setName(username);\n        createMessage.setType(CONNECTED);\n        createMessage.setMsg(HASCONNECTED);\n        createMessage.setPicture(picture);\n        oos.writeObject(createMessage);\n    }\n\n}\n"
  },
  {
    "path": "client/src/main/java/com/client/login/LoginController.java",
    "content": "package com.client.login;\n\nimport com.client.chatwindow.ChatController;\nimport com.client.chatwindow.Listener;\nimport com.client.util.ResizeHelper;\nimport javafx.animation.KeyFrame;\nimport javafx.animation.KeyValue;\nimport javafx.animation.Timeline;\nimport javafx.application.Platform;\nimport javafx.beans.value.ChangeListener;\nimport javafx.beans.value.ObservableValue;\nimport javafx.fxml.FXML;\nimport javafx.fxml.FXMLLoader;\nimport javafx.fxml.Initializable;\nimport javafx.scene.Cursor;\nimport javafx.scene.Parent;\nimport javafx.scene.Scene;\nimport javafx.scene.control.*;\nimport javafx.scene.image.ImageView;\nimport javafx.scene.layout.BorderPane;\nimport javafx.scene.layout.Pane;\nimport javafx.scene.paint.Color;\nimport javafx.scene.shape.Rectangle;\nimport javafx.stage.Stage;\nimport javafx.stage.WindowEvent;\nimport javafx.util.Duration;\n\nimport java.io.IOException;\nimport java.net.URL;\nimport java.util.Random;\nimport java.util.ResourceBundle;\n\n/**\n *  Created by Dominic on 12-Nov-15.\n */\npublic class LoginController implements Initializable {\n    @FXML private ImageView Defaultview;\n    @FXML private ImageView Sarahview;\n    @FXML private ImageView Dominicview;\n    @FXML public  TextField hostnameTextfield;\n    @FXML private TextField portTextfield;\n    @FXML private TextField usernameTextfield;\n    @FXML private ChoiceBox imagePicker;\n    @FXML private Label selectedPicture;\n    public static ChatController con;\n    @FXML private BorderPane borderPane;\n    private double xOffset;\n    private double yOffset;\n    private Scene scene;\n\n    private static LoginController instance;\n\n    public LoginController() {\n        instance = this;\n    }\n\n    public static LoginController getInstance() {\n        return instance;\n    }\n    public void loginButtonAction() throws IOException {\n        String hostname = hostnameTextfield.getText();\n        int port = Integer.parseInt(portTextfield.getText());\n        String username = usernameTextfield.getText();\n        String picture = selectedPicture.getText();\n\n        FXMLLoader fmxlLoader = new FXMLLoader(getClass().getResource(\"/views/ChatView.fxml\"));\n        Parent window = (Pane) fmxlLoader.load();\n        con = fmxlLoader.<ChatController>getController();\n        Listener listener = new Listener(hostname, port, username, picture, con);\n        Thread x = new Thread(listener);\n        x.start();\n        this.scene = new Scene(window);\n    }\n\n    public void showScene() throws IOException {\n        Platform.runLater(() -> {\n            Stage stage = (Stage) hostnameTextfield.getScene().getWindow();\n            stage.setResizable(true);\n            stage.setWidth(1040);\n            stage.setHeight(620);\n\n            stage.setOnCloseRequest((WindowEvent e) -> {\n                Platform.exit();\n                System.exit(0);\n            });\n            stage.setScene(this.scene);\n            stage.setMinWidth(800);\n            stage.setMinHeight(300);\n            ResizeHelper.addResizeListener(stage);\n            stage.centerOnScreen();\n            con.setUsernameLabel(usernameTextfield.getText());\n            con.setImageLabel(selectedPicture.getText());\n        });\n    }\n\n    @Override\n    public void initialize(URL location, ResourceBundle resources) {\n        imagePicker.getSelectionModel().selectFirst();\n        selectedPicture.textProperty().bind(imagePicker.getSelectionModel().selectedItemProperty());\n        selectedPicture.setVisible(false);\n\n        /* Drag and Drop */\n        borderPane.setOnMousePressed(event -> {\n            xOffset = MainLauncher.getPrimaryStage().getX() - event.getScreenX();\n            yOffset = MainLauncher.getPrimaryStage().getY() - event.getScreenY();\n            borderPane.setCursor(Cursor.CLOSED_HAND);\n        });\n\n        borderPane.setOnMouseDragged(event -> {\n            MainLauncher.getPrimaryStage().setX(event.getScreenX() + xOffset);\n            MainLauncher.getPrimaryStage().setY(event.getScreenY() + yOffset);\n\n        });\n\n        borderPane.setOnMouseReleased(event -> {\n            borderPane.setCursor(Cursor.DEFAULT);\n        });\n\n        imagePicker.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {\n            @Override\n            public void changed(ObservableValue<? extends String> selected, String oldPicture, String newPicture) {\n                if (oldPicture != null) {\n                    switch (oldPicture) {\n                        case \"Default\":\n                            Defaultview.setVisible(false);\n                            break;\n                        case \"Dominic\":\n                            Dominicview.setVisible(false);\n                            break;\n                        case \"Sarah\":\n                            Sarahview.setVisible(false);\n                            break;\n                    }\n                }\n                if (newPicture != null) {\n                    switch (newPicture) {\n                        case \"Default\":\n                            Defaultview.setVisible(true);\n                            break;\n                        case \"Dominic\":\n                            Dominicview.setVisible(true);\n                            break;\n                        case \"Sarah\":\n                            Sarahview.setVisible(true);\n                            break;\n                    }\n                }\n            }\n        });\n        int numberOfSquares = 30;\n        while (numberOfSquares > 0){\n            generateAnimation();\n            numberOfSquares--;\n        }\n    }\n\n\n    /* This method is used to generate the animation on the login window, It will generate random ints to determine\n     * the size, speed, starting points and direction of each square.\n     */\n    public void generateAnimation(){\n        Random rand = new Random();\n        int sizeOfSqaure = rand.nextInt(50) + 1;\n        int speedOfSqaure = rand.nextInt(10) + 5;\n        int startXPoint = rand.nextInt(420);\n        int startYPoint = rand.nextInt(350);\n        int direction = rand.nextInt(5) + 1;\n\n        KeyValue moveXAxis = null;\n        KeyValue moveYAxis = null;\n        Rectangle r1 = null;\n\n        switch (direction){\n            case 1 :\n                // MOVE LEFT TO RIGHT\n                r1 = new Rectangle(0,startYPoint,sizeOfSqaure,sizeOfSqaure);\n                moveXAxis = new KeyValue(r1.xProperty(), 350 -  sizeOfSqaure);\n                break;\n            case 2 :\n                // MOVE TOP TO BOTTOM\n                r1 = new Rectangle(startXPoint,0,sizeOfSqaure,sizeOfSqaure);\n                moveYAxis = new KeyValue(r1.yProperty(), 420 - sizeOfSqaure);\n                break;\n            case 3 :\n                // MOVE LEFT TO RIGHT, TOP TO BOTTOM\n                r1 = new Rectangle(startXPoint,0,sizeOfSqaure,sizeOfSqaure);\n                moveXAxis = new KeyValue(r1.xProperty(), 350 -  sizeOfSqaure);\n                moveYAxis = new KeyValue(r1.yProperty(), 420 - sizeOfSqaure);\n                break;\n            case 4 :\n                // MOVE BOTTOM TO TOP\n                r1 = new Rectangle(startXPoint,420-sizeOfSqaure ,sizeOfSqaure,sizeOfSqaure);\n                moveYAxis = new KeyValue(r1.xProperty(), 0);\n                break;\n            case 5 :\n                // MOVE RIGHT TO LEFT\n                r1 = new Rectangle(420-sizeOfSqaure,startYPoint,sizeOfSqaure,sizeOfSqaure);\n                moveXAxis = new KeyValue(r1.xProperty(), 0);\n                break;\n            case 6 :\n                //MOVE RIGHT TO LEFT, BOTTOM TO TOP\n                r1 = new Rectangle(startXPoint,0,sizeOfSqaure,sizeOfSqaure);\n                moveXAxis = new KeyValue(r1.xProperty(), 350 -  sizeOfSqaure);\n                moveYAxis = new KeyValue(r1.yProperty(), 420 - sizeOfSqaure);\n                break;\n\n            default:\n                System.out.println(\"default\");\n        }\n\n        r1.setFill(Color.web(\"#F89406\"));\n        r1.setOpacity(0.1);\n\n        KeyFrame keyFrame = new KeyFrame(Duration.millis(speedOfSqaure * 1000), moveXAxis, moveYAxis);\n        Timeline timeline = new Timeline();\n        timeline.setCycleCount(Timeline.INDEFINITE);\n        timeline.setAutoReverse(true);\n        timeline.getKeyFrames().add(keyFrame);\n        timeline.play();\n        borderPane.getChildren().add(borderPane.getChildren().size()-1,r1);\n    }\n\n    /* Terminates Application */\n    public void closeSystem(){\n        Platform.exit();\n        System.exit(0);\n    }\n\n    public void minimizeWindow(){\n        MainLauncher.getPrimaryStage().setIconified(true);\n    }\n\n    /* This displays an alert message to the user */\n    public void showErrorDialog(String message) {\n        Platform.runLater(()-> {\n            Alert alert = new Alert(Alert.AlertType.WARNING);\n            alert.setTitle(\"Warning!\");\n            alert.setHeaderText(message);\n            alert.setContentText(\"Please check for firewall issues and check if the server is running.\");\n            alert.showAndWait();\n        });\n\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/client/login/MainLauncher.java",
    "content": "package com.client.login;\n\nimport javafx.application.Application;\nimport javafx.application.Platform;\nimport javafx.fxml.FXMLLoader;\nimport javafx.scene.Parent;\nimport javafx.scene.Scene;\nimport javafx.scene.image.Image;\nimport javafx.stage.Stage;\nimport javafx.stage.StageStyle;\n\npublic class MainLauncher extends Application {\n\n    private static Stage primaryStageObj;\n\n    @Override\n    public void start(Stage primaryStage) throws Exception {\n        primaryStageObj = primaryStage;\n        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource(\"views/LoginView.fxml\"));\n        primaryStage.initStyle(StageStyle.UNDECORATED);\n        primaryStage.setTitle(\"Socket Chat : Client version 0.3\");\n        primaryStage.getIcons().add(new Image(getClass().getClassLoader().getResource(\"images/plug.png\").toString()));\n        Scene mainScene = new Scene(root, 350, 420);\n        mainScene.setRoot(root);\n        primaryStage.setResizable(false);\n        primaryStage.setScene(mainScene);\n        primaryStage.show();\n        primaryStage.setOnCloseRequest(e -> Platform.exit());\n    }\n\n\n    public static void main(String[] args) {\n        launch(args);\n    }\n\n    public static Stage getPrimaryStage() {\n        return primaryStageObj;\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/client/util/ResizeHelper.java",
    "content": "package com.client.util;\n\nimport javafx.collections.ObservableList;\nimport javafx.event.EventHandler;\nimport javafx.event.EventType;\nimport javafx.scene.Cursor;\nimport javafx.scene.Node;\nimport javafx.scene.Parent;\nimport javafx.scene.Scene;\nimport javafx.scene.input.MouseEvent;\nimport javafx.stage.Stage;\n\n//created by Alexander Berg\npublic class ResizeHelper {\n\n    public static void addResizeListener(Stage stage) {\n        ResizeListener resizeListener = new ResizeListener(stage);\n        stage.getScene().addEventHandler(MouseEvent.MOUSE_MOVED, resizeListener);\n        stage.getScene().addEventHandler(MouseEvent.MOUSE_PRESSED, resizeListener);\n        stage.getScene().addEventHandler(MouseEvent.MOUSE_DRAGGED, resizeListener);\n        stage.getScene().addEventHandler(MouseEvent.MOUSE_EXITED, resizeListener);\n        stage.getScene().addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, resizeListener);\n        ObservableList<Node> children = stage.getScene().getRoot().getChildrenUnmodifiable();\n        for (Node child : children) {\n            addListenerDeeply(child, resizeListener);\n        }\n    }\n\n    public static void addListenerDeeply(Node node, EventHandler<MouseEvent> listener) {\n        node.addEventHandler(MouseEvent.MOUSE_MOVED, listener);\n        node.addEventHandler(MouseEvent.MOUSE_PRESSED, listener);\n        node.addEventHandler(MouseEvent.MOUSE_DRAGGED, listener);\n        node.addEventHandler(MouseEvent.MOUSE_EXITED, listener);\n        node.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, listener);\n        if (node instanceof Parent) {\n            Parent parent = (Parent) node;\n            ObservableList<Node> children = parent.getChildrenUnmodifiable();\n            for (Node child : children) {\n                addListenerDeeply(child, listener);\n            }\n        }\n    }\n\n    static class ResizeListener implements EventHandler<MouseEvent> {\n        private Stage stage;\n        private Cursor cursorEvent = Cursor.DEFAULT;\n        private int border = 4;\n        private double startX = 0;\n        private double startY = 0;\n\n        public ResizeListener(Stage stage) {\n            this.stage = stage;\n        }\n\n        @Override\n        public void handle(MouseEvent mouseEvent) {\n            EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();\n            Scene scene = stage.getScene();\n\n            double mouseEventX = mouseEvent.getSceneX(),\n                    mouseEventY = mouseEvent.getSceneY(),\n                    sceneWidth = scene.getWidth(),\n                    sceneHeight = scene.getHeight();\n\n            if (MouseEvent.MOUSE_MOVED.equals(mouseEventType)) {\n                if (mouseEventX < border && mouseEventY < border) {\n                    cursorEvent = Cursor.NW_RESIZE;\n                } else if (mouseEventX < border && mouseEventY > sceneHeight - border) {\n                    cursorEvent = Cursor.SW_RESIZE;\n                } else if (mouseEventX > sceneWidth - border && mouseEventY < border) {\n                    cursorEvent = Cursor.NE_RESIZE;\n                } else if (mouseEventX > sceneWidth - border && mouseEventY > sceneHeight - border) {\n                    cursorEvent = Cursor.SE_RESIZE;\n                } else if (mouseEventX < border) {\n                    cursorEvent = Cursor.W_RESIZE;\n                } else if (mouseEventX > sceneWidth - border) {\n                    cursorEvent = Cursor.E_RESIZE;\n                } else if (mouseEventY < border) {\n                    cursorEvent = Cursor.N_RESIZE;\n                } else if (mouseEventY > sceneHeight - border) {\n                    cursorEvent = Cursor.S_RESIZE;\n                } else {\n                    cursorEvent = Cursor.DEFAULT;\n                }\n                scene.setCursor(cursorEvent);\n            } else if(MouseEvent.MOUSE_EXITED.equals(mouseEventType) || MouseEvent.MOUSE_EXITED_TARGET.equals(mouseEventType)){\n                scene.setCursor(Cursor.DEFAULT);\n            } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) {\n                startX = stage.getWidth() - mouseEventX;\n                startY = stage.getHeight() - mouseEventY;\n            } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) {\n                if (Cursor.DEFAULT.equals(cursorEvent) == false) {\n                    if (Cursor.W_RESIZE.equals(cursorEvent) == false && Cursor.E_RESIZE.equals(cursorEvent) == false) {\n                        double minHeight = stage.getMinHeight() > (border*2) ? stage.getMinHeight() : (border*2);\n                        if (Cursor.NW_RESIZE.equals(cursorEvent) == true || Cursor.N_RESIZE.equals(cursorEvent) == true || Cursor.NE_RESIZE.equals(cursorEvent) == true) {\n                            if (stage.getHeight() > minHeight || mouseEventY < 0) {\n                                stage.setHeight(stage.getY() - mouseEvent.getScreenY() + stage.getHeight());\n                                stage.setY(mouseEvent.getScreenY());\n                            }\n                        } else {\n                            if (stage.getHeight() > minHeight || mouseEventY + startY - stage.getHeight() > 0) {\n                                stage.setHeight(mouseEventY + startY);\n                            }\n                        }\n                    }\n\n                    if (Cursor.N_RESIZE.equals(cursorEvent) == false && Cursor.S_RESIZE.equals(cursorEvent) == false) {\n                        double minWidth = stage.getMinWidth() > (border*2) ? stage.getMinWidth() : (border*2);\n                        if (Cursor.NW_RESIZE.equals(cursorEvent) == true || Cursor.W_RESIZE.equals(cursorEvent) == true || Cursor.SW_RESIZE.equals(cursorEvent) == true) {\n                            if (stage.getWidth() > minWidth || mouseEventX < 0) {\n                                stage.setWidth(stage.getX() - mouseEvent.getScreenX() + stage.getWidth());\n                                stage.setX(mouseEvent.getScreenX());\n                            }\n                        } else {\n                            if (stage.getWidth() > minWidth || mouseEventX + startX - stage.getWidth() > 0) {\n                                stage.setWidth(mouseEventX + startX);\n                            }\n                        }\n                    }\n                }\n\n            }\n        }\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/client/util/VoicePlayback.java",
    "content": "package com.client.util;\n\nimport javax.sound.sampled.*;\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * @author Dominic\n * @since 16-Oct-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic class VoicePlayback extends VoiceUtil {\n    public static void playAudio(byte[] audio) {\n        try {\n            InputStream input = new ByteArrayInputStream(audio);\n            final AudioFormat format = getAudioFormat();\n            final AudioInputStream ais = new AudioInputStream(input, format, audio.length / format.getFrameSize());\n            DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);\n            final SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);\n            line.open(format);\n            line.start();\n\n            Runnable runner = new Runnable() {\n                int bufferSize = (int) format.getSampleRate() * format.getFrameSize();\n                byte buffer[] = new byte[bufferSize];\n\n                public void run() {\n                    try {\n                        int count;\n                        while ((count = ais.read(\n                                buffer, 0, buffer.length)) != -1) {\n                            if (count > 0) {\n                                line.write(buffer, 0, count);\n                            }\n                        }\n                    } catch (IOException e) {\n                        System.err.println(\"I/O problems: \" + e);\n                    } finally {\n                        line.drain();\n                        line.close();\n                    }\n                }\n            };\n            Thread playThread = new Thread(runner);\n            playThread.start();\n        } catch (LineUnavailableException e) {\n            System.err.println(\"Line unavailable: \" + e);\n        }\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/client/util/VoiceRecorder.java",
    "content": "package com.client.util;\n\nimport com.client.chatwindow.Listener;\n\nimport javax.sound.sampled.*;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\n\n/**\n * @author Dominic\n * @since 16-Oct-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic class VoiceRecorder extends VoiceUtil {\n\n    public static void captureAudio() {\n        try {\n            final AudioFormat format = getAudioFormat();\n            DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);\n            final TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);\n            line.open(format);\n            line.start();\n            Runnable runner = new Runnable() {\n                int bufferSize = (int)format.getSampleRate() * format.getFrameSize();\n                byte buffer[] = new byte[bufferSize];\n\n                public void run() {\n                    out = new ByteArrayOutputStream();\n                    isRecording = true;\n                    try {\n                        while (isRecording) {\n                            int count = line.read(buffer, 0, buffer.length);\n                            if (count > 0) {\n                                out.write(buffer, 0, count);\n                            }\n                        }\n                    } finally {\n                        try {\n                            out.close();\n                            out.flush();\n                            line.close();\n                            line.flush();\n                            Listener.sendVoiceMessage(out.toByteArray());\n                        } catch (IOException e) {\n                            e.printStackTrace();\n                        }\n                    }\n                }\n            };\n            Thread captureThread = new Thread(runner);\n            captureThread.start();\n        } catch (LineUnavailableException e) {\n            System.err.println(\"Line unavailable: \" );\n            e.printStackTrace();\n        }\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/client/util/VoiceUtil.java",
    "content": "package com.client.util;\n\nimport javax.sound.sampled.AudioFormat;\nimport java.io.ByteArrayOutputStream;\n\n/**\n * @author Dominic\n * @since 16-Oct-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic class VoiceUtil {\n    public static void setRecording(boolean flag){\n        isRecording = flag;\n    }\n\n    public static boolean isRecording() {\n        return isRecording;\n    }\n\n    protected static boolean isRecording = false;\n    static ByteArrayOutputStream out;\n    /**\n     * Defines an audio format\n     */\n    static AudioFormat getAudioFormat() {\n        float sampleRate = 16000;\n        int sampleSizeInBits = 8;\n        int channels = 2;\n        boolean signed = true;\n        boolean bigEndian = true;\n        AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,\n                channels, signed, bigEndian);\n        return format;\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/Message.java",
    "content": "package com.messages;\n\nimport java.io.Serializable;\nimport java.util.ArrayList;\nimport java.util.HashMap;\n\npublic class Message implements Serializable {\n\n    private String name;\n    private MessageType type;\n    private String msg;\n    private int count;\n    private ArrayList<User> list;\n    private ArrayList<User> users;\n\n    private Status status;\n\n    public byte[] getVoiceMsg() {\n        return voiceMsg;\n    }\n\n    private byte[] voiceMsg;\n\n    public String getPicture() {\n        return picture;\n    }\n\n    private String picture;\n\n    public Message() {\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public String getMsg() {\n\n        return msg;\n    }\n\n    public void setMsg(String msg) {\n        this.msg = msg;\n    }\n\n    public MessageType getType() {\n        return type;\n    }\n\n    public void setType(MessageType type) {\n        this.type = type;\n    }\n\n    public ArrayList<User> getUserlist() {\n        return list;\n    }\n\n    public void setUserlist(HashMap<String, User> userList) {\n        this.list = new ArrayList<>(userList.values());\n    }\n\n    public void setOnlineCount(int count){\n        this.count = count;\n    }\n\n    public int getOnlineCount(){\n        return this.count;\n    }\n\n    public void setPicture(String picture) {\n        this.picture = picture;\n    }\n\n\n    public ArrayList<User> getUsers() {\n        return users;\n    }\n\n    public void setUsers(ArrayList<User> users) {\n        this.users = users;\n    }\n\n    public void setStatus(Status status) {\n        this.status = status;\n    }\n\n    public Status getStatus() {\n        return status;\n    }\n\n    public void setVoiceMsg(byte[] voiceMsg) {\n        this.voiceMsg = voiceMsg;\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/MessageType.java",
    "content": "package com.messages;\n\n/**\n * @author Dominic\n * @since 03-Sep-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic enum MessageType {\n    DISCONNECTED, CONNECTED, STATUS, USER, SERVER, NOTIFICATION, VOICE\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/Status.java",
    "content": "package com.messages;\n\n/**\n * @author Dominic\n * @since 03-Sep-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic enum Status {\n    ONLINE, AWAY, BUSY\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/User.java",
    "content": "package com.messages;\n\nimport java.io.Serializable;\n\n/**\n * Created by Dominic on 01-May-16.\n */\npublic class User implements Serializable {\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    String name;\n\n    public String getPicture() {\n        return picture;\n    }\n\n    public void setPicture(String picture) {\n        this.picture = picture;\n    }\n\n    public Status getStatus() {\n        return status;\n    }\n\n    public void setStatus(Status status) {\n        this.status = status;\n    }\n\n    String picture;\n    Status status;\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/bubble/Bubble.java",
    "content": "package com.messages.bubble;\n\nimport javafx.scene.shape.HLineTo;\nimport javafx.scene.shape.LineTo;\nimport javafx.scene.shape.MoveTo;\nimport javafx.scene.shape.Path;\nimport javafx.scene.shape.VLineTo;\n\npublic class Bubble extends Path{\n\t\n\t/*Copyright {2015} {Terah Laweh}\n\n\t   Licensed under the Apache License, Version 2.0 (the \"License\");\n\t   you may not use this file except in compliance with the License.\n\t   You may obtain a copy of the License at\n\n\t       http://www.apache.org/licenses/LICENSE-2.0\n\n\t   Unless required by applicable law or agreed to in writing, software\n\t   distributed under the License is distributed on an \"AS IS\" BASIS,\n\t   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\t   See the License for the specific language governing permissions and\n\t   limitations under the License.\n\t*/\n\n\tpublic Bubble(BubbleSpec bubbleSpec) {\n\t\tsuper();\n\t\tswitch (bubbleSpec) {\n\t\tcase FACE_BOTTOM:\n\t\t\tbreak;\n\t\tcase FACE_LEFT_BOTTOM:\n\t\t\tdrawRectBubbleLeftBaselineIndicator();\n\t\t\tbreak;\n\t\tcase FACE_LEFT_CENTER:\n\t\t\tdrawRectBubbleLeftCenterIndicator();\n\t\t\tbreak;\n\t\tcase FACE_RIGHT_BOTTOM:\n\t\t\tdrawRectBubbleRightBaselineIndicator();\n\t\t\tbreak;\n\t\tcase FACE_RIGHT_CENTER:\n\t\t\tdrawRectBubbleRightCenterIndicator();\n\t\t\tbreak;\n\t\tcase FACE_TOP:\n\t\t\tdrawRectBubbleToplineIndicator();\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t}\n\n\tprivate void drawRectBubbleToplineIndicator() {\n\t\tgetElements().addAll(new MoveTo(1.0f, 1.2f),\n\t\t\t\tnew HLineTo(2.5f),\n\t\t\t\tnew LineTo(2.7f, 1.0f),\n\t\t\t\tnew LineTo(2.9f, 1.2f),\n\t\t\t\tnew HLineTo(4.4f),\n\t\t\t\tnew VLineTo(4f),\n\t\t\t\tnew HLineTo(1.0f),\n\t\t\t\tnew VLineTo(1.2f)\n\t\t\t\t);\n\t}\n\n\tprivate void drawRectBubbleRightBaselineIndicator() {\n\t\tgetElements().addAll(new MoveTo(3.0f, 1.0f),\n\t\t\t\tnew HLineTo(0f),\n\t\t\t\tnew VLineTo(4f),\n\t\t\t\tnew HLineTo(3.0f),\n\t\t\t\tnew LineTo(2.8f, 3.8f),\n\t\t\t\tnew VLineTo(1f)\n\t\t\t\t);\n\t}\n\n\tprivate void drawRectBubbleLeftBaselineIndicator() {\n\t\tgetElements().addAll(new MoveTo(1.2f, 1.0f),\n\t\t\t\tnew HLineTo(3f),\n\t\t\t\tnew VLineTo(4f),\n\t\t\t\tnew HLineTo(1.0f),\n\t\t\t\tnew LineTo(1.2f, 3.8f),\n\t\t\t\tnew VLineTo(1f)\n\t\t\t\t);\n\t}\n\n\tprivate void drawRectBubbleRightCenterIndicator() {\n\t\tgetElements().addAll(new MoveTo(3.0f, 2.5f),\n\t\t\t\tnew LineTo(2.8f, 2.4f),\n\t\t\t\tnew VLineTo(1f),\n\t\t\t\tnew HLineTo(0f),\n\t\t\t\tnew VLineTo(4f),\n\t\t\t\tnew HLineTo(2.8f),\n\t\t\t\tnew VLineTo(2.7f),\n\t\t\t\tnew LineTo(3.0f, 2.5f)\n\t\t\t\t);\n\t}\n\t\n\tprotected double drawRectBubbleIndicatorRule = 0.2;\n\n\tprivate void drawRectBubbleLeftCenterIndicator() {\n\t\tgetElements().addAll(new MoveTo(1.0f, 2.5f),\n\t\t\t\tnew LineTo(1.2f, 2.4f),\n\t\t\t\tnew VLineTo(1f),\n\t\t\t\tnew HLineTo(2.9f),\n\t\t\t\tnew VLineTo(4f),\n\t\t\t\tnew HLineTo(1.2f),\n\t\t\t\tnew VLineTo(2.7f),\n\t\t\t\tnew LineTo(1.0f, 2.5f)\n\t\t\t\t);\n\t}\n\n\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/bubble/BubbleSpec.java",
    "content": "package com.messages.bubble;\n\npublic enum BubbleSpec {\n\t\n\t/*Copyright {2015} {Terah Laweh}\n\n\t   Licensed under the Apache License, Version 2.0 (the \"License\");\n\t   you may not use this file except in compliance with the License.\n\t   You may obtain a copy of the License at\n\n\t       http://www.apache.org/licenses/LICENSE-2.0\n\n\t   Unless required by applicable law or agreed to in writing, software\n\t   distributed under the License is distributed on an \"AS IS\" BASIS,\n\t   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\t   See the License for the specific language governing permissions and\n\t   limitations under the License.\n\t*/\n\n\tFACE_TOP, FACE_BOTTOM, FACE_LEFT_BOTTOM, FACE_LEFT_CENTER, FACE_RIGHT_BOTTOM, FACE_RIGHT_CENTER;\n\n}\n"
  },
  {
    "path": "client/src/main/java/com/messages/bubble/BubbledLabel.java",
    "content": "package com.messages.bubble;\n\nimport javafx.beans.InvalidationListener;\nimport javafx.beans.Observable;\nimport javafx.beans.value.ChangeListener;\nimport javafx.beans.value.ObservableValue;\nimport javafx.geometry.Insets;\nimport javafx.scene.Node;\nimport javafx.scene.control.Label;\nimport javafx.scene.effect.DropShadow;\nimport javafx.scene.paint.Color;\nimport javafx.scene.shape.Shape;\n\npublic class BubbledLabel extends Label {\n\t\n\t/*Copyright {2015} {Terah Laweh}\n\n\t   Licensed under the Apache License, Version 2.0 (the \"License\");\n\t   you may not use this file except in compliance with the License.\n\t   You may obtain a copy of the License at\n\n\t       http://www.apache.org/licenses/LICENSE-2.0\n\n\t   Unless required by applicable law or agreed to in writing, software\n\t   distributed under the License is distributed on an \"AS IS\" BASIS,\n\t   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\t   See the License for the specific language governing permissions and\n\t   limitations under the License.\n\t*/\n\n\tprivate BubbleSpec bs = BubbleSpec.FACE_LEFT_CENTER;\n\tprivate double pading = 5.0;\n\tprivate boolean systemCall = false;\n\n\tpublic BubbledLabel() {\n\t\tsuper();\n\t\tinit();\n\t}\n\n\tpublic BubbledLabel(String arg0, Node arg1) {\n\t\tsuper(arg0, arg1);\n\t\tinit();\n\t}\n\n\tpublic BubbledLabel(String arg0) {\n\t\tsuper(arg0);\n\t\tinit();\n\t}\n\n\tpublic BubbledLabel(BubbleSpec bubbleSpec) {\n\t\tsuper();\n\t\tthis.bs = bubbleSpec;\n\t\tinit();\n\t}\n\n\tpublic BubbledLabel(String arg0, Node arg1,BubbleSpec bubbleSpec) {\n\t\tsuper(arg0, arg1);\n\t\tthis.bs = bubbleSpec;\n\t\tinit();\n\t}\n\n\tpublic BubbledLabel(String arg0,BubbleSpec bubbleSpec) {\n\t\tsuper(arg0);\n\t\tthis.bs = bubbleSpec;\n\t\tinit();\n\t}\n\n\tprivate void init(){\n\t\tDropShadow ds = new DropShadow();\n\t\tds.setOffsetX(1.3);\n\t\tds.setOffsetY(1.3);\n\t\tds.setColor(Color.DARKGRAY);\n\t\tsetPrefSize(Label.USE_COMPUTED_SIZE, Label.USE_COMPUTED_SIZE);\n\t\tshapeProperty().addListener(new ChangeListener<Shape>() {\n\t\t\t@Override\n\t\t\tpublic void changed(ObservableValue<? extends Shape> arg0,\n\t\t\t\t\tShape arg1, Shape arg2) {\n\t\t\t\tif(systemCall){\t\t\t\t\t\n\t\t\t\t\tsystemCall = false;\n\t\t\t\t}else{\n\t\t\t\t\tshapeIt();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\theightProperty().addListener(new InvalidationListener() {\n\n\t\t\t@Override\n\t\t\tpublic void invalidated(Observable arg0) {\n\t\t\t\tif(!systemCall)\n\t\t\t\t\tsetPrefHeight(Label.USE_COMPUTED_SIZE);\n\t\t\t}\n\t\t});\n\n\t\twidthProperty().addListener(new InvalidationListener() {\n\n\t\t\t@Override\n\t\t\tpublic void invalidated(Observable observable) {\n\t\t\t\tif(!systemCall)\n\t\t\t\t\tsetPrefHeight(Label.USE_COMPUTED_SIZE);\n\t\t\t}\n\t\t});\n\n\t\tshapeIt();\t\t\n\t}\n\n\t@Override\n\tprotected void updateBounds() {\n\t\tsuper.updateBounds();\t\t\n\t\t//top right  bottom  left\n\t\tswitch (bs) {\n\t\tcase FACE_LEFT_BOTTOM:\n\t\t\tsetPadding(new Insets(pading,pading,\n\t\t\t\t\t(this.getBoundsInLocal().getWidth()*((Bubble)getShape()).drawRectBubbleIndicatorRule)/2\n\t\t\t\t\t+pading,\n\t\t\t\t\tpading));\n\t\t\tbreak;\n\t\tcase FACE_LEFT_CENTER:\n\t\t\tsetPadding(new Insets(pading,pading,pading,\n\t\t\t\t\t(this.getBoundsInLocal().getWidth()*((Bubble)getShape()).drawRectBubbleIndicatorRule)/2\n\t\t\t\t\t+pading\n\t\t\t\t\t));\n\t\t\tbreak;\n\t\tcase FACE_RIGHT_BOTTOM:\n\t\t\tsetPadding(new Insets(pading,\n\t\t\t\t\t(this.getBoundsInLocal().getWidth()*((Bubble)getShape()).drawRectBubbleIndicatorRule)/2\n\t\t\t\t\t+pading\n\t\t\t\t\t,pading,pading));\n\t\t\tbreak;\n\t\tcase FACE_RIGHT_CENTER:\n\t\t\tsetPadding(new Insets(pading,\n\t\t\t\t\t(this.getBoundsInLocal().getWidth()*((Bubble)getShape()).drawRectBubbleIndicatorRule)/2\n\t\t\t\t\t+pading\n\t\t\t\t\t,pading,pading));\n\t\t\tbreak;\n\t\tcase FACE_TOP:\n\t\t\tsetPadding(new Insets(\n\t\t\t\t\t(this.getBoundsInLocal().getWidth()*((Bubble)getShape()).drawRectBubbleIndicatorRule)/2\n\t\t\t\t\t+pading,\n\t\t\t\t\tpading,pading,pading));\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tpublic final double getPading() {\n\t\treturn pading;\n\t}\n\n\tpublic void setPading(double pading) {\n\t\tif(pading > 25.0)\n\t\t\treturn;\n\t\tthis.pading = pading;\n\t}\n\n\tpublic BubbleSpec getBubbleSpec() {\n\t\treturn bs;\n\t}\n\n\tpublic void setBubbleSpec(BubbleSpec bubbleSpec) {\n\t\tthis.bs = bubbleSpec;\n\t\tshapeIt();\n\t}\n\n\tprivate final void shapeIt(){\n\t\tsystemCall = true;\n\t\tsetShape(new Bubble(bs));\n\t\tSystem.gc();\n\t}\n}\n"
  },
  {
    "path": "client/src/main/java/com/traynotifications/animations/AnimationProvider.java",
    "content": "package com.traynotifications.animations;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.function.Predicate;\nimport java.util.stream.Collectors;\n\n/**\n * A provider class that houses all animation objects that implement TrayAnimation\n * This makes it easier to lookup any existing animations and retrieve them\n * This means the user can easily switch animations, and in the background all possible animation types\n * Are stores in here, so when a user selects an animation type, this class will return the TrayAnimation that satisfies that request\n * It's much like a mini database\n */\npublic class AnimationProvider {\n\n    private List<TrayAnimation> animationsList;\n\n    public AnimationProvider(TrayAnimation... animations) {\n        animationsList = new ArrayList<>();\n        Collections.addAll(animationsList, animations);\n    }\n\n    public void addAll(TrayAnimation... animations) {\n        Collections.addAll(animationsList, animations);\n    }\n\n    public TrayAnimation get(int index) {\n        return animationsList.get(index);\n    }\n\n    public TrayAnimation findFirstWhere(Predicate<? super TrayAnimation> predicate) {\n        return animationsList.stream().filter(predicate).findFirst().orElse(null);\n    }\n\n    public List<TrayAnimation> where(Predicate<? super TrayAnimation> predicate) {\n        return animationsList.stream().filter(predicate).collect(Collectors.toList());\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/traynotifications/animations/AnimationType.java",
    "content": "package com.traynotifications.animations;\n\npublic enum AnimationType {\n    FADE,\n    SLIDE,\n    POPUP\n}\n"
  },
  {
    "path": "client/src/main/java/com/traynotifications/animations/FadeAnimation.java",
    "content": "package com.traynotifications.animations;\n\nimport javafx.animation.KeyFrame;\nimport javafx.animation.KeyValue;\nimport javafx.animation.SequentialTransition;\nimport javafx.animation.Timeline;\nimport javafx.util.Duration;\nimport com.traynotifications.models.CustomStage;\n\npublic class FadeAnimation implements TrayAnimation {\n\n    private final Timeline showAnimation, dismissAnimation;\n    private final SequentialTransition sq;\n    private final CustomStage stage;\n    private boolean trayIsShowing;\n\n    /**\n     * Initializes a fade type animation on a stage\n     * @param customStage The stage associate the fade animation with\n     */\n    public FadeAnimation(CustomStage customStage) {\n\n        this.stage = customStage;\n\n        //It wouldn't allow me to play embedded animations so I had to create two separate\n        //Instances so I could play sequentially and individually.\n\n        showAnimation = setupShowAnimation();\n        dismissAnimation = setupDismissAnimation();\n\n        sq = new SequentialTransition(setupShowAnimation(), setupDismissAnimation());\n    }\n\n    /**\n     *\n     * @return a constructed instance of a show fade animation\n     */\n    private Timeline setupShowAnimation() {\n\n        Timeline tl = new Timeline();\n\n        //Sets opacity to 0.0 instantly which is pretty much invisible\n        KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.0);\n        KeyFrame frame1 = new KeyFrame(Duration.ZERO, kvOpacity);\n\n        //Sets opacity to 1.0 (fully visible) over the time of 3000 milliseconds.\n        KeyValue kvOpacity2 = new KeyValue(stage.opacityProperty(), 1.0);\n        KeyFrame frame2 = new KeyFrame(Duration.millis(3000), kvOpacity2);\n\n        tl.getKeyFrames().addAll(frame1, frame2);\n\n        tl.setOnFinished(e -> trayIsShowing = true);\n\n        return tl;\n    }\n\n    /**\n     *\n     * @return a constructed instance of a dismiss fade animation\n     */\n    private Timeline setupDismissAnimation() {\n\n        Timeline tl = new Timeline();\n\n        //At this stage the opacity is already at 1.0\n\n        //Lowers the opacity to 0.0 within 2000 milliseconds\n        KeyValue kv1 = new KeyValue(stage.opacityProperty(), 0.0);\n        KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);\n\n        tl.getKeyFrames().addAll(kf1);\n\n        //Action to be performed when the animation has finished\n        tl.setOnFinished(e -> {\n            trayIsShowing = false;\n            stage.close();\n            stage.setLocation(stage.getBottomRight());\n        });\n\n        return tl;\n    }\n\n    /**\n     * The type of animation this class plays\n     *\n     * @return The type of animation this class plays\n     */\n    @Override\n    public AnimationType getAnimationType() {\n        return AnimationType.FADE;\n    }\n\n    /**\n     * Plays both the show and dismiss animation using a sequential transition object\n     *\n     * @param dismissDelay How long to delay the start of the dismiss animation\n     */\n    @Override\n    public void playSequential(Duration dismissDelay) {\n        sq.getChildren().get(1).setDelay(dismissDelay);\n        sq.play();\n    }\n\n    /**\n     * Plays the implemented show animation\n     */\n    @Override\n    public void playShowAnimation() {\n        showAnimation.play();\n    }\n\n    /**\n     * Plays the implemented dismiss animation\n     */\n    @Override\n    public void playDismissAnimation() {\n        dismissAnimation.play();\n    }\n\n    /**\n     * Signifies if the tray is current showing\n     *\n     * @return boolean resultant\n     */\n    @Override\n    public boolean isShowing() {\n        return trayIsShowing;\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/traynotifications/animations/PopupAnimation.java",
    "content": "package com.traynotifications.animations;\n\nimport javafx.animation.*;\nimport com.traynotifications.models.CustomStage;\nimport javafx.util.Duration;\n\npublic class PopupAnimation implements TrayAnimation {\n\n    private final Timeline showAnimation, dismissAnimation;\n    private final SequentialTransition sq;\n    private final CustomStage stage;\n    private boolean trayIsShowing;\n\n    public PopupAnimation(CustomStage s) {\n\n        this.stage = s;\n\n        showAnimation = setupShowAnimation();\n        dismissAnimation = setupDismissAnimation();\n\n        sq = new SequentialTransition(setupShowAnimation(), setupDismissAnimation());\n    }\n\n    private Timeline setupDismissAnimation() {\n\n        Timeline tl = new Timeline();\n\n        KeyValue kv1 = new KeyValue(stage.yLocationProperty(), stage.getY() + stage.getWidth());\n        KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);\n\n        KeyValue kv2 = new KeyValue(stage.opacityProperty(), 0.0);\n        KeyFrame kf2 = new KeyFrame(Duration.millis(2000), kv2);\n\n        tl.getKeyFrames().addAll(kf1, kf2);\n\n        tl.setOnFinished(e -> {\n            trayIsShowing = false;\n            stage.close();\n            stage.setLocation(stage.getBottomRight());\n        });\n\n        return tl;\n    }\n\n    private Timeline setupShowAnimation() {\n\n        Timeline tl = new Timeline();\n\n        KeyValue kv1 = new KeyValue(stage.yLocationProperty(), stage.getBottomRight().getY() + stage.getWidth());\n        KeyFrame kf1 = new KeyFrame(Duration.ZERO, kv1);\n\n        KeyValue kv2 = new KeyValue(stage.yLocationProperty(), stage.getBottomRight().getY());\n        KeyFrame kf2 = new KeyFrame(Duration.millis(1000), kv2);\n\n        KeyValue kv3 = new KeyValue(stage.opacityProperty(), 0.0);\n        KeyFrame kf3 = new KeyFrame(Duration.ZERO, kv3);\n\n        KeyValue kv4 = new KeyValue(stage.opacityProperty(), 1.0);\n        KeyFrame kf4 = new KeyFrame(Duration.millis(2000), kv4);\n\n        tl.getKeyFrames().addAll(kf1, kf2, kf3, kf4);\n\n        tl.setOnFinished(e -> trayIsShowing = true);\n\n        return tl;\n    }\n\n    /**\n     * The type of animation this class plays\n     *\n     * @return The type of animation this class plays\n     */\n    @Override\n    public AnimationType getAnimationType() {\n        return AnimationType.POPUP;\n    }\n\n    /**\n     * Plays both the show and dismiss animation using a sequential transition object\n     *\n     * @param dismissDelay How long to delay the start of the dismiss animation\n     */\n    @Override\n    public void playSequential(Duration dismissDelay) {\n        sq.getChildren().get(1).setDelay(dismissDelay);\n        sq.play();\n    }\n\n    /**\n     * Plays the implemented show animation\n     */\n    @Override\n    public void playShowAnimation() {\n        showAnimation.play();\n    }\n\n    /**\n     * Plays the implemented dismiss animation\n     */\n    @Override\n    public void playDismissAnimation() {\n        dismissAnimation.play();\n    }\n\n    /**\n     * Signifies if the tray is current showing\n     *\n     * @return boolean resultant\n     */\n    @Override\n    public boolean isShowing() {\n        return trayIsShowing;\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/traynotifications/animations/SlideAnimation.java",
    "content": "package com.traynotifications.animations;\n\nimport javafx.animation.*;\nimport javafx.util.Duration;\nimport com.traynotifications.models.CustomStage;\n\npublic class SlideAnimation implements TrayAnimation {\n\n    private final Timeline showAnimation, dismissAnimation;\n    private final SequentialTransition sq;\n    private final CustomStage stage;\n    private boolean trayIsShowing;\n\n    public SlideAnimation(CustomStage customStage) {\n\n        this.stage = customStage;\n\n        showAnimation = setupShowAnimation();\n        dismissAnimation = setupDismissAnimation();\n\n        //It wouldn't allow me to play embedded animations so I had to create two separate\n        //Instances so I could play sequentially and individually.\n\n        sq = new SequentialTransition(setupShowAnimation(), setupDismissAnimation());\n    }\n\n    private Timeline setupShowAnimation() {\n\n        Timeline tl = new Timeline();\n\n        //Sets the x location of the tray off the screen\n        double offScreenX = stage.getOffScreenBounds().getX();\n        KeyValue kvX = new KeyValue(stage.xLocationProperty(), offScreenX);\n        KeyFrame frame1 = new KeyFrame(Duration.ZERO, kvX);\n\n        //Animates the Tray onto the screen and interpolates at a tangent for 300 millis\n        Interpolator interpolator = Interpolator.TANGENT(Duration.millis(300), 50);\n        KeyValue kvInter = new KeyValue(stage.xLocationProperty(), stage.getBottomRight().getX(), interpolator);\n        KeyFrame frame2 = new KeyFrame(Duration.millis(1300), kvInter);\n\n        //Sets opacity to 0 instantly\n        KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.0);\n        KeyFrame frame3 = new KeyFrame(Duration.ZERO, kvOpacity);\n\n        //Increases the opacity to fully visible whilst moving in the space of 1000 millis\n        KeyValue kvOpacity2 = new KeyValue(stage.opacityProperty(), 1.0);\n        KeyFrame frame4 = new KeyFrame(Duration.millis(1000), kvOpacity2);\n\n        tl.getKeyFrames().addAll(frame1, frame2, frame3, frame4);\n\n        tl.setOnFinished(e -> trayIsShowing = true);\n\n        return tl;\n    }\n\n    private Timeline setupDismissAnimation() {\n\n        Timeline tl = new Timeline();\n\n        double offScreenX = stage.getOffScreenBounds().getX();\n        Interpolator interpolator = Interpolator.TANGENT(Duration.millis(300), 50);\n        double trayPadding = 3;\n\n        //The destination X location for the stage. Which is off the users screen\n        //Since the tray has some padding, we want to hide that too\n        KeyValue kvX = new KeyValue(stage.xLocationProperty(), offScreenX + trayPadding, interpolator);\n        KeyFrame frame1 = new KeyFrame(Duration.millis(1400), kvX);\n\n        //Change the opacity level to 0.4 over the duration of 2000 millis\n        KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.4);\n        KeyFrame frame2 = new KeyFrame(Duration.millis(2000), kvOpacity);\n\n        tl.getKeyFrames().addAll(frame1, frame2);\n\n        tl.setOnFinished(e -> {\n            trayIsShowing = false;\n            stage.close();\n            stage.setLocation(stage.getBottomRight());\n        });\n\n        return tl;\n    }\n\n    /**\n     * The type of animation this class plays\n     *\n     * @return The type of animation this class plays\n     */\n    @Override\n    public AnimationType getAnimationType() {\n        return AnimationType.SLIDE;\n    }\n\n    /**\n     * Plays both the show and dismiss animation using a sequential transition object\n     *\n     * @param dismissDelay How long to delay the start of the dismiss animation\n     */\n    @Override\n    public void playSequential(Duration dismissDelay) {\n        sq.getChildren().get(1).setDelay(dismissDelay);\n        sq.play();\n    }\n\n    /**\n     * Plays the implemented show animation\n     */\n    @Override\n    public void playShowAnimation() {\n        showAnimation.play();\n    }\n\n    /**\n     * Plays the implemented dismiss animation\n     */\n    @Override\n    public void playDismissAnimation() {\n        dismissAnimation.play();\n    }\n\n    /**\n     * Signifies if the tray is current showing\n     *\n     * @return boolean resultant\n     */\n    @Override\n    public boolean isShowing() {\n        return trayIsShowing;\n    }\n}"
  },
  {
    "path": "client/src/main/java/com/traynotifications/animations/TrayAnimation.java",
    "content": "package com.traynotifications.animations;\n\nimport javafx.util.Duration;\n\n//All tray animations must implement TrayAnimation\npublic interface TrayAnimation {\n\n    /**\n     * The type of animation this class plays\n     * @return The type of animation this class plays\n     */\n    AnimationType getAnimationType();\n\n    /**\n     * Plays both the show and dismiss animation using a sequential transition object\n     * @param dismissDelay How long to delay the start of the dismiss animation\n     */\n    void playSequential(Duration dismissDelay);\n\n    /**\n     * Plays the implemented show animation\n     */\n    void playShowAnimation();\n\n    /**\n     * Plays the implemented dismiss animation\n     */\n    void playDismissAnimation();\n\n    /**\n     * Signifies if the tray is current showing\n     * @return boolean resultant\n     */\n    boolean isShowing();\n}"
  },
  {
    "path": "client/src/main/java/com/traynotifications/models/CustomStage.java",
    "content": "package com.traynotifications.models;\n\nimport javafx.beans.property.SimpleDoubleProperty;\nimport javafx.geometry.Rectangle2D;\nimport javafx.scene.layout.AnchorPane;\nimport javafx.stage.Screen;\nimport javafx.stage.Stage;\nimport javafx.stage.StageStyle;\n\npublic class CustomStage extends Stage {\n\n    private final Location bottomRight;\n\n    public CustomStage(AnchorPane ap, StageStyle style) {\n        initStyle(style);\n\n        setSize(ap.getPrefWidth(), ap.getPrefHeight());\n\n        Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();\n        double x = screenBounds.getMinX() + screenBounds.getWidth() - ap.getPrefWidth() - 2;\n        double y = screenBounds.getMinY() + screenBounds.getHeight() - ap.getPrefHeight() - 2;\n\n        bottomRight = new Location(x,y);\n    }\n\n    public Location getBottomRight() {\n        return bottomRight;\n    }\n\n    public void setSize(double width, double height) {\n        setWidth(width);\n        setHeight(height);\n    }\n\n    public Location getOffScreenBounds() {\n        Location loc = getBottomRight();\n\n        return new Location(loc.getX() + this.getWidth(), loc.getY());\n    }\n\n    public void setLocation(Location loc) {\n        setX(loc.getX());\n        setY(loc.getY());\n    }\n\n    private SimpleDoubleProperty xLocationProperty = new SimpleDoubleProperty() {\n        @Override\n        public void set(double newValue) {\n            setX(newValue);\n        }\n\n        @Override\n        public double get() {\n            return getX();\n        }\n    };\n\n    public SimpleDoubleProperty xLocationProperty() {\n        return xLocationProperty;\n    }\n\n    private SimpleDoubleProperty yLocationProperty = new SimpleDoubleProperty() {\n        @Override\n        public void set(double newValue) {\n            setY(newValue);\n        }\n\n        @Override\n        public double get() {\n            return getY();\n        }\n    };\n\n    public SimpleDoubleProperty yLocationProperty() {\n        return yLocationProperty;\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/traynotifications/models/Location.java",
    "content": "package com.traynotifications.models;\n\npublic class Location {\n\n    private double x, y;\n\n    public Location(double xLoc, double yLoc) {\n        this.x = xLoc;\n        this.y = yLoc;\n    }\n\n    public double getX() {\n        return x;\n    }\n\n    public double getY() {\n        return y;\n    }\n}\n"
  },
  {
    "path": "client/src/main/java/com/traynotifications/notification/NotificationType.java",
    "content": "package com.traynotifications.notification;\n\npublic enum NotificationType {\n    INFORMATION,\n    NOTICE,\n    SUCCESS,\n    WARNING,\n    ERROR,\n    CUSTOM\n}\n"
  },
  {
    "path": "client/src/main/java/com/traynotifications/notification/TrayNotification.java",
    "content": "package com.traynotifications.notification;\n\nimport javafx.event.ActionEvent;\nimport javafx.event.EventHandler;\nimport javafx.fxml.FXML;\nimport javafx.fxml.FXMLLoader;\nimport javafx.scene.Scene;\nimport javafx.scene.control.Label;\nimport javafx.scene.image.Image;\nimport javafx.scene.image.ImageView;\nimport javafx.scene.layout.AnchorPane;\nimport javafx.scene.paint.Paint;\nimport javafx.scene.shape.Rectangle;\nimport javafx.stage.StageStyle;\nimport javafx.util.Duration;\nimport com.traynotifications.animations.*;\nimport com.traynotifications.models.CustomStage;\n\nimport java.io.IOException;\nimport java.net.URL;\n\npublic final class TrayNotification {\n\n    @FXML\n    private Label lblTitle, lblMessage, lblClose;\n    @FXML\n    private ImageView imageIcon;\n    @FXML\n    private Rectangle rectangleColor;\n    @FXML\n    private AnchorPane rootNode;\n\n    private CustomStage stage;\n    private NotificationType notificationType;\n    private AnimationType animationType;\n    private EventHandler<ActionEvent> onDismissedCallBack, onShownCallback;\n    private TrayAnimation animator;\n    private AnimationProvider animationProvider;\n\n    /**\n     * Initializes an instance of the tray notification object\n     * @param title The title text to assign to the tray\n     * @param body The body text to assign to the tray\n     * @param img The image to show on the tray\n     * @param rectangleFill The fill for the rectangle\n     */\n    public TrayNotification(String title, String body, Image img, Paint rectangleFill) {\n        initTrayNotification(title, body, NotificationType.CUSTOM);\n\n        setImage(img);\n        setRectangleFill(rectangleFill);\n    }\n\n    /**\n     * Initializes an instance of the tray notification object\n     * @param title The title text to assign to the tray\n     * @param body The body text to assign to the tray\n     * @param notificationType The notification type to assign to the tray\n     */\n    public TrayNotification(String title, String body, NotificationType notificationType ) {\n        initTrayNotification(title, body, notificationType);\n    }\n\n    /**\n     * Initializes an empty instance of the tray notification\n     */\n    public TrayNotification() {\n        initTrayNotification(\"\", \"\", NotificationType.CUSTOM);\n    }\n\n    private void initTrayNotification(String title, String message, NotificationType type) {\n\n        try {\n            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(\"/views/TrayNotification.fxml\"));\n\n            fxmlLoader.setController(this);\n            fxmlLoader.load();\n\n            initStage();\n            initAnimations();\n\n            setTray(title, message, type);\n\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n    }\n\n    private void initAnimations() {\n\n        animationProvider =\n            new AnimationProvider(new FadeAnimation(stage), new SlideAnimation(stage), new PopupAnimation(stage));\n\n        //Default animation type\n        setAnimationType(AnimationType.SLIDE);\n    }\n\n    private void initStage() {\n\n        stage = new CustomStage(rootNode, StageStyle.UNDECORATED);\n        stage.setScene(new Scene(rootNode));\n        stage.setAlwaysOnTop(true);\n        stage.setLocation(stage.getBottomRight());\n\n        lblClose.setOnMouseClicked(e -> dismiss());\n    }\n\n    public void setNotificationType(NotificationType nType) {\n\n        notificationType = nType;\n\n        URL imageLocation = null;\n        String paintHex = null;\n\n        switch (nType) {\n\n            case INFORMATION:\n                imageLocation = getClass().getResource(\"/tray/resources/info.png\");\n                paintHex = \"#2C54AB\";\n                break;\n\n            case NOTICE:\n                imageLocation = getClass().getResource(\"/tray/resources/notice.png\");\n                paintHex = \"#8D9695\";\n                break;\n\n            case SUCCESS:\n                imageLocation = getClass().getResource(\"/tray/resources/success.png\");\n                paintHex = \"#009961\";\n                break;\n\n            case WARNING:\n                imageLocation = getClass().getResource(\"/tray/resources/warning.png\");\n                paintHex = \"#E23E0A\";\n                break;\n\n            case ERROR:\n                imageLocation = getClass().getResource(\"/tray/resources/error.png\");\n                paintHex = \"#CC0033\";\n                break;\n\n            case CUSTOM:\n                return;\n        }\n\n        setRectangleFill(Paint.valueOf(paintHex));\n        setImage(new Image(imageLocation.toString()));\n        setTrayIcon(imageIcon.getImage());\n    }\n\n    public NotificationType getNotificationType() {\n        return notificationType;\n    }\n\n    public void setTray(String title, String message, NotificationType type) {\n        setTitle(title);\n        setMessage(message);\n        setNotificationType(type);\n    }\n\n    public void setTray(String title, String message, Image img, Paint rectangleFill, AnimationType animType) {\n        setTitle(title);\n        setMessage(message);\n        setImage(img);\n        setRectangleFill(rectangleFill);\n        setAnimationType(animType);\n    }\n\n    public boolean isTrayShowing() {\n        return animator.isShowing();\n    }\n\n    /**\n     * Shows and dismisses the tray notification\n     * @param dismissDelay How long to delay the start of the dismiss animation\n     */\n    public void showAndDismiss(Duration dismissDelay) {\n\n        if (isTrayShowing()) {\n            dismiss();\n        } else {\n            stage.show();\n\n            onShown();\n            animator.playSequential(dismissDelay);\n        }\n\n        onDismissed();\n    }\n\n    /**\n     * Displays the notification tray\n     */\n    public void showAndWait() {\n\n        if (! isTrayShowing()) {\n            stage.show();\n\n            animator.playShowAnimation();\n\n            onShown();\n        }\n    }\n\n    /**\n     * Dismisses the notifcation tray\n     */\n    public void dismiss() {\n\n        if (isTrayShowing()) {\n            animator.playDismissAnimation();\n            onDismissed();\n        }\n    }\n\n    private void onShown() {\n        if (onShownCallback != null)\n            onShownCallback.handle(new ActionEvent());\n    }\n\n    private void onDismissed() {\n        if (onDismissedCallBack != null)\n            onDismissedCallBack.handle(new ActionEvent());\n    }\n\n    /**\n     * Sets an action event for when the tray has been dismissed\n     * @param event The event to occur when the tray has been dismissed\n     */\n    public void setOnDismiss(EventHandler<ActionEvent> event) {\n        onDismissedCallBack  = event;\n    }\n\n    /**\n     * Sets an action event for when the tray has been shown\n     * @param event The event to occur after the tray has been shown\n     */\n    public void setOnShown(EventHandler<ActionEvent> event) {\n        onShownCallback  = event;\n    }\n\n    /**\n     * Sets a new task bar image for the tray\n     * @param img The image to assign\n     */\n    public void setTrayIcon(Image img) {\n        stage.getIcons().clear();\n        stage.getIcons().add(img);\n    }\n\n    public Image getTrayIcon() {\n        return stage.getIcons().get(0);\n    }\n\n    /**\n     * Sets a title to the tray\n     * @param txt The text to assign to the tray icon\n     */\n    public void setTitle(String txt) {\n        lblTitle.setText(txt);\n    }\n\n    public String getTitle() {\n        return lblTitle.getText();\n    }\n\n    /**\n     * Sets the message for the tray notification\n     * @param txt The text to assign to the body of the tray notification\n     */\n    public void setMessage(String txt) {\n        lblMessage.setText(txt);\n    }\n\n    public String getMessage() {\n        return lblMessage.getText();\n    }\n\n    public void setImage (Image img) {\n        imageIcon.setImage(img);\n\n        setTrayIcon(img);\n    }\n\n    public Image getImage() {\n        return imageIcon.getImage();\n    }\n\n    public void setRectangleFill(Paint value) {\n        rectangleColor.setFill(value);\n    }\n\n    public Paint getRectangleFill() {\n        return rectangleColor.getFill();\n    }\n\n    public void setAnimationType(AnimationType type) {\n        animator = animationProvider.findFirstWhere(a -> a.getAnimationType() == type);\n\n        animationType = type;\n    }\n\n    public AnimationType getAnimationType() {\n        return animationType;\n    }\n}"
  },
  {
    "path": "client/src/main/resources/styles/ButtonStyle.css",
    "content": ".button {\n    -fx-opacity: 1.0;\n}\n\n.button:hover {\n    -fx-opacity: 0.6;\n}\n\n\n"
  },
  {
    "path": "client/src/main/resources/styles/ChatViewStyle.css",
    "content": ".vbox {\n    -fx-border-color: #2e8b57;\n    -fx-border-width: 2px;\n    -fx-padding: 10;\n    -fx-spacing: 8;\n}\n\n\n"
  },
  {
    "path": "client/src/main/resources/styles/ComboBox.css",
    "content": ".comboTextField {\n    -fx-background-color: -fx-text-box-border, -fx-control-inner-background;\n    -fx-background-insets: 0, 1 0 1 1;\n    -fx-padding: 1 3 1 3;\n    -fx-background-radius: 0;\n    -fx-cursor: hand;\n}\n\n.comboTextField:focused {\n    -fx-background-color: -fx-text-box-border, -fx-control-inner-background;\n    -fx-background-insets: 0, 1 0 1 1;\n\n}\n\n.comboButton {\n    -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color;\n    -fx-background-insets: 0, 1, 2;\n    -fx-background-radius: 0 5 5 0, 0 4 4 0, 0 3 3 0;\n}\n\n.comboButton:focused {\n    -fx-color: -fx-focused-base;\n    -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color;\n    -fx-background-insets: 0, 1, 2;\n    -fx-background-radius: 0 5 5 0, 0 4 4 0, 0 3 3 0;\n}\n\n\n.comboFocus{\n    -fx-border-color:-fx-focus-color;\n    -fx-border-insets: -1;\n    -fx-border-radius: 0 5 5 0\n}\n.comboFocusOut{\n    -fx-border-color:transparent;\n    -fx-border-insets: 0;\n    -fx-border-radius: 0 5 5 0\n}\n"
  },
  {
    "path": "client/src/main/resources/styles/ListViewStyle.css",
    "content": ".list-cell {\n    -fx-cell-size: 50 ;\n    -fx-animated: true;\n    -fx-padding: 1px;\n}\n\n.list-cell:hover{\n    -fx-background-color: #dbdbdb;\n}\n\n.list-view {\n    -fx-border-image-width: 0;\n}\n\n#statusList {\n    -fx-box-border: transparent;\n}\n\n#userList {\n    -fx-box-border: transparent;\n}\n\n#listHbox {\n    -fx-background-color: #d5d5d5;\n    -fx-padding: 0.2;\n    -fx-spacing: -2;\n}\n\n#onlineUsersHbox {\n    -fx-border-color: #d5d5d5;\n    -fx-border-width: 1px;\n    -fx-padding: 0.2;\n    -fx-spacing: -2;\n}\n\n\n"
  },
  {
    "path": "client/src/main/resources/styles/Login.css",
    "content": "#CloseBtn {\n    -fx-graphic: url(\"../images/cross.png\");\n    -fx-background-color:transparent;\n    -fx-opacity: 1;\n}\n\n#CloseBtn:hover {\n    -fx-opacity: 0.5;\n}\n#CloseBtn:pressed {\n    -fx-opacity: 0.2;\n}\n\n#MinimizedBtn {\n    -fx-graphic: url(\"../images/line.png\");\n    -fx-background-color: transparent;\n    -fx-opacity: 1;\n\n}\n\n#MinimizedBtn:hover {\n    -fx-opacity: 0.5;\n}\n\n#connectBtn{\n    -fx-color: #ffffff;\n    -fx-padding: 5px 20px;\n    -fx-background-color: linear-gradient(to bottom, #ffe49e 0%,#ffb700 3%,#ffad00 35%,#ff9000 97%,#e27f00 100%);\n    -fx-font-family: 'Open Sans', sans-serif;\n    -fx-font-size: 12px;\n    border-radius: 3px;\n    cursor: pointer;\n    -fx-opacity: 1;\n}\n#connectBtn:hover{\n    -fx-cursor: hand;\n    -fx-opacity: 0.5;\n}\n\n#connectBtn:pressed{\n    -fx-opacity: 1;\n    -fx-padding: 5px 20px;\n    -fx-spacing: 10px;\n    -fx-start-margin: 10px;\n    -fx-background-color: linear-gradient(to bottom, #ffe49e 0%,#ffb700 3%,#ffad00 35%,#ff9000 97%,#e27f00 100%);\n    -fx-font-family: 'Open Sans', sans-serif;\n    -fx-cursor: hand;\n}"
  },
  {
    "path": "client/src/main/resources/views/ChatView.fxml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<?import java.lang.*?>\n<?import javafx.collections.*?>\n<?import javafx.scene.*?>\n<?import javafx.scene.text.*?>\n<?import javafx.collections.FXCollections?>\n<?import javafx.geometry.*?>\n<?import javafx.scene.control.*?>\n<?import javafx.scene.Cursor?>\n<?import javafx.scene.image.*?>\n<?import javafx.scene.layout.*?>\n<?import javafx.scene.text.Font?>\n<?import java.lang.String?>\n\n<BorderPane fx:id=\"borderPane\" maxHeight=\"620.0\" maxWidth=\"1040.0\" prefHeight=\"620.0\" prefWidth=\"1040.0\" xmlns=\"http://javafx.com/javafx/8.0.40\" xmlns:fx=\"http://javafx.com/fxml/1\" fx:controller=\"com.client.chatwindow.ChatController\">\n   <center>\n      <VBox maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\">\n         <children>\n            <ScrollPane fitToHeight=\"true\" fitToWidth=\"true\" hbarPolicy=\"NEVER\" maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" pannable=\"true\" prefHeight=\"496.0\" vbarPolicy=\"ALWAYS\" vmin=\"1.0\" vvalue=\"1.0\" VBox.vgrow=\"ALWAYS\">\n               <content>\n                  <ListView fx:id=\"chatPane\" maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" prefHeight=\"200.0\" prefWidth=\"200.0\" />\n               </content>\n            </ScrollPane>\n            <HBox maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" minHeight=\"-Infinity\" minWidth=\"100.0\" VBox.vgrow=\"NEVER\">\n               <children>\n                  <TextArea fx:id=\"messageBox\" maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" minHeight=\"-Infinity\" minWidth=\"100.0\" nodeOrientation=\"LEFT_TO_RIGHT\" onKeyPressed=\"#sendMethod\" prefHeight=\"16.0\" prefWidth=\"698.0\" promptText=\"Enter Message...\" scaleShape=\"false\" HBox.hgrow=\"ALWAYS\">\n                     <font>\n                        <Font name=\"SansSerif Regular\" size=\"14.0\" />\n                     </font>\n                  </TextArea>\n                  <Button fx:id=\"buttonSend\" alignment=\"CENTER\" maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" minHeight=\"-Infinity\" minWidth=\"-Infinity\" mnemonicParsing=\"false\" onAction=\"#sendButtonAction\" prefHeight=\"43.0\" prefWidth=\"140.0\" scaleShape=\"false\" text=\"Send\" textAlignment=\"CENTER\" HBox.hgrow=\"NEVER\" />\n                  <Button fx:id=\"recordBtn\" maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" mnemonicParsing=\"false\" onMousePressed=\"#recordVoiceMessage\">\n                     <graphic>\n                        <ImageView fx:id=\"microphoneImageView\" fitHeight=\"24.0\" fitWidth=\"24.0\" pickOnBounds=\"true\" preserveRatio=\"true\">\n                           <image>\n                              <Image url=\"@../images/microphone.png\" />\n                           </image>\n                        </ImageView>\n                     </graphic></Button>\n               </children>\n            </HBox>\n         </children>\n      </VBox>\n   </center>\n   <left>\n      <VBox maxHeight=\"1.7976931348623157E308\" BorderPane.alignment=\"CENTER\">\n         <children>\n            <HBox fx:id=\"onlineUsersHbox\" minHeight=\"-Infinity\" minWidth=\"-Infinity\" prefHeight=\"50.0\" prefWidth=\"217.0\" stylesheets=\"@../styles/ListViewStyle.css\">\n               <children>\n                  <Label prefHeight=\"50.0\" prefWidth=\"124.0\" text=\"Online Users:\" textAlignment=\"CENTER\" textFill=\"#fc6747\">\n                     <font>\n                        <Font name=\"SansSerif Regular\" size=\"14.0\" />\n                     </font>\n                     <padding>\n                        <Insets left=\"10.0\" />\n                     </padding>\n                     <opaqueInsets>\n                        <Insets bottom=\"10.0\" />\n                     </opaqueInsets>\n                  </Label>\n                  <Label fx:id=\"onlineCountLabel\" prefHeight=\"48.0\" prefWidth=\"94.0\" text=\"0\" textFill=\"#fc6747\">\n                     <opaqueInsets>\n                        <Insets />\n                     </opaqueInsets>\n                     <font>\n                        <Font name=\"SansSerif Regular\" size=\"14.0\" />\n                     </font>\n                  </Label>\n               </children>\n            </HBox>\n            <ListView fx:id=\"userList\" focusTraversable=\"false\" maxHeight=\"1.7976931348623157E308\" prefHeight=\"495.0\" prefWidth=\"217.0\" style=\"-fx-border-image-width: 0;\" stylesheets=\"@../styles/ListViewStyle.css\">\n            </ListView>\n         </children>\n      </VBox>\n   </left>\n   <top>\n      <BorderPane maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" style=\"-fx-background-color: #031c30;\" BorderPane.alignment=\"CENTER\">\n         <center>\n            <ImageView fitHeight=\"79.0\" fitWidth=\"522.0\" pickOnBounds=\"true\" preserveRatio=\"true\" BorderPane.alignment=\"CENTER\">\n               <image>\n                  <Image url=\"@../images/fxchat.png\" />\n               </image>\n               <BorderPane.margin>\n                  <Insets right=\"100.0\" />\n               </BorderPane.margin>\n            </ImageView>\n         </center>\n         <right>\n            <HBox prefHeight=\"24.0\" prefWidth=\"30.0\" stylesheets=\"@../styles/ButtonStyle.css\" BorderPane.alignment=\"CENTER\">\n               <children>\n                  <ImageView fitHeight=\"23.0\" fitWidth=\"30.0\" pickOnBounds=\"true\" preserveRatio=\"true\" styleClass=\"button\">\n                     <image>\n                        <Image url=\"@../images/settings.png\" />\n                     </image>\n                     <HBox.margin>\n                        <Insets right=\"30.0\" top=\"30.0\" />\n                     </HBox.margin>\n                     <cursor>\n                        <Cursor fx:constant=\"HAND\" />\n                     </cursor>\n                  </ImageView>\n                  <ImageView fitHeight=\"22.0\" fitWidth=\"21.0\" onMousePressed=\"#closeApplication\" pickOnBounds=\"true\" preserveRatio=\"true\" styleClass=\"button\">\n                     <image>\n                        <Image url=\"@../images/close_normal.png\" />\n                     </image>\n                     <HBox.margin>\n                        <Insets right=\"30.0\" top=\"30.0\" />\n                     </HBox.margin>\n                     <cursor>\n                        <Cursor fx:constant=\"HAND\" />\n                     </cursor>\n                  </ImageView>\n               </children>\n            </HBox>\n         </right>\n         <left>\n            <HBox prefWidth=\"259.0\" BorderPane.alignment=\"CENTER\">\n               <children>\n                  <ImageView fx:id=\"userImageView\" fitHeight=\"69.0\" fitWidth=\"59.0\" pickOnBounds=\"true\" preserveRatio=\"true\">\n                     <image>\n                        <Image url=\"@../images/default.png\" />\n                     </image>\n                     <HBox.margin>\n                        <Insets left=\"10.0\" top=\"10.0\" />\n                     </HBox.margin>\n                  </ImageView>\n                  <VBox>\n                     <HBox.margin>\n                        <Insets left=\"10.0\" top=\"30.0\" />\n                     </HBox.margin>\n                     <children>\n                        <Label fx:id=\"usernameLabel\" text=\"Dominic Heal\" textFill=\"#fa6648\">\n                           <font>\n                              <Font name=\"HelveticaNeue Medium\" size=\"14.0\" />\n                           </font>\n                        </Label>\n                        <ComboBox fx:id=\"statusComboBox\" prefHeight=\"25.0\" prefWidth=\"101.0\" promptText=\"Online\" stylesheets=\"@../styles/ComboBox.css\">\n                           <items>\n                              <FXCollections fx:factory=\"observableArrayList\">\n                                 <String fx:value=\"Online\" />\n                                 <String fx:value=\"Away\" />\n                                 <String fx:value=\"Busy\" />\n                              </FXCollections>\n                           </items>\n                        </ComboBox>\n                     </children>\n                  </VBox>\n               </children></HBox>\n         </left>\n      </BorderPane>\n   </top>\n   <rotationAxis>\n      <Point3D />\n   </rotationAxis>\n</BorderPane>\n"
  },
  {
    "path": "client/src/main/resources/views/LoginView.fxml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<?import javafx.collections.FXCollections?>\n<?import javafx.geometry.Insets?>\n<?import javafx.scene.control.*?>\n<?import javafx.scene.Cursor?>\n<?import javafx.scene.image.*?>\n<?import javafx.scene.layout.*?>\n<?import javafx.scene.text.Font?>\n<?import java.lang.String?>\n<BorderPane fx:id=\"borderPane\" maxWidth=\"350.0\" minWidth=\"350.0\" prefHeight=\"420.0\" prefWidth=\"350.0\" xmlns=\"http://javafx.com/javafx/8.0.40\" xmlns:fx=\"http://javafx.com/fxml/1\" fx:controller=\"com.client.login.LoginController\">\n   <right>\n      <GridPane BorderPane.alignment=\"CENTER\">\n         <columnConstraints>\n            <ColumnConstraints halignment=\"RIGHT\" hgrow=\"SOMETIMES\" maxWidth=\"325.0\" minWidth=\"10.0\" prefWidth=\"103.0\" />\n            <ColumnConstraints halignment=\"CENTER\" hgrow=\"SOMETIMES\" maxWidth=\"218.0\" minWidth=\"10.0\" prefWidth=\"210.0\" />\n            <ColumnConstraints halignment=\"CENTER\" hgrow=\"SOMETIMES\" maxWidth=\"325.0\" minWidth=\"10.0\" prefWidth=\"103.0\" />\n         </columnConstraints>\n         <rowConstraints>\n            <RowConstraints maxHeight=\"149.0\" minHeight=\"10.0\" prefHeight=\"36.0\" vgrow=\"SOMETIMES\" />\n            <RowConstraints maxHeight=\"226.0\" minHeight=\"10.0\" prefHeight=\"133.0\" vgrow=\"SOMETIMES\" />\n            <RowConstraints maxHeight=\"149.0\" minHeight=\"10.0\" prefHeight=\"57.0\" vgrow=\"SOMETIMES\" />\n            <RowConstraints maxHeight=\"96.0\" minHeight=\"10.0\" prefHeight=\"42.0\" vgrow=\"SOMETIMES\" />\n            <RowConstraints maxHeight=\"126.0\" minHeight=\"12.0\" prefHeight=\"35.0\" />\n            <RowConstraints maxHeight=\"96.0\" minHeight=\"10.0\" prefHeight=\"29.0\" vgrow=\"SOMETIMES\" />\n            <RowConstraints maxHeight=\"127.0\" minHeight=\"0.0\" prefHeight=\"36.0\" valignment=\"CENTER\" />\n            <RowConstraints maxHeight=\"110.0\" minHeight=\"10.0\" prefHeight=\"47.0\" />\n            <RowConstraints maxHeight=\"110.0\" minHeight=\"10.0\" prefHeight=\"28.0\" />\n            <RowConstraints maxHeight=\"110.0\" minHeight=\"9.0\" prefHeight=\"11.0\" />\n         </rowConstraints>\n         <children>\n            <Button id=\"connectBtn\" alignment=\"CENTER\" contentDisplay=\"CENTER\" mnemonicParsing=\"false\" onAction=\"#loginButtonAction\" stylesheets=\"@../styles/Login.css\" text=\"Connect\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"7\" />\n            <Label text=\"Hostname: \" textAlignment=\"CENTER\" textFill=\"#f89406\" GridPane.rowIndex=\"5\" />\n            <TextField fx:id=\"hostnameTextfield\" prefWidth=\"188.0\" text=\"localhost\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"5\" />\n            <Label text=\"Port: \" textFill=\"#f89406\" GridPane.rowIndex=\"6\" />\n            <TextField fx:id=\"portTextfield\" prefHeight=\"13.0\" prefWidth=\"149.0\" text=\"9001\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"6\" />\n            <Label text=\"Username: \" textFill=\"#f89406\" GridPane.rowIndex=\"3\" />\n            <TextField fx:id=\"usernameTextfield\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"3\" />\n            <Label prefHeight=\"22.0\" prefWidth=\"73.0\" text=\"Server Details\" textFill=\"#f89406\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"4\" />\n            <StackPane GridPane.columnIndex=\"1\" GridPane.rowIndex=\"1\">\n               <children>\n                  <ImageView fx:id=\"Defaultview\" fitHeight=\"93\" fitWidth=\"93\" pickOnBounds=\"true\" preserveRatio=\"true\">\n                     <image>\n                        <Image url=\"@../images/default.png\" />\n                     </image>\n                  </ImageView>\n                  <ImageView fx:id=\"Sarahview\" fitHeight=\"93.0\" fitWidth=\"124.0\" pickOnBounds=\"true\" preserveRatio=\"true\" visible=\"false\">\n                     <image>\n                        <Image preserveRatio=\"false\" smooth=\"false\" url=\"@../images/sarah.png\" />\n                     </image>\n                  </ImageView>\n                  <ImageView fx:id=\"Dominicview\" fitHeight=\"93.0\" fitWidth=\"124.0\" pickOnBounds=\"true\" preserveRatio=\"true\" visible=\"false\">\n                     <image>\n                        <Image preserveRatio=\"false\" smooth=\"true\" url=\"@../images/dominic.png\" />\n                     </image>\n                  </ImageView>\n               </children>\n            </StackPane>\n            <ChoiceBox fx:id=\"imagePicker\" prefWidth=\"150.0\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"2\">\n               <items>\n                  <FXCollections fx:factory=\"observableArrayList\">\n                     <String fx:value=\"Default\" />\n                     <String fx:value=\"Dominic\" />\n                     <String fx:value=\"Sarah\" />\n                  </FXCollections>\n               </items>\n                    </ChoiceBox>\n            <Label fx:id=\"selectedPicture\" text=\"Label\" GridPane.rowIndex=\"1\" />\n            <HBox prefHeight=\"100.0\" prefWidth=\"200.0\" GridPane.columnIndex=\"2\">\n               <children>\n                  <Button id=\"MinimizedBtn\" contentDisplay=\"GRAPHIC_ONLY\" graphicTextGap=\"0.0\" maxHeight=\"24.0\" maxWidth=\"68.0\" minWidth=\"45.0\" mnemonicParsing=\"false\" onAction=\"#minimizeWindow\" prefHeight=\"24.0\" prefWidth=\"45.0\" stylesheets=\"@../styles/Login.css\">\n                     <cursor>\n                        <Cursor fx:constant=\"HAND\" />\n                     </cursor>\n                  </Button>\n                  <Button id=\"CloseBtn\" fx:id=\"closeButton\" contentDisplay=\"GRAPHIC_ONLY\" graphicTextGap=\"0.0\" maxHeight=\"24.0\" maxWidth=\"68.0\" minWidth=\"45.0\" mnemonicParsing=\"false\" onAction=\"#closeSystem\" prefHeight=\"24.0\" prefWidth=\"45.0\" stylesheets=\"@../styles/Login.css\">\n                     <cursor>\n                        <Cursor fx:constant=\"HAND\" />\n                     </cursor></Button>\n               </children>\n               <GridPane.margin>\n                  <Insets right=\"10.0\" top=\"10.0\" />\n               </GridPane.margin>\n            </HBox>\n            <Label text=\"JavaFX Version 0.3\" textFill=\"#f89406\" GridPane.columnIndex=\"1\" GridPane.rowIndex=\"8\">\n               <font>\n                  <Font size=\"10.0\" />\n               </font>\n            </Label>\n         </children>\n      </GridPane>\n   </right>\n</BorderPane>\n"
  },
  {
    "path": "client/src/main/resources/views/TrayNotification.fxml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<?import javafx.scene.*?>\n<?import javafx.scene.text.*?>\n<?import javafx.scene.control.*?>\n<?import javafx.scene.image.*?>\n<?import javafx.scene.shape.*?>\n<?import javafx.scene.layout.*?>\n\n<AnchorPane fx:id=\"rootNode\" maxHeight=\"-Infinity\" maxWidth=\"-Infinity\" minHeight=\"-Infinity\" minWidth=\"-Infinity\" prefHeight=\"87.0\" prefWidth=\"461.0\" style=\"-fx-border-color: gray; -fx-border-width: 1;\" xmlns=\"http://javafx.com/javafx/8\" xmlns:fx=\"http://javafx.com/fxml/1\">\n   <children>\n      <Rectangle fx:id=\"rectangleColor\" arcHeight=\"5.0\" arcWidth=\"5.0\" fill=\"GREY\" height=\"85.0\" layoutX=\"1.0\" layoutY=\"1.0\" stroke=\"GREY\" strokeType=\"INSIDE\" style=\"-fx-arc-width: 0;\" width=\"32.0\" />\n      <ImageView fx:id=\"imageIcon\" fitHeight=\"67.0\" fitWidth=\"67.0\" layoutX=\"47.0\" layoutY=\"9.0\" pickOnBounds=\"true\" />\n      <Label fx:id=\"lblTitle\" layoutX=\"126.0\" layoutY=\"9.0\" text=\"Title:\" wrapText=\"true\">\n         <font>\n            <Font name=\"System Bold\" size=\"16.0\" />\n         </font>\n      </Label>\n      <Label fx:id=\"lblMessage\" layoutX=\"126.0\" layoutY=\"52.0\" text=\"Message:\" wrapText=\"true\">\n         <font>\n            <Font size=\"13.0\" />\n         </font>\n      </Label>\n      <Label fx:id=\"lblClose\" layoutX=\"441.0\" text=\"x\">\n         <font>\n            <Font size=\"20.0\" />\n         </font>\n         <cursor>\n            <Cursor fx:constant=\"HAND\" />\n         </cursor>\n      </Label>\n   </children>\n</AnchorPane>\n"
  },
  {
    "path": "pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>groupId</groupId>\n    <artifactId>JavaFx</artifactId>\n    <packaging>pom</packaging>\n    <version>1.0-SNAPSHOT</version>\n    <name>JavaFX-Chat</name>\n\n    <modules>\n        <module>server</module>\n        <module>client</module>\n    </modules>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.6.1</version>\n                <configuration>\n                    <source>1.8</source>\n                    <target>1.8</target>\n                </configuration>\n            </plugin>\n            <plugin>\n            <groupId>org.apache.maven.plugins</groupId>\n            <artifactId>maven-jar-plugin</artifactId>\n                <version>3.0.2</version>\n            </plugin>\n        </plugins>\n    </build>\n</project>"
  },
  {
    "path": "server/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n    <parent>\n        <groupId>groupId</groupId>\n        <artifactId>JavaFx</artifactId>\n        <version>1.0-SNAPSHOT</version>\n    </parent>\n    <artifactId>server</artifactId>\n    <packaging>jar</packaging>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-jar-plugin</artifactId>\n                <configuration>\n                    <archive>\n                        <manifest>\n                            <addClasspath>true</addClasspath>\n                            <mainClass>com.server.Server</mainClass>\n                        </manifest>\n                    </archive>\n                </configuration>\n            </plugin>\n\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-assembly-plugin</artifactId>\n                <version>2.4.1</version>\n                <configuration>\n                    <!-- get all project dependencies -->\n                    <descriptorRefs>\n                        <descriptorRef>jar-with-dependencies</descriptorRef>\n                    </descriptorRefs>\n                    <!-- MainClass in mainfest make a executable jar -->\n                    <archive>\n                        <manifest>\n                            <mainClass>com.server.Server</mainClass>\n                        </manifest>\n                    </archive>\n\n                </configuration>\n                <executions>\n                    <execution>\n                        <id>make-assembly</id>\n                        <!-- bind to the packaging phase -->\n                        <phase>package</phase>\n                        <goals>\n                            <goal>single</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-api</artifactId>\n            <version>1.5.6</version>\n            <type>jar</type>\n        </dependency>\n        <dependency>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-simple</artifactId>\n            <version>1.5.6</version>\n        </dependency>\n    </dependencies>\n</project>"
  },
  {
    "path": "server/src/main/java/com/exception/DuplicateUsernameException.java",
    "content": "package com.exception;\n\n/**\n * @author Dominic\n * @since 23-Oct-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic class DuplicateUsernameException extends Exception {\n    public DuplicateUsernameException(String message){\n        super(message);\n    }\n}\n"
  },
  {
    "path": "server/src/main/java/com/messages/Message.java",
    "content": "package com.messages;\n\nimport java.io.Serializable;\nimport java.util.ArrayList;\nimport java.util.HashMap;\n\npublic class Message implements Serializable {\n\n    private String name;\n    private MessageType type;\n    private String msg;\n    private int count;\n    private ArrayList<User> list;\n    private ArrayList<User> users;\n\n    private Status status;\n    private byte[] voiceMsg;\n\n    public byte[] getVoiceMsg() {\n        return voiceMsg;\n    }\n\n    public String getPicture() {\n        return picture;\n    }\n\n    private String picture;\n\n    public Message() {\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public String getMsg() {\n\n        return msg;\n    }\n\n    public void setMsg(String msg) {\n        this.msg = msg;\n    }\n\n    public MessageType getType() {\n        return type;\n    }\n\n    public void setType(MessageType type) {\n        this.type = type;\n    }\n\n    public ArrayList<User> getUserlist() {\n        return list;\n    }\n\n    public void setUserlist(HashMap<String, User> userList) {\n        this.list = new ArrayList<>(userList.values());\n    }\n\n    public void setOnlineCount(int count){\n        this.count = count;\n    }\n\n    public int getOnlineCount(){\n        return this.count;\n    }\n\n    public void setPicture(String picture) {\n        this.picture = picture;\n    }\n\n\n    public ArrayList<User> getUsers() {\n        return users;\n    }\n\n    public void setUsers(ArrayList<User> users) {\n        this.users = users;\n    }\n\n    public void setStatus(Status status) {\n        this.status = status;\n    }\n\n    public Status getStatus() {\n        return status;\n    }\n\n    public void setVoiceMsg(byte[] voiceMsg) {\n        this.voiceMsg = voiceMsg;\n    }\n}\n"
  },
  {
    "path": "server/src/main/java/com/messages/MessageType.java",
    "content": "package com.messages;\n\n/**\n * @author Dominic\n * @since 03-Sep-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic enum MessageType {\n    DISCONNECTED, CONNECTED, STATUS, USER, SERVER, NOTIFICATION, VOICE\n}\n"
  },
  {
    "path": "server/src/main/java/com/messages/Status.java",
    "content": "package com.messages;\n\n/**\n * @author Dominic\n * @since 03-Sep-16\n * Website: www.dominicheal.com\n * Github: www.github.com/DomHeal\n */\npublic enum Status {\n    ONLINE, AWAY, BUSY\n}\n"
  },
  {
    "path": "server/src/main/java/com/messages/User.java",
    "content": "package com.messages;\n\nimport java.io.Serializable;\n\n/**\n * Created by Dominic on 01-May-16.\n */\npublic class User implements Serializable {\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    String name;\n\n    public String getPicture() {\n        return picture;\n    }\n\n    public void setPicture(String picture) {\n        this.picture = picture;\n    }\n\n    public Status getStatus() {\n        return status;\n    }\n\n    public void setStatus(Status status) {\n        this.status = status;\n    }\n\n    String picture;\n    Status status;\n}\n"
  },
  {
    "path": "server/src/main/java/com/server/Server.java",
    "content": "package com.server;\n\nimport com.exception.DuplicateUsernameException;\nimport com.messages.Message;\nimport com.messages.MessageType;\nimport com.messages.Status;\nimport com.messages.User;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\nimport java.io.*;\nimport java.net.ServerSocket;\nimport java.net.Socket;\nimport java.net.SocketException;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.HashSet;\n\npublic class Server {\n\n    /* Setting up variables */\n    private static final int PORT = 9001;\n    private static final HashMap<String, User> names = new HashMap<>();\n    private static HashSet<ObjectOutputStream> writers = new HashSet<>();\n    private static ArrayList<User> users = new ArrayList<>();\n    static Logger logger = LoggerFactory.getLogger(Server.class);\n\n    public static void main(String[] args) throws Exception {\n        logger.info(\"The chat server is running.\");\n        ServerSocket listener = new ServerSocket(PORT);\n\n        try {\n            while (true) {\n                new Handler(listener.accept()).start();\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        } finally {\n            listener.close();\n        }\n    }\n\n\n    private static class Handler extends Thread {\n        private String name;\n        private Socket socket;\n        private Logger logger = LoggerFactory.getLogger(Handler.class);\n        private User user;\n        private ObjectInputStream input;\n        private OutputStream os;\n        private ObjectOutputStream output;\n        private InputStream is;\n\n        public Handler(Socket socket) throws IOException {\n            this.socket = socket;\n        }\n\n        public void run() {\n            logger.info(\"Attempting to connect a user...\");\n            try {\n                is = socket.getInputStream();\n                input = new ObjectInputStream(is);\n                os = socket.getOutputStream();\n                output = new ObjectOutputStream(os);\n\n                Message firstMessage = (Message) input.readObject();\n                checkDuplicateUsername(firstMessage);\n                writers.add(output);\n                sendNotification(firstMessage);\n                addToList();\n\n                while (socket.isConnected()) {\n                    Message inputmsg = (Message) input.readObject();\n                    if (inputmsg != null) {\n                        logger.info(inputmsg.getType() + \" - \" + inputmsg.getName() + \": \" + inputmsg.getMsg());\n                        switch (inputmsg.getType()) {\n                            case USER:\n                                write(inputmsg);\n                                break;\n                            case VOICE:\n                                write(inputmsg);\n                                break;\n                            case CONNECTED:\n                                addToList();\n                                break;\n                            case STATUS:\n                                changeStatus(inputmsg);\n                                break;\n                        }\n                    }\n                }\n            } catch (SocketException socketException) {\n                logger.error(\"Socket Exception for user \" + name);\n            } catch (DuplicateUsernameException duplicateException){\n                logger.error(\"Duplicate Username : \" + name);\n            } catch (Exception e){\n                logger.error(\"Exception in run() method for user: \" + name, e);\n            } finally {\n                closeConnections();\n            }\n        }\n\n        private Message changeStatus(Message inputmsg) throws IOException {\n            logger.debug(inputmsg.getName() + \" has changed status to  \" + inputmsg.getStatus());\n            Message msg = new Message();\n            msg.setName(user.getName());\n            msg.setType(MessageType.STATUS);\n            msg.setMsg(\"\");\n            User userObj = names.get(name);\n            userObj.setStatus(inputmsg.getStatus());\n            write(msg);\n            return msg;\n        }\n\n        private synchronized void checkDuplicateUsername(Message firstMessage) throws DuplicateUsernameException {\n            logger.info(firstMessage.getName() + \" is trying to connect\");\n            if (!names.containsKey(firstMessage.getName())) {\n                this.name = firstMessage.getName();\n                user = new User();\n                user.setName(firstMessage.getName());\n                user.setStatus(Status.ONLINE);\n                user.setPicture(firstMessage.getPicture());\n\n                users.add(user);\n                names.put(name, user);\n\n                logger.info(name + \" has been added to the list\");\n            } else {\n                logger.error(firstMessage.getName() + \" is already connected\");\n                throw new DuplicateUsernameException(firstMessage.getName() + \" is already connected\");\n            }\n        }\n\n        private Message sendNotification(Message firstMessage) throws IOException {\n            Message msg = new Message();\n            msg.setMsg(\"has joined the chat.\");\n            msg.setType(MessageType.NOTIFICATION);\n            msg.setName(firstMessage.getName());\n            msg.setPicture(firstMessage.getPicture());\n            write(msg);\n            return msg;\n        }\n\n\n        private Message removeFromList() throws IOException {\n            logger.debug(\"removeFromList() method Enter\");\n            Message msg = new Message();\n            msg.setMsg(\"has left the chat.\");\n            msg.setType(MessageType.DISCONNECTED);\n            msg.setName(\"SERVER\");\n            msg.setUserlist(names);\n            write(msg);\n            logger.debug(\"removeFromList() method Exit\");\n            return msg;\n        }\n\n        /*\n         * For displaying that a user has joined the server\n         */\n        private Message addToList() throws IOException {\n            Message msg = new Message();\n            msg.setMsg(\"Welcome, You have now joined the server! Enjoy chatting!\");\n            msg.setType(MessageType.CONNECTED);\n            msg.setName(\"SERVER\");\n            write(msg);\n            return msg;\n        }\n\n        /*\n         * Creates and sends a Message type to the listeners.\n         */\n        private void write(Message msg) throws IOException {\n            for (ObjectOutputStream writer : writers) {\n                msg.setUserlist(names);\n                msg.setUsers(users);\n                msg.setOnlineCount(names.size());\n                writer.writeObject(msg);\n                writer.reset();\n            }\n        }\n\n        /*\n         * Once a user has been disconnected, we close the open connections and remove the writers\n         */\n        private synchronized void closeConnections()  {\n            logger.debug(\"closeConnections() method Enter\");\n            logger.info(\"HashMap names:\" + names.size() + \" writers:\" + writers.size() + \" usersList size:\" + users.size());\n            if (name != null) {\n                names.remove(name);\n                logger.info(\"User: \" + name + \" has been removed!\");\n            }\n            if (user != null){\n                users.remove(user);\n                logger.info(\"User object: \" + user + \" has been removed!\");\n            }\n            if (output != null){\n                writers.remove(output);\n                logger.info(\"Writer object: \" + user + \" has been removed!\");\n            }\n            if (is != null){\n                try {\n                    is.close();\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n            }\n            if (os != null){\n                try {\n                    os.close();\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n            }\n            if (input != null){\n                try {\n                    input.close();\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n            }\n            try {\n                removeFromList();\n            } catch (Exception e) {\n                e.printStackTrace();\n            }\n            logger.info(\"HashMap names:\" + names.size() + \" writers:\" + writers.size() + \" usersList size:\" + users.size());\n            logger.debug(\"closeConnections() method Exit\");\n        }\n    }\n}\n"
  }
]