Browse Source

added client methods

master
MrTob 5 years ago
parent
commit
cf80077381
3 changed files with 106 additions and 23 deletions
  1. +45
    -22
      .idea/workspace.xml
  2. +20
    -1
      src/xyz/nextn/Client.java
  3. +41
    -0
      src/xyz/nextn/Server.java

+ 45
- 22
.idea/workspace.xml View File

@@ -2,7 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="bb3e1b7e-b662-4d08-9145-fd676c7f3d31" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/xyz/nextn/Server.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/xyz/nextn/Server.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@@ -18,12 +18,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/xyz/nextn/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="43" lean-forward="true" selection-start-line="5" selection-start-column="43" selection-end-line="5" selection-end-column="43" />
<folding>
<element signature="e#84#85#0" expanded="true" />
<element signature="e#125#126#0" expanded="true" />
</folding>
<state relative-caret-position="119">
<caret line="7" column="27" selection-start-line="7" selection-start-column="27" selection-end-line="7" selection-end-column="27" />
</state>
</provider>
</entry>
@@ -31,8 +27,13 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/xyz/nextn/Server.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="4" selection-start-line="7" selection-start-column="4" selection-end-line="7" selection-end-column="4" />
<state relative-caret-position="374">
<caret line="30" column="57" lean-forward="true" selection-start-line="30" selection-start-column="57" selection-end-line="30" selection-end-column="58" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#549#550#0" expanded="true" />
<element signature="e#599#600#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@@ -126,6 +127,11 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
@@ -153,11 +159,25 @@
<option name="project" value="LOCAL" />
<updated>1569263446175</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="added Server methods">
<created>1569263681042</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1569263681042</updated>
</task>
<task id="LOCAL-00004" summary="added Server methods">
<created>1569263789745</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1569263789745</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="63000" />
<option name="totallyTimeSpent" value="305000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
@@ -170,9 +190,10 @@
<window_info id="Designer" order="4" />
<window_info id="UI Designer" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Messages" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49946696" visible="true" weight="0.32936078" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -181,7 +202,7 @@
<window_info anchor="bottom" id="Database Changes" order="8" />
<window_info anchor="bottom" id="Terminal" order="9" />
<window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.50053304" side_tool="true" visible="true" weight="0.32936078" />
<window_info active="true" anchor="bottom" id="Version Control" order="11" sideWeight="0.49946696" visible="true" weight="0.32936078" />
<window_info anchor="bottom" id="Version Control" order="11" sideWeight="0.49946696" weight="0.32936078" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -225,24 +246,26 @@
<component name="VcsManagerConfiguration">
<MESSAGE value="git init" />
<MESSAGE value="added server" />
<option name="LAST_COMMIT_MESSAGE" value="added server" />
<MESSAGE value="added Server methods" />
<option name="LAST_COMMIT_MESSAGE" value="added Server methods" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/xyz/nextn/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="43" lean-forward="true" selection-start-line="5" selection-start-column="43" selection-end-line="5" selection-end-column="43" />
<folding>
<element signature="e#84#85#0" expanded="true" />
<element signature="e#125#126#0" expanded="true" />
</folding>
<state relative-caret-position="119">
<caret line="7" column="27" selection-start-line="7" selection-start-column="27" selection-end-line="7" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/xyz/nextn/Server.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="4" selection-start-line="7" selection-start-column="4" selection-end-line="7" selection-end-column="4" />
<state relative-caret-position="374">
<caret line="30" column="57" lean-forward="true" selection-start-line="30" selection-start-column="57" selection-end-line="30" selection-end-column="58" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#549#550#0" expanded="true" />
<element signature="e#599#600#0" expanded="true" />
</folding>
</state>
</provider>
</entry>


+ 20
- 1
src/xyz/nextn/Client.java View File

@@ -1,4 +1,23 @@
package xyz.nextn;

public class Client {
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class Client extends Thread
{
DateFormat fordate = new SimpleDateFormat("yyyy/MM/dd");
DateFormat fortime = new SimpleDateFormat("hh:mm:ss");
final DataInputStream dis;
final DataOutputStream dos;
final Socket s;

public Client(Socket s, DataInputStream dis, DataOutputStream dos)
{
this.s = s;
this.dis = dis;
this.dos = dos;
}
}

+ 41
- 0
src/xyz/nextn/Server.java View File

@@ -2,6 +2,7 @@ package xyz.nextn;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
@@ -36,6 +37,46 @@ public class Server {
public EchoClientHandler(Socket socket) {
this.clientSocket = socket;
}

public void run() {
try {
out = new PrintWriter(clientSocket.getOutputStream(), true);
} catch (IOException e) {
e.printStackTrace();
}
try {
in = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
} catch (IOException e) {
e.printStackTrace();
}

String inputLine = null;
while (true) {
try {
if (!((inputLine = in.readLine()) != null)) break;
} catch (IOException e) {
e.printStackTrace();
}
if (".".equals(inputLine)) {
out.println("bye");
break;
}
out.println(inputLine);
}

try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
out.close();
try {
clientSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

}

Loading…
Cancel
Save