Browse Source

Release 22

master
Defend 8 years ago
parent
commit
812e515146
  1. 292
      .idea/workspace.xml
  2. 82
      src/client.java
  3. 51
      src/console.java
  4. 4
      src/ctServer.java
  5. 6
      src/eventHandler.java
  6. 40
      src/socketInfo.java

292
.idea/workspace.xml

@ -28,8 +28,8 @@
<file leaf-file-name="ctServer.java" pinned="false" current-in-tab="false"> <file leaf-file-name="ctServer.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ctServer.java"> <entry file="file://$PROJECT_DIR$/src/ctServer.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="485"> <state relative-caret-position="255">
<caret line="32" column="1" selection-start-line="32" selection-start-column="1" selection-end-line="32" selection-end-column="1" /> <caret line="15" column="16" selection-start-line="15" selection-start-column="16" selection-end-line="15" selection-end-column="16" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -40,10 +40,15 @@
<file leaf-file-name="console.java" pinned="false" current-in-tab="false"> <file leaf-file-name="console.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/console.java"> <entry file="file://$PROJECT_DIR$/src/console.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264"> <state relative-caret-position="187">
<caret line="67" column="90" selection-start-line="67" selection-start-column="90" selection-end-line="67" selection-end-column="90" /> <caret line="11" column="4" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -52,31 +57,32 @@
<file leaf-file-name="socketInfo.java" pinned="false" current-in-tab="false"> <file leaf-file-name="socketInfo.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/socketInfo.java"> <entry file="file://$PROJECT_DIR$/src/socketInfo.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264"> <state relative-caret-position="-804">
<caret line="89" column="37" selection-start-line="89" selection-start-column="37" selection-end-line="89" selection-end-column="37" /> <caret line="72" column="53" selection-start-line="72" selection-start-column="34" selection-end-line="72" selection-end-column="53" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="client.java" pinned="false" current-in-tab="true"> <file leaf-file-name="eventHandler.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/client.java"> <entry file="file://$PROJECT_DIR$/src/eventHandler.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162"> <state relative-caret-position="68">
<caret line="63" column="28" selection-start-line="63" selection-start-column="28" selection-end-line="63" selection-end-column="28" /> <caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding> <folding />
<element signature="imports" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="JsonParser.class" pinned="false" current-in-tab="false"> <file leaf-file-name="client.java" pinned="false" current-in-tab="true">
<entry file="jar://$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class"> <entry file="file://$PROJECT_DIR$/src/client.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204"> <state relative-caret-position="-5">
<caret line="30" column="16" selection-start-line="30" selection-start-column="16" selection-end-line="30" selection-end-column="16" /> <caret line="98" column="33" selection-start-line="98" selection-start-column="33" selection-end-line="98" selection-end-column="33" />
<folding /> <folding>
<element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -100,10 +106,11 @@
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/src/main.java" /> <option value="$PROJECT_DIR$/src/main.java" />
<option value="$PROJECT_DIR$/src/ctServer.java" />
<option value="$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class" /> <option value="$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class" />
<option value="$PROJECT_DIR$/src/socketInfo.java" /> <option value="$PROJECT_DIR$/src/socketInfo.java" />
<option value="$PROJECT_DIR$/src/console.java" /> <option value="$PROJECT_DIR$/src/console.java" />
<option value="$PROJECT_DIR$/src/ctServer.java" />
<option value="$PROJECT_DIR$/src/eventHandler.java" />
<option value="$PROJECT_DIR$/src/client.java" /> <option value="$PROJECT_DIR$/src/client.java" />
</list> </list>
</option> </option>
@ -145,9 +152,8 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="Scratches" /> <pane id="Scratches" />
<pane id="PackagesPane" /> <pane id="Scope" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<PATH> <PATH>
@ -166,8 +172,37 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="ctServer" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="ctServer" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="ctServer" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="ctServer" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</pane> </pane>
<pane id="PackagesPane" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -180,8 +215,9 @@
<property name="GenerateAntBuildDialog.backupFiles" value="true" /> <property name="GenerateAntBuildDialog.backupFiles" value="true" />
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="ctserver" /> <property name="GenerateAntBuildDialog.outputFileNameProperty" value="ctserver" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="restartRequiresConfirmation" value="false" />
</component> </component>
<component name="RunManager" selected="Application.Unnamed"> <component name="RunManager" selected="Application.Debug">
<configuration default="true" type="#com.intellij.j2meplugin.run.J2MEConfigurationType" factoryName="J2ME"> <configuration default="true" type="#com.intellij.j2meplugin.run.J2MEConfigurationType" factoryName="J2ME">
<module name="" /> <module name="" />
<USER_OPTIONS /> <USER_OPTIONS />
@ -623,7 +659,7 @@
<configuration default="true" type="osgi.bnd.run" factoryName="Test Launcher (JUnit)"> <configuration default="true" type="osgi.bnd.run" factoryName="Test Launcher (JUnit)">
<method /> <method />
</configuration> </configuration>
<configuration default="false" name="Unnamed" type="Application" factoryName="Application"> <configuration default="false" name="Debug" type="Application" factoryName="Application" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="ctServer" /> <option name="MAIN_CLASS_NAME" value="ctServer" />
<option name="VM_PARAMETERS" value="" /> <option name="VM_PARAMETERS" value="" />
@ -639,7 +675,7 @@
<method /> <method />
</configuration> </configuration>
<list size="1"> <list size="1">
<item index="0" class="java.lang.String" itemvalue="Application.Unnamed" /> <item index="0" class="java.lang.String" itemvalue="Application.Debug" />
</list> </list>
</component> </component>
<component name="ShelveChangesManager" show_recycled="false"> <component name="ShelveChangesManager" show_recycled="false">
@ -661,25 +697,36 @@
<workItem from="1470936508138" duration="9814000" /> <workItem from="1470936508138" duration="9814000" />
<workItem from="1470992276279" duration="9337000" /> <workItem from="1470992276279" duration="9337000" />
<workItem from="1471206887598" duration="5117000" /> <workItem from="1471206887598" duration="5117000" />
<workItem from="1471213151749" duration="371000" />
<workItem from="1471272205780" duration="10014000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="92242000" /> <option name="totallyTimeSpent" value="102627000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1066" extended-state="6" /> <frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
<editor active="true" /> <editor active="false" />
<layout> <layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3290461" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3279743" sideWeight="0.4792111" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3279743" sideWeight="0.4792111" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3876853" sideWeight="0.5444984" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3876853" sideWeight="0.5444984" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3858521" sideWeight="0.45550162" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3858521" sideWeight="0.45550162" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32839224" sideWeight="0.4978678" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32839224" sideWeight="0.4978678" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -689,7 +736,7 @@
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39935064" sideWeight="0.47708333" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39871383" sideWeight="0.47708333" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@ -712,7 +759,7 @@
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<option name="time" value="33" /> <option name="time" value="39" />
</breakpoint-manager> </breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
@ -732,11 +779,120 @@
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/console.java"> <entry file="file://$PROJECT_DIR$/src/console.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1037">
<caret line="67" column="90" selection-start-line="67" selection-start-column="90" selection-end-line="67" selection-end-column="90" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/socketInfo.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1496">
<caret line="89" column="37" selection-start-line="89" selection-start-column="37" selection-end-line="89" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/client.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="425">
<caret line="30" column="16" selection-start-line="30" selection-start-column="16" selection-end-line="30" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ctServer.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="32" column="1" selection-start-line="32" selection-start-column="1" selection-end-line="32" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/console.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1037">
<caret line="67" column="90" selection-start-line="67" selection-start-column="90" selection-end-line="67" selection-end-column="90" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/socketInfo.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1496">
<caret line="89" column="37" selection-start-line="89" selection-start-column="37" selection-end-line="89" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/client.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="425">
<caret line="30" column="16" selection-start-line="30" selection-start-column="16" selection-end-line="30" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ctServer.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="32" column="1" selection-start-line="32" selection-start-column="1" selection-end-line="32" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/console.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -747,6 +903,7 @@
<caret line="62" column="9" selection-start-line="62" selection-start-column="9" selection-end-line="62" selection-end-column="9" /> <caret line="62" column="9" selection-start-line="62" selection-start-column="9" selection-end-line="62" selection-end-column="9" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -767,6 +924,11 @@
<caret line="64" column="91" selection-start-line="64" selection-start-column="91" selection-end-line="64" selection-end-column="91" /> <caret line="64" column="91" selection-start-line="64" selection-start-column="91" selection-end-line="64" selection-end-column="91" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -777,6 +939,7 @@
<caret line="54" column="20" selection-start-line="54" selection-start-column="20" selection-end-line="54" selection-end-column="20" /> <caret line="54" column="20" selection-start-line="54" selection-start-column="20" selection-end-line="54" selection-end-column="20" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -797,6 +960,11 @@
<caret line="34" column="5" selection-start-line="34" selection-start-column="5" selection-end-line="34" selection-end-column="5" /> <caret line="34" column="5" selection-start-line="34" selection-start-column="5" selection-end-line="34" selection-end-column="5" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -807,6 +975,7 @@
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -828,6 +997,11 @@
<caret line="67" column="13" selection-start-line="67" selection-start-column="13" selection-end-line="67" selection-end-column="13" /> <caret line="67" column="13" selection-start-line="67" selection-start-column="13" selection-end-line="67" selection-end-column="13" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -838,6 +1012,7 @@
<caret line="86" column="50" selection-start-line="86" selection-start-column="50" selection-end-line="86" selection-end-column="50" /> <caret line="86" column="50" selection-start-line="86" selection-start-column="50" selection-end-line="86" selection-end-column="50" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -859,6 +1034,11 @@
<caret line="67" column="13" selection-start-line="67" selection-start-column="13" selection-end-line="67" selection-end-column="13" /> <caret line="67" column="13" selection-start-line="67" selection-start-column="13" selection-end-line="67" selection-end-column="13" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -869,6 +1049,7 @@
<caret line="43" column="30" selection-start-line="43" selection-start-column="30" selection-end-line="43" selection-end-column="30" /> <caret line="43" column="30" selection-start-line="43" selection-start-column="30" selection-end-line="43" selection-end-column="30" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -897,33 +1078,30 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="jar://E:/ProfessionalPrograms/JDK8/src.zip!/java/util/ArrayList.java" />
<entry file="file://$PROJECT_DIR$/ctserver.xml" /> <entry file="file://$PROJECT_DIR$/ctserver.xml" />
<entry file="file://$PROJECT_DIR$/module_ctserver.xml" /> <entry file="file://$PROJECT_DIR$/module_ctserver.xml" />
<entry file="file://$PROJECT_DIR$/package-list" /> <entry file="file://$PROJECT_DIR$/package-list" />
<entry file="jar://E:/ProfessionalPrograms/JDK8/src.zip!/java/net/SocketInputStream.java" /> <entry file="jar://E:/ProfessionalPrograms/JDK8/src.zip!/java/net/SocketInputStream.java" />
<entry file="jar://$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class"> <entry file="jar://$PROJECT_DIR$/lib/javax.json.jar!/javax/json/stream/JsonParser.class">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204"> <state relative-caret-position="425">
<caret line="30" column="16" selection-start-line="30" selection-start-column="16" selection-end-line="30" selection-end-column="16" /> <caret line="30" column="16" selection-start-line="30" selection-start-column="16" selection-end-line="30" selection-end-column="16" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/ctServer.java"> <entry file="jar://E:/ProfessionalPrograms/JDK8/src.zip!/java/util/ArrayList.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="485"> <state relative-caret-position="181">
<caret line="32" column="1" selection-start-line="32" selection-start-column="1" selection-end-line="32" selection-end-column="1" /> <caret line="430" column="0" selection-start-line="430" selection-start-column="0" selection-end-line="430" selection-end-column="0" />
<folding> <folding />
<element signature="imports" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/console.java"> <entry file="file://$PROJECT_DIR$/src/ctServer.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264"> <state relative-caret-position="255">
<caret line="67" column="90" selection-start-line="67" selection-start-column="90" selection-end-line="67" selection-end-column="90" /> <caret line="15" column="16" selection-start-line="15" selection-start-column="16" selection-end-line="15" selection-end-column="16" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -932,18 +1110,42 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/socketInfo.java"> <entry file="file://$PROJECT_DIR$/src/socketInfo.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264"> <state relative-caret-position="-804">
<caret line="89" column="37" selection-start-line="89" selection-start-column="37" selection-end-line="89" selection-end-column="37" /> <caret line="72" column="53" selection-start-line="72" selection-start-column="34" selection-end-line="72" selection-end-column="53" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/eventHandler.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/console.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="11" column="4" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#consoleListner#0;class#console#0" expanded="false" />
<element signature="method#out#0;class#console#0" expanded="false" />
<element signature="method#socket#0;class#console#0" expanded="false" />
<element signature="method#debug#0;class#console#0" expanded="false" />
<element signature="method#run#0;class#console#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/client.java"> <entry file="file://$PROJECT_DIR$/src/client.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162"> <state relative-caret-position="-5">
<caret line="63" column="28" selection-start-line="63" selection-start-column="28" selection-end-line="63" selection-end-column="28" /> <caret line="98" column="33" selection-start-line="98" selection-start-column="33" selection-end-line="98" selection-end-column="33" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#bytesToStringUTFCustom#0;class#client#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>

82
src/client.java

@ -41,6 +41,7 @@ public class client extends Thread {
if(!socketInfo.isOnline(id)){ if(!socketInfo.isOnline(id)){
return; return;
} }
sendSocket("{\"fn\":\"close\",\"reason\":\"\"}");
try { try {
in.close(); in.close();
out.close(); out.close();
@ -57,15 +58,27 @@ public class client extends Thread {
return; return;
} }
while (socketInfo.isOnline(id)) { while (socketInfo.isOnline(id)) {
// Получение сообщения
String msg = readSocket(); String msg = readSocket();
// Сохранение данных из сообщения
parseInput(msg); parseInput(msg);
// Проверка протокола
if(!socketInfo.isProtocolAuth(id)){socketInfo.checkProtocol(id);} if(!socketInfo.isProtocolAuth(id)){socketInfo.checkProtocol(id);}
if(!socketInfo.isProtocolAuth(id)){sendSocket("{\"fn\":\"bad_protocol\"}");close();} if(!socketInfo.isProtocolAuth(id)){close();}
//TODO: подключить Event Handler
//TODO: проверить ROLE клиента
//TODO: выполнить событие в зависимости от ROLE клиента
//RoleChecker -> socketInfo
//eventFilter -> eventHandler
//eventFilter > switch > EVENT & ROLE
//eventFilter >> eventMaker >> client.socket
//TODO: убрать ECHO сообщение
sendSocket(msg); sendSocket(msg);
} }
} }
private String bytesToStringUTFCustom(int[] ints) { private String bytesToStringUTFCustom(int[] ints) {
//TODO: добавить поддержку русского языка
char[] buffer = new char[ints.length]; char[] buffer = new char[ints.length];
for (int i = 0; i < buffer.length; i++) { for (int i = 0; i < buffer.length; i++) {
char c = (char) ints[i]; char c = (char) ints[i];
@ -98,9 +111,7 @@ public class client extends Thread {
+ "\r\n\r\n") + "\r\n\r\n")
.getBytes("UTF-8"); .getBytes("UTF-8");
out.write(response, 0, response.length); out.write(response, 0, response.length);
} catch (IOException e) { } catch (IOException | NoSuchAlgorithmException e) {
console.out("Server Error:", e.toString());
} catch (NoSuchAlgorithmException e) {
console.out("Server Error:", e.toString()); console.out("Server Error:", e.toString());
} }
socket.setSoTimeout(0); socket.setSoTimeout(0);
@ -110,7 +121,6 @@ public class client extends Thread {
} }
} catch (SocketException e) { } catch (SocketException e) {
console.debug("исключение 22"); console.debug("исключение 22");
//TODO: написать исключение если сокет закрыт
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
console.socket(id, "Handshake Timeout (2000ms)"); console.socket(id, "Handshake Timeout (2000ms)");
socketInfo.setHttpAuth(id, false); socketInfo.setHttpAuth(id, false);
@ -138,19 +148,14 @@ public class client extends Thread {
System.arraycopy(response, 0, r, 2, response.length); System.arraycopy(response, 0, r, 2, response.length);
r[0] = (byte) 129; r[0] = (byte) 129;
r[1] = (byte) (response.length); r[1] = (byte) (response.length);
} else { } else if (message.length() < 65535) {
if (message.length() < 65535) {
r = new byte[response.length + 4]; r = new byte[response.length + 4];
System.arraycopy(response, 0, r, 4, response.length); System.arraycopy(response, 0, r, 4, response.length);
r[0] = (byte) 129; r[0] = (byte) 129;
r[1] = (byte) 126; r[1] = (byte) 126;
r[2] = (byte) (response.length >>> 8); r[2] = (byte) (response.length >>> 8);
r[3] = (byte) (response.length); r[3] = (byte) (response.length);
} else { } else if (response.length < Long.MAX_VALUE) {
if (response.length > Long.MAX_VALUE) {
console.out("Socket Exception", "Too long message for sending! (>64bit)");
return false;
}
r = new byte[response.length + 8]; r = new byte[response.length + 8];
System.arraycopy(response, 0, r, 8, response.length); System.arraycopy(response, 0, r, 8, response.length);
r[0] = (byte) 129; r[0] = (byte) 129;
@ -163,7 +168,9 @@ public class client extends Thread {
r[7] = (byte) (response.length >>> 16); r[7] = (byte) (response.length >>> 16);
r[8] = (byte) (response.length >>> 8); r[8] = (byte) (response.length >>> 8);
r[9] = (byte) (response.length); r[9] = (byte) (response.length);
} } else {
console.out("Socket Exception", "Too long message for sending! (>64bit)");
return false;
} }
try { try {
out.write(r, 0, r.length); out.write(r, 0, r.length);
@ -180,7 +187,6 @@ public class client extends Thread {
String out = ""; String out = "";
try { try {
int[] MSG = new int[0]; int[] MSG = new int[0];
int OPCOUNT = 1;
int LENGTH; int LENGTH;
int KEYFRAME = 0; int KEYFRAME = 0;
int[] KEY = new int[4]; int[] KEY = new int[4];
@ -194,10 +200,6 @@ public class client extends Thread {
return null; return null;
case 129: case 129:
LENGTH = in.read(); //читаем второй бит с данными о размере сообщения LENGTH = in.read(); //читаем второй бит с данными о размере сообщения
//TODO: which и switch OPCOUNT - необходимо убрать
while (OPCOUNT < 4) {
switch (OPCOUNT) {
case 1:
switch (LENGTH) { //узнаем длину сообщения switch (LENGTH) { //узнаем длину сообщения
default: default:
KEYFRAME = 2; KEYFRAME = 2;
@ -209,8 +211,6 @@ public class client extends Thread {
KEYFRAME = 10; //65535-... KEYFRAME = 10; //65535-...
break; break;
} }
break;
case 2:
switch (KEYFRAME) { switch (KEYFRAME) {
case 2: case 2:
MSG = new int[LENGTH - 128]; MSG = new int[LENGTH - 128];
@ -238,17 +238,12 @@ public class client extends Thread {
int enc = in.read(); int enc = in.read();
MSG[j] = (byte) (enc ^ KEY[j & 0x3]); MSG[j] = (byte) (enc ^ KEY[j & 0x3]);
} }
break;
case 3:
if (MSG.length > 0) { if (MSG.length > 0) {
out = bytesToStringUTFCustom(MSG); out = bytesToStringUTFCustom(MSG);
} else { } else {
return null; return null;
} }
} }
OPCOUNT++;
}
}
} catch (IOException e) { } catch (IOException e) {
console.out("Socket Exception", "Client socket is closed?! Closing socket connection!"); console.out("Socket Exception", "Client socket is closed?! Closing socket connection!");
close(); close();
@ -295,40 +290,3 @@ public class client extends Thread {
} }
} }
// public void sControl(){
// try{
// while (true) {
// String input = reader.readLine();
// if(input == null){break;}
// Pattern main = Pattern.compile(";");
// if(!httpAuth) {
// if (!ctServer.checkClient(this, main.split(input))) {
// writer.println("CONNECT_DENIED");
// break;
// }
// }
// switch (input) {
// case "EXIT":
// socket.close();
// break;
// default:
// writer.println("Client info - " + socket.getRemoteSocketAddress().toString());
// console.out("Socket "+socketID+" Message",input);
// }
// }
// } catch (IOException e) {
// console.out("Server Error:", e.toString());
// } finally {
// close();
// try {
// socket.close();
// console.out("Server", "Socket "+socketID+" disconnected!");
// } catch (IOException e) {
// console.out("Server","System socket closing error!");
// }catch (NullPointerException e){
//
// }
//
// }
// }

51
src/console.java

@ -53,6 +53,7 @@ public class console extends Thread{
try{ try{
line = in.readLine(); line = in.readLine();
Integer sid; Integer sid;
Integer id;
Pattern main = Pattern.compile(" "); Pattern main = Pattern.compile(" ");
String[] sx = main.split(line); String[] sx = main.split(line);
switch (sx[0]){ switch (sx[0]){
@ -73,19 +74,12 @@ public class console extends Thread{
break; break;
case "/kick": case "/kick":
sid = Integer.valueOf(sx[1]); sid = Integer.valueOf(sx[1]);
if(socketInfo.findSocket(Integer.valueOf(sx[1])) != -1){ if(socketInfo.findSocket.bySID(Integer.valueOf(sx[1])) != -1){
socketInfo.getClient(sid).close(); socketInfo.getClient(sid).close();
} }
break; break;
case "/help":
console.out("Server","/kick [socketid] для отключения сокета от сервера");
console.out("Server","/list для отображения всех клиентов");
console.out("Server","/info [socketid] для отображения полной информации о данном клиенте");
console.out("Server","/send [socketid] [msg] отладочная команда");
console.out("Server","ctServer Proto Defend Development 2016");
break;
case "/send": case "/send":
sid = socketInfo.findSocket(Integer.valueOf(sx[1])); sid = socketInfo.findSocket.bySID(Integer.valueOf(sx[1]));
if(sid != -1){ if(sid != -1){
String msg = ""; String msg = "";
for (int i = 2; i < sx.length ; i++) { for (int i = 2; i < sx.length ; i++) {
@ -95,6 +89,45 @@ public class console extends Thread{
socketInfo.getClient(Integer.valueOf(sx[1])).sendSocket(msg); socketInfo.getClient(Integer.valueOf(sx[1])).sendSocket(msg);
} }
break; break;
case "/info":
if(sx.length < 3){
console.out("Server","/info [pid/sid] <id>");
} else {
switch (sx[1]) {
case "sid":
sid = Integer.valueOf(sx[2]);
id = socketInfo.findSocket.bySID(sid);
if(id == -1){break;}
console.socket(sid,"VKID " + socketInfo.VKID.get(id)
+ " PROTOCOL " + socketInfo.PROTOCOL.get(id)
+ " EVENT " + socketInfo.EVENT.get(id)
+ " PARTYID " + socketInfo.PARTYID.get(id)
+ " TRACKDURATION " + socketInfo.DURATION.get(id));
break;
case "pid":
ArrayList<Integer> a = socketInfo.findSocket.byPID(Integer.valueOf(sx[2]));
for (int i = 0; i < a.size(); i++) {
id = a.get(i);
console.socket(socketInfo.SOCKETID.get(id),"VKID " + socketInfo.VKID.get(id)
+ " PROTOCOL " + socketInfo.PROTOCOL.get(id)
+ " EVENT " + socketInfo.EVENT.get(id)
+ " PARTYID " + socketInfo.PARTYID.get(id)
+ " TRACKDURATION " + socketInfo.DURATION.get(id));
}
break;
default:
console.out("Server", "/info [pid/sid] <id>");
break;
}
}
break;
case "/help":
console.out("Server","/kick [socketid] для отключения сокета от сервера");
console.out("Server","/list для отображения всех клиентов");
console.out("Server","/info pid/sid [id] для отображения полной информации о данном клиенте");
console.out("Server","/send [socketid] [msg] отладочная команда");
console.out("Server","ctServer Proto Defend Development 2016");
break;
default: console.out("Server","Введите /help для помощи"); default: console.out("Server","Введите /help для помощи");
} }

4
src/ctServer.java

@ -5,11 +5,11 @@ public class ctServer {
public static void main(String[] args) throws IOException{ public static void main(String[] args) throws IOException{
socketInfo.init(); socketInfo.init();
// socketID = 0; //TODO: оптимизация идентификаторов сокетов
try{ try{
new console().consoleListner(); new console().consoleListner();
} }
catch (IOException e){ catch (IOException ignored){
} }
int port = 80; int port = 80;

6
src/eventHandler.java

@ -0,0 +1,6 @@
/**
* Created by itsmy on 15.08.2016.
*/
public class eventHandler extends client {
}

40
src/socketInfo.java

@ -1,4 +1,7 @@
import com.sun.istack.internal.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.function.BooleanSupplier; import java.util.function.BooleanSupplier;
/** /**
@ -46,7 +49,7 @@ public class socketInfo {
} }
public static void close(Integer sid){ public static void close(Integer sid){
int s = findSocket(sid); int s = findSocket.bySID(sid);
VKID.remove(s); VKID.remove(s);
ROLE.remove(s); ROLE.remove(s);
PROTOCOL.remove(s); PROTOCOL.remove(s);
@ -67,25 +70,38 @@ public class socketInfo {
return sid; return sid;
} }
public static Integer findSocket(int s){ public static class findSocket extends socketInfo{
public static Integer bySID(Integer s){
int id = -1; int id = -1;
for (int i = 0; i < SOCKETID.size(); i++) { for (int i = 0; i < SOCKETID.size(); i++) {
if(SOCKETID.get(i) == s){ if(SOCKETID.get(i).equals(s)){
id = i; id = i;
} }
} }
return id; return id;
} }
public static ArrayList<Integer> byPID(Integer pid){
ArrayList<Integer> a = new ArrayList<>();
for (int i = 0; i < PARTYID.size(); i++) {
if(PARTYID.get(i).equals(pid)){
a.add(i);
}
}
return a;
}
}
public static void setHttpAuth(Integer sid, Boolean b){ public static void setHttpAuth(Integer sid, Boolean b){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return; if(s == -1) return;
httpAuth.set(s, b); httpAuth.set(s, b);
} }
public static void checkProtocol(Integer sid){ public static void checkProtocol(Integer sid){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return; if(s == -1) return;
if(PROTOCOL.get(s).equals("1A")){ if(PROTOCOL.get(s).equals("1A")){
protocolAuth.set(s, true); protocolAuth.set(s, true);
@ -93,31 +109,31 @@ public class socketInfo {
} }
public static Boolean isProtocolAuth(Integer sid){ public static Boolean isProtocolAuth(Integer sid){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return Boolean.FALSE; if(s == -1) return Boolean.FALSE;
return protocolAuth.get(s); return protocolAuth.get(s);
} }
public static Boolean isHttpAuth(Integer sid){ public static Boolean isHttpAuth(Integer sid){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return Boolean.FALSE; if(s == -1) return Boolean.FALSE;
return httpAuth.get(s); return httpAuth.get(s);
} }
public static Boolean isOnline(Integer sid){ public static Boolean isOnline(Integer sid){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return Boolean.FALSE; if(s == -1) return Boolean.FALSE;
return ONLINE.get(s); return ONLINE.get(s);
} }
public static client getClient(Integer sid){ public static client getClient(Integer sid){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return null; if(s == -1) return null;
return socketInfo.CLIENT.get(s); return socketInfo.CLIENT.get(s);
} }
public static void setString(Integer sid, String keyName, String value) { public static void setString(Integer sid, String keyName, String value) {
int s = findSocket(sid); int s = findSocket.bySID(sid);
if (s == -1) return; if (s == -1) return;
switch (keyName) { switch (keyName) {
case "fn": case "fn":
@ -133,7 +149,7 @@ public class socketInfo {
} }
public static void setInteger(Integer sid, String keyName, Integer value){ public static void setInteger(Integer sid, String keyName, Integer value){
int s = findSocket(sid); int s = findSocket.bySID(sid);
if(s == -1) return; if(s == -1) return;
switch (keyName){ switch (keyName){
case "vk_id": VKID.set(s, value); case "vk_id": VKID.set(s, value);

Loading…
Cancel
Save