Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stephen
IF3230-Tugas-Besar-Sister-2015
Commits
146cdc31
Commit
146cdc31
authored
Apr 23, 2015
by
Stephen
Browse files
Updated
parent
d598baae
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/client/build/classes/tcpclient/TCPClient.class
View file @
146cdc31
No preview for this file type
src/client/nbproject/private/private.properties
View file @
146cdc31
compile.on.save
=
true
user.properties.file
=
C:
\\
Users
\\
user
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
user.properties.file
=
C:
\\
Users
\\
Stephen
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
.2
\\
build.properties
src/client/src/tcpclient/TCPClient.java
View file @
146cdc31
...
...
@@ -802,11 +802,11 @@ public class TCPClient {
response
=
client
.
offer
(
client
.
token
,
2
,
1
,
7
,
3
);
System
.
out
.
println
(
response
.
toString
());
// response = client.sendFind(client.token, 2);
// System.out.println(response.toString());
response
=
client
.
findoffer
(
2
);
response
=
client
.
sendFind
(
client
.
token
,
2
);
System
.
out
.
println
(
response
.
toString
());
// response = client.findoffer(2);
// System.out.println(response.toString());
}
}
src/server/build/classes/tcpserver/MySQLAccess.class
View file @
146cdc31
No preview for this file type
src/server/build/classes/tcpserver/TCPServer.class
View file @
146cdc31
No preview for this file type
src/server/nbproject/private/private.properties
View file @
146cdc31
compile.on.save
=
true
user.properties.file
=
C:
\\
Users
\\
user
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
user.properties.file
=
C:
\\
Users
\\
Stephen
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
.2
\\
build.properties
src/server/src/tcpserver/MySQLAccess.java
View file @
146cdc31
...
...
@@ -618,7 +618,8 @@ public class MySQLAccess {
JSONArray
offers
=
new
JSONArray
();
try
{
preparedStatement
=
connect
.
prepareStatement
(
"SELECT * FROM offer WHERE "
+
"offered_item="
+
id_item
+
";"
);
+
"offered_item="
+
id_item
+
" AND "
+
"id_user=0;"
);
resultSet
=
preparedStatement
.
executeQuery
();
while
(
resultSet
.
next
())
{
...
...
src/server/src/tcpserver/TCPServer.java
View file @
146cdc31
...
...
@@ -39,7 +39,7 @@ public class TCPServer implements Runnable {
serverPort
=
6789
;
serverClientSocket
=
new
ServerSocket
(
serverPort
);
servers
=
new
ArrayList
<
Host
>();
thisIP
=
"167.205.
34.209
"
;
thisIP
=
"167.205.
71.56
"
;
sql
=
new
MySQLAccess
();
}
...
...
@@ -273,9 +273,15 @@ public class TCPServer implements Runnable {
public
boolean
moreThan5Minutes
(
String
d1
,
String
d2
)
{
boolean
more
=
false
;
String
[]
d1split
=
d1
.
split
(
":"
);
String
[]
d2split
=
d2
.
split
(
":"
);
int
totalSec1
=
Integer
.
parseInt
(
d1split
[
0
])*
3600
+
Integer
.
parseInt
(
d1split
[
1
])*
60
+
Integer
.
parseInt
(
d1split
[
2
]);
int
totalSec2
=
Integer
.
parseInt
(
d2split
[
0
])*
3600
+
Integer
.
parseInt
(
d2split
[
1
])*
60
+
Integer
.
parseInt
(
d2split
[
2
]);
if
((
totalSec1
-
totalSec2
)
>
300
)
{
more
=
true
;
}
return
more
;
}
...
...
@@ -292,7 +298,7 @@ public class TCPServer implements Runnable {
findOfferTime
=
dateFormat
.
format
(
date
);
}
if
(
firsttime
||
moreThan5Minutes
(
findOfferTime
,
cur
rTime
))
{
if
(
firsttime
||
moreThan5Minutes
(
currTime
,
findOffe
rTime
))
{
JSONObject
responseJSON
=
new
JSONObject
();
responseJSON
.
put
(
"status"
,
"ok"
);
JSONArray
offers
=
new
JSONArray
();
...
...
@@ -385,7 +391,7 @@ public class TCPServer implements Runnable {
}
}
public
boolean
isJSONValid
(
String
test
)
{
public
static
boolean
isJSONValid
(
String
test
)
{
try
{
new
JSONObject
(
test
);
}
catch
(
JSONException
ex
)
{
...
...
@@ -422,7 +428,7 @@ public class TCPServer implements Runnable {
System
.
out
.
println
(
"Received: "
+
server
.
clientRequest
+
"aaaaaaa"
);
if
(!
server
.
clientRequest
.
equalsIgnoreCase
(
""
)
&&
server
.
isJSONValid
(
server
.
clientRequest
))
{
if
(!
server
.
clientRequest
.
equalsIgnoreCase
(
""
)
&&
isJSONValid
(
server
.
clientRequest
))
{
// Mementuk JSON Object dari request client
JSONObject
clientObject
=
new
JSONObject
(
server
.
clientRequest
);
String
method
=
clientObject
.
getString
(
"method"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment