Skip to content

Commit f2b06f2

Browse files
committed
edit json format
1 parent f4456b1 commit f2b06f2

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

.idea/workspace.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Server.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ def on_join_room(data):
105105
# es.index(index=index_name, doc_type="log", body=doc_join)
106106
emit("user-connect", {"sid": sid, "name": display_name}, broadcast=True, include_self=False, room=room_id)
107107

108-
message = json.dumps({
108+
message = {
109109
"text": f'{display_name}님이 접속하셨습니다.',
110110
'type': "join"
111-
})
111+
}
112112
emit("chatting", message, broadcast=True, include_self=True, room=room_id)
113113
# broadcasting시 동일한 네임스페이스에 연결된 모든 클라이언트에게 메시지를 송신함
114114
# include_self=False 이므로 본인을 제외하고 broadcasting
@@ -143,10 +143,10 @@ def on_disconnect():
143143
# es.index(index=index_name, doc_type="log", body=doc_disconnect)
144144

145145
print("[{}] Member left: {}<{}>".format(room_id, display_name, sid))
146-
message = json.dumps({
146+
message = {
147147
"text": f'{display_name} 님이 나갔습니다.',
148148
'type': "disconnect"
149-
})
149+
}
150150
emit("chatting", message, broadcast=True, include_self=True, room=room_id)
151151

152152
emit("user-disconnect", {"sid": sid}, broadcast=True, include_self=False, room=room_id)
@@ -190,12 +190,12 @@ def send_message(message):
190190
# now = date.strftime('%m/%d/%y %H:%M:%S')
191191
# doc_chatting= {"des" : "chatting", "room_id" : room_id, "chatting message" : text,"@timestamp": utc_time()}
192192
# es.index(index=index_name, doc_type="log", body=doc_chatting)
193-
data = json.dumps({
193+
data = {
194194
"text": text,
195-
"room_id":room_id,
195+
"room_id": room_id,
196196
"sender": sender,
197197
"type": "normal"
198-
})
198+
}
199199
# broadcast to others in the room
200200
emit("chatting", data, broadcast=True, include_self=True, room=room_id)
201201
print("emit chatting event")

0 commit comments

Comments
 (0)