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
lancarjodoh
IF3230-Tugas-Besar-Sister-2015
Commits
5490422f
Commit
5490422f
authored
Apr 26, 2015
by
mamat-rahmat
Browse files
hubungan sama server lain masih ngebug
parent
757b459a
Changes
2
Hide whitespace changes
Inline
Side-by-side
bin/server/mainserver_thread_v2.py
View file @
5490422f
...
...
@@ -402,9 +402,6 @@ def handler(a, c):
response
=
str
(
dictResponse
)
elif
(
method
==
"sendfind"
):
## TODO : AMBIL DARI SEMUA SERVER, TAMBAH PENGECUALIAN DARI SENDIRI
token
=
dataJSON
[
"token"
]
item
=
dataJSON
[
"item"
]
kriteria1Object
=
{
"offered_item"
:
item
}
...
...
@@ -520,8 +517,25 @@ def handler(a, c):
response
=
"{'status' : 'ok'}"
else
:
kriteria2Object
=
{
"offer_token"
:
offer_token
}
response
=
"{'status' : 'fail', 'description' : 'not exists'}"
#kirim accept offer ke server lain
for
server
in
listActiveServer
:
if
(
server
[
"ip"
]
!=
hostLaptop
):
print
(
server
[
"ip"
],
server
[
"port"
])
s2
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s2
.
connect
((
server
[
"ip"
],
server
[
"port"
]))
message
=
'{ "method" : "accept", "offer_token" : "'
+
offer_token
+
'"}'
print
(
message
)
s2
.
send
(
str
.
encode
(
message
))
tm
=
s2
.
recv
(
4096
)
tmString
=
tm
.
decode
(
"utf-8"
)
print
(
tmString
)
tmJSON
=
json
.
JSONDecoder
().
decode
(
tmString
)
if
(
tmJSON
[
"status"
]
==
"ok"
):
response
=
"{'status' : 'ok'}"
else
:
response
=
"{'status' : 'fail', 'description' : 'not exists'}"
elif
(
method
==
'accept'
):
offer_token
=
dataJSON
[
'offer_token'
]
...
...
bin/server/map
View file @
5490422f
{
"name": "lima",
"width": 5,
"height": 5,
"map": [
[
4,
8
,
4
,
8
,
6
,
3
,
5
,
8
],
[
7
,
4
,
1
,
6
,
5,
9
,
3
8
,
9
],
[
2,
1,
8,
6,
0,
8,
5
7,
9
],
[
0,
7,
7,
6,
9,
7
1,
2
],
[
4,
8,
7,
1,
9
,
5
5
,
1
]
]
],
"name": "hihi",
"height": 5
}
\ No newline at end of file
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