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
805d5733
Commit
805d5733
authored
Apr 24, 2015
by
Stephen
Browse files
Redesigned Login form
parent
ce5a2b11
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/client/src/tcpclient/LoginPanel.java
0 → 100644
View file @
805d5733
package
tcpclient
;
import
java.awt.Graphics
;
import
java.awt.Image
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
javax.imageio.ImageIO
;
import
javax.swing.ImageIcon
;
import
javax.swing.JPanel
;
public
class
LoginPanel
extends
JPanel
{
private
Image
img
;
public
LoginPanel
()
{
// load the background image
try
{
img
=
ImageIO
.
read
(
getClass
().
getResource
(
"images/login.png"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Override
protected
void
paintComponent
(
Graphics
g
)
{
super
.
paintComponent
(
g
);
g
.
drawImage
(
img
,
0
,
0
,
getWidth
(),
getHeight
(),
this
);
}
}
src/client/src/tcpclient/MainPage.form
View file @
805d5733
...
...
@@ -287,7 +287,7 @@
</Group>
<EmptySpace
min=
"-2"
pref=
"45"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"connectButton"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
pref=
"246"
max=
"32767"
attributes=
"0"
/>
<EmptySpace
max=
"32767"
attributes=
"0"
/>
</Group>
</Group>
</DimensionLayout>
...
...
@@ -345,21 +345,28 @@
<Component
id=
"loginButton"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
alignment=
"0"
attributes=
"0"
>
<EmptySpace
min=
"-2"
pref=
"161"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"loginLabel"
min=
"-2"
pref=
"60"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
min=
"-2"
pref=
"52"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Component
id=
"usernameLoginLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"passwordLoginLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"-2"
pref=
"161"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"loginLabel"
min=
"-2"
pref=
"60"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
min=
"-2"
pref=
"175"
max=
"-2"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
alignment=
"1"
attributes=
"0"
>
<EmptySpace
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"1"
attributes=
"0"
>
<Component
id=
"jLabel3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"jLabel2"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
min=
"-2"
pref=
"110"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
<EmptySpace
min=
"-2"
pref=
"75"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
max=
"-2"
attributes=
"0"
>
<Component
id=
"passwordLoginField"
max=
"32767"
attributes=
"0"
/>
<Component
id=
"usernameLoginTextField"
min=
"-2"
pref=
"151"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
</Group>
<EmptySpace
max=
"32767"
attributes=
"0"
/>
<EmptySpace
pref=
"361"
max=
"32767"
attributes=
"0"
/>
</Group>
</Group>
</DimensionLayout>
...
...
@@ -369,14 +376,14 @@
<EmptySpace
min=
"-2"
pref=
"90"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"loginLabel"
min=
"-2"
pref=
"25"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
type=
"separate"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"
0
"
attributes=
"0"
>
<Component
id=
"usernameLoginTextField"
alignment=
"1"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"
usernameLogin
Label"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"
1
"
attributes=
"0"
>
<Component
id=
"usernameLoginTextField"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"
j
Label
2
"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
type=
"separate"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"3"
attributes=
"0"
>
<Component
id=
"passwordLoginLabel"
alignment=
"3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"passwordLoginField"
alignment=
"3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"jLabel3"
alignment=
"3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
min=
"-2"
pref=
"36"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"loginButton"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
...
...
@@ -391,16 +398,6 @@
<Property
name=
"text"
type=
"java.lang.String"
value=
"LOGIN"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"usernameLoginLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Username"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"passwordLoginLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Password"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JTextField"
name=
"usernameLoginTextField"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"ayam"
/>
...
...
@@ -422,6 +419,16 @@
<EventHandler
event=
"actionPerformed"
listener=
"java.awt.event.ActionListener"
parameters=
"java.awt.event.ActionEvent"
handler=
"loginButtonActionPerformed"
/>
</Events>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"jLabel2"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Username"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"jLabel3"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Password"
/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container
class=
"javax.swing.JPanel"
name=
"registerPanel"
>
...
...
src/client/src/tcpclient/MainPage.java
View file @
805d5733
...
...
@@ -3,6 +3,7 @@ package tcpclient;
import
java.applet.Applet
;
import
java.awt.CardLayout
;
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Image
;
import
java.awt.event.ActionEvent
;
...
...
@@ -28,6 +29,7 @@ import javax.swing.Icon;
import
javax.swing.ImageIcon
;
import
javax.swing.JButton
;
import
javax.swing.JCheckBox
;
import
javax.swing.JLabel
;
import
javax.swing.JOptionPane
;
import
javax.swing.JScrollPane
;
import
javax.swing.JTable
;
...
...
@@ -66,9 +68,9 @@ public class MainPage extends javax.swing.JFrame {
mapModel
=
new
MapTableModel
();
tradeboxModel
=
new
TradeboxTableModel
();
initComponents
();
//mapTable
MenuPanel
.
setVisible
(
false
);
settingPanel
.
setSize
(
this
.
getSize
());
}
/**
...
...
@@ -100,13 +102,13 @@ public class MainPage extends javax.swing.JFrame {
portTextField
=
new
javax
.
swing
.
JTextField
();
connectButton
=
new
javax
.
swing
.
JButton
();
serverLabel
=
new
javax
.
swing
.
JLabel
();
loginPanel
=
new
javax
.
swing
.
J
Panel
();
loginPanel
=
new
Login
Panel
();
loginLabel
=
new
javax
.
swing
.
JLabel
();
usernameLoginLabel
=
new
javax
.
swing
.
JLabel
();
passwordLoginLabel
=
new
javax
.
swing
.
JLabel
();
usernameLoginTextField
=
new
javax
.
swing
.
JTextField
();
passwordLoginField
=
new
javax
.
swing
.
JPasswordField
();
loginButton
=
new
javax
.
swing
.
JButton
();
jLabel2
=
new
javax
.
swing
.
JLabel
();
jLabel3
=
new
javax
.
swing
.
JLabel
();
registerPanel
=
new
javax
.
swing
.
JPanel
();
registerLabel
=
new
javax
.
swing
.
JLabel
();
usernameRegisterLabel
=
new
javax
.
swing
.
JLabel
();
...
...
@@ -415,17 +417,13 @@ public class MainPage extends javax.swing.JFrame {
.
addComponent
(
portTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)))
.
addGap
(
45
,
45
,
45
)
.
addComponent
(
connectButton
)
.
addContainerGap
(
246
,
Short
.
MAX_VALUE
))
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
);
MainPanel
.
add
(
settingPanel
,
"SettingCard"
);
loginLabel
.
setText
(
"LOGIN"
);
usernameLoginLabel
.
setText
(
"Username"
);
passwordLoginLabel
.
setText
(
"Password"
);
usernameLoginTextField
.
setText
(
"ayam"
);
passwordLoginField
.
setText
(
"ayam"
);
...
...
@@ -442,6 +440,10 @@ public class MainPage extends javax.swing.JFrame {
}
});
jLabel2
.
setText
(
"Username"
);
jLabel3
.
setText
(
"Password"
);
javax
.
swing
.
GroupLayout
loginPanelLayout
=
new
javax
.
swing
.
GroupLayout
(
loginPanel
);
loginPanel
.
setLayout
(
loginPanelLayout
);
loginPanelLayout
.
setHorizontalGroup
(
...
...
@@ -452,17 +454,21 @@ public class MainPage extends javax.swing.JFrame {
.
addGap
(
444
,
444
,
444
)
.
addComponent
(
loginButton
))
.
addGroup
(
loginPanelLayout
.
createSequentialGroup
()
.
addGap
(
161
,
161
,
161
)
.
addComponent
(
loginLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
60
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
52
,
52
,
52
)
.
addGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
usernameLoginLabel
)
.
addComponent
(
passwordLoginLabel
))
.
addGap
(
75
,
75
,
75
)
.
addGroup
(
loginPanelLayout
.
createSequentialGroup
()
.
addGap
(
161
,
161
,
161
)
.
addComponent
(
loginLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
60
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
175
,
175
,
175
))
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
loginPanelLayout
.
createSequentialGroup
()
.
addContainerGap
()
.
addGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
)
.
addComponent
(
jLabel3
)
.
addComponent
(
jLabel2
))
.
addGap
(
110
,
110
,
110
)))
.
addGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
false
)
.
addComponent
(
passwordLoginField
)
.
addComponent
(
usernameLoginTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
151
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))))
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
.
addContainerGap
(
361
,
Short
.
MAX_VALUE
))
);
loginPanelLayout
.
setVerticalGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
...
...
@@ -470,13 +476,13 @@ public class MainPage extends javax.swing.JFrame {
.
addGap
(
90
,
90
,
90
)
.
addComponent
(
loginLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
25
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
18
,
18
,
18
)
.
addGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEAD
ING
)
.
addComponent
(
usernameLoginTextField
,
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
usernameLogin
Label
))
.
addGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAIL
ING
)
.
addComponent
(
usernameLoginTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
j
Label
2
))
.
addGap
(
18
,
18
,
18
)
.
addGroup
(
loginPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
BASELINE
)
.
addComponent
(
passwordLogin
Label
)
.
addComponent
(
passwordLoginField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addComponent
(
passwordLogin
Field
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
jLabel3
))
.
addGap
(
36
,
36
,
36
)
.
addComponent
(
loginButton
)
.
addContainerGap
(
290
,
Short
.
MAX_VALUE
))
...
...
@@ -1548,8 +1554,7 @@ public class MainPage extends javax.swing.JFrame {
GemsIcon
.
setText
(
InventoryList
.
getString
(
6
));
LifeElixirIcon
.
setText
(
InventoryList
.
getString
(
7
));
ManaCrystalIcon
.
setText
(
InventoryList
.
getString
(
8
));
StoneIcon
.
setText
(
InventoryList
.
getString
(
9
));
StoneIcon
.
setText
(
InventoryList
.
getString
(
9
));
}
else
{
showMessage
(
response
.
getString
(
"status"
));
...
...
@@ -2531,6 +2536,8 @@ public class MainPage extends javax.swing.JFrame {
private
javax
.
swing
.
JLabel
ipaddressLabel
;
private
javax
.
swing
.
JTextField
ipaddressTextField
;
private
javax
.
swing
.
JLabel
jLabel1
;
private
javax
.
swing
.
JLabel
jLabel2
;
private
javax
.
swing
.
JLabel
jLabel3
;
private
javax
.
swing
.
JButton
loginButton
;
private
javax
.
swing
.
JLabel
loginLabel
;
private
javax
.
swing
.
JPanel
loginPanel
;
...
...
@@ -2542,7 +2549,6 @@ public class MainPage extends javax.swing.JFrame {
private
javax
.
swing
.
JButton
moveButton
;
private
javax
.
swing
.
JPanel
offerPanel
;
private
javax
.
swing
.
JPasswordField
passwordLoginField
;
private
javax
.
swing
.
JLabel
passwordLoginLabel
;
private
javax
.
swing
.
JPasswordField
passwordRegisterField
;
private
javax
.
swing
.
JLabel
passwordRegisterLabel
;
private
javax
.
swing
.
JPanel
playerPanel
;
...
...
@@ -2561,7 +2567,6 @@ public class MainPage extends javax.swing.JFrame {
private
javax
.
swing
.
JScrollPane
tradeboxScrollPane
;
private
javax
.
swing
.
JTable
tradeboxTable
;
private
javax
.
swing
.
JPanel
tradeitemPanel
;
private
javax
.
swing
.
JLabel
usernameLoginLabel
;
private
javax
.
swing
.
JTextField
usernameLoginTextField
;
private
javax
.
swing
.
JLabel
usernameRegisterLabel
;
private
javax
.
swing
.
JTextField
usernameRegisterTextField
;
...
...
src/client/src/tcpclient/images/login.png
0 → 100644
View file @
805d5733
59.4 KB
src/server/build/built-jar.properties
View file @
805d5733
#
Wed
, 2
2
Apr 2015 1
6:28:23
+0700
#
Fri
, 2
4
Apr 2015 1
5:40:37
+0700
C\:\\Users\\Stephen\\Documents\\NetBeansProjects\\TubesSister\\src\\
server
=
src/server/build/classes/tcpserver/TCPServer.class
View file @
805d5733
No preview for this file type
src/server/dist/TCPServer.jar
View file @
805d5733
No preview for this file type
src/server/src/tcpserver/TCPServer.java
View file @
805d5733
...
...
@@ -442,91 +442,95 @@ public class TCPServer implements Runnable {
// Membaca request dari client
DataOutputStream
outToClient
=
new
DataOutputStream
(
server
.
clientSocket
.
getOutputStream
());
DataInputStream
inFromClient
=
new
DataInputStream
(
server
.
clientSocket
.
getInputStream
());
byte
b
[]
=
new
byte
[
4096
];
inFromClient
.
read
(
b
);
server
.
clientRequest
=
new
String
(
b
,
"UTF-8"
);
System
.
out
.
println
(
"Received: "
+
server
.
clientRequest
+
"aaaaaaa"
);
if
(!
server
.
clientRequest
.
equalsIgnoreCase
(
""
)
&&
isJSONValid
(
server
.
clientRequest
))
{
// Mementuk JSON Object dari request client
JSONObject
clientObject
=
new
JSONObject
(
server
.
clientRequest
);
String
method
=
clientObject
.
getString
(
"method"
);
try
{
byte
b
[]
=
new
byte
[
4096
];
inFromClient
.
read
(
b
);
server
.
clientRequest
=
new
String
(
b
,
"UTF-8"
);
if
(
method
.
equalsIgnoreCase
(
"signup"
))
{
// Jika method request adalah "signup"
JSONObject
responseJSON
=
server
.
signup
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
if
(
responseJSON
.
getString
(
"status"
).
equalsIgnoreCase
(
"ok"
))
{
server
.
sql
.
createInventory
(
clientObject
.
getString
(
"username"
));
}
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"login"
))
{
// Jika method request adalah "login"
JSONObject
responseJSON
=
server
.
login
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
if
(
responseJSON
.
getString
(
"status"
).
equalsIgnoreCase
(
"ok"
))
{
server
.
userID
=
server
.
sql
.
getUserId
(
clientObject
.
getString
(
"username"
));
server
.
token
=
responseJSON
.
getString
(
"token"
);
System
.
out
.
println
(
"ID : "
+
server
.
userID
);
System
.
out
.
println
(
"token : "
+
server
.
token
);
System
.
out
.
println
(
"Received: "
+
server
.
clientRequest
+
"aaaaaaa"
);
if
(!
server
.
clientRequest
.
equalsIgnoreCase
(
""
)
&&
isJSONValid
(
server
.
clientRequest
))
{
// Mementuk JSON Object dari request client
JSONObject
clientObject
=
new
JSONObject
(
server
.
clientRequest
);
String
method
=
clientObject
.
getString
(
"method"
);
if
(
method
.
equalsIgnoreCase
(
"signup"
))
{
// Jika method request adalah "signup"
JSONObject
responseJSON
=
server
.
signup
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
if
(
responseJSON
.
getString
(
"status"
).
equalsIgnoreCase
(
"ok"
))
{
server
.
sql
.
createInventory
(
clientObject
.
getString
(
"username"
));
}
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"login"
))
{
// Jika method request adalah "login"
JSONObject
responseJSON
=
server
.
login
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
if
(
responseJSON
.
getString
(
"status"
).
equalsIgnoreCase
(
"ok"
))
{
server
.
userID
=
server
.
sql
.
getUserId
(
clientObject
.
getString
(
"username"
));
server
.
token
=
responseJSON
.
getString
(
"token"
);
System
.
out
.
println
(
"ID : "
+
server
.
userID
);
System
.
out
.
println
(
"token : "
+
server
.
token
);
}
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"inventory"
))
{
JSONObject
responseJSON
=
server
.
inventory
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"mixitem"
))
{
JSONObject
responseJSON
=
server
.
mixitem
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"map"
))
{
JSONObject
responseJSON
=
server
.
map
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"move"
))
{
JSONObject
responseJSON
=
server
.
move
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"field"
))
{
JSONObject
responseJSON
=
server
.
field
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"offer"
))
{
JSONObject
responseJSON
=
server
.
offer
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"canceloffer"
))
{
JSONObject
responseJSON
=
server
.
canceloffer
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"tradebox"
))
{
JSONObject
responseJSON
=
server
.
tradebox
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"fetchitem"
))
{
JSONObject
responseJSON
=
server
.
fetchitem
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"findoffer"
))
{
JSONObject
responseJSON
=
server
.
findoffer
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"sendfind"
))
{
JSONObject
responseJSON
=
server
.
sendfind
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"accept"
))
{
JSONObject
responseJSON
=
server
.
accept
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"sendaccept"
))
{
JSONObject
responseJSON
=
server
.
sendaccept
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"serverStatus"
))
{
JSONObject
responseJSON
=
server
.
serverstatus
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"inventory"
))
{
JSONObject
responseJSON
=
server
.
inventory
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"mixitem"
))
{
JSONObject
responseJSON
=
server
.
mixitem
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"map"
))
{
JSONObject
responseJSON
=
server
.
map
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"move"
))
{
JSONObject
responseJSON
=
server
.
move
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"field"
))
{
JSONObject
responseJSON
=
server
.
field
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"offer"
))
{
JSONObject
responseJSON
=
server
.
offer
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"canceloffer"
))
{
JSONObject
responseJSON
=
server
.
canceloffer
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"tradebox"
))
{
JSONObject
responseJSON
=
server
.
tradebox
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"fetchitem"
))
{
JSONObject
responseJSON
=
server
.
fetchitem
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"findoffer"
))
{
JSONObject
responseJSON
=
server
.
findoffer
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"sendfind"
))
{
JSONObject
responseJSON
=
server
.
sendfind
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"accept"
))
{
JSONObject
responseJSON
=
server
.
accept
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"sendaccept"
))
{
JSONObject
responseJSON
=
server
.
sendaccept
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
else
if
(
method
.
equalsIgnoreCase
(
"serverStatus"
))
{
JSONObject
responseJSON
=
server
.
serverstatus
(
clientObject
);
System
.
out
.
println
(
"Sent: "
+
responseJSON
.
toString
());
outToClient
.
write
(
responseJSON
.
toString
().
getBytes
(
"UTF-8"
));
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error reading client request"
);
}
}
}
...
...
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