@@ -41,21 +41,23 @@ class Settings(BaseSettings):
4141rooms_sid = {}
4242names_sid = {}
4343
44-
4544### elk, kibana
46- es = Elasticsearch (f'{ ES_IP } :{ ES_PORT } ' ) ## 변경
45+ es = Elasticsearch (f'{ ES_IP } :{ ES_PORT } ' ) ## 변경
4746es .info ()
4847
4948
50- def utc_time ():
49+ def utc_time ():
5150 return datetime .datetime .utcnow ().strftime ('%Y-%m-%dT%H:%M:%S.%f' )[:- 3 ] + 'Z'
5251
52+
5353def make_index (es , index_name ):
5454 if es .indices .exists (index = index_name ):
5555 es .indices .delete (index = index_name )
5656 es .indices .create (index = index_name )
5757
58- index_name = 'webrtc_room'
58+
59+ index_name = 'webrtc_room'
60+
5961
6062@app .route ('/' )
6163def hello ():
@@ -79,12 +81,11 @@ def on_create_room(data):
7981
8082 emit ("join-request" )
8183
82-
8384 # elk
8485 room_id = data ["room_id" ]
8586 date = datetime .datetime .now ()
8687 now = date .strftime ('%m/%d/%y %H:%M:%S' )
87- doc_create = {"des" :"create room" , "room_id" :room_id , "@timestamp" : utc_time ()}
88+ doc_create = {"des" : "create room" , "room_id" : room_id , "@timestamp" : utc_time ()}
8889 es .index (index = index_name , doc_type = "log" , body = doc_create )
8990
9091
@@ -114,7 +115,7 @@ def on_join_room(data):
114115 ### elk
115116 date = datetime .datetime .now ()
116117 now = date .strftime ('%m/%d/%y %H:%M:%S' )
117- doc_join = {"des" :"New member joined" , "room_id" :room_id , "sid" : sid , "@timestamp" : utc_time ()}
118+ doc_join = {"des" : "New member joined" , "room_id" : room_id , "sid" : sid , "@timestamp" : utc_time ()}
118119 es .index (index = index_name , doc_type = "log" , body = doc_join )
119120 emit ("user-connect" , {"sid" : sid , "name" : display_name }, broadcast = True , include_self = False , room = room_id )
120121
@@ -154,7 +155,7 @@ def on_join_room(data):
154155 print (key )
155156 print (users_in_room [key ])
156157 if users_in_room [key ] is display_name :
157- del ( usrlist [ sid ])
158+ del users_in_room [ key ]
158159 emit ("user-list" , {"list" : usrlist , "my_id" : sid })
159160
160161 # print("\n users: ", users_in_room, "\n")
@@ -169,7 +170,7 @@ def on_disconnect():
169170 ### elk
170171 now = datetime .datetime .now ()
171172 now = now .strftime ('%m/%d/%y %H:%M:%S' )
172- doc_disconnect = {"des" :"user-disconnect" , "room_id" :room_id , "sid" : sid , "@timestamp" : utc_time ()}
173+ doc_disconnect = {"des" : "user-disconnect" , "room_id" : room_id , "sid" : sid , "@timestamp" : utc_time ()}
173174 es .index (index = index_name , doc_type = "log" , body = doc_disconnect )
174175
175176 print ("[{}] Member left: {}<{}>" .format (room_id , display_name , sid ))
@@ -222,20 +223,18 @@ def send_message(message):
222223 # doc_chatting= {"des" : "chatting", "room_id" : room_id, "chatting message" : text,"@timestamp": utc_time()}
223224 # es.index(index=index_name, doc_type="log", body=doc_chatting)
224225
225-
226226 date = datetime .datetime .now ()
227227 now = date .strftime ('%m/%d/%y %H:%M:%S' )
228- doc_chatting = {"des" : "chatting" , "room_id" : room_id , "chatting message" : text ,"@timestamp" : utc_time ()}
228+ doc_chatting = {"des" : "chatting" , "room_id" : room_id , "chatting message" : text , "@timestamp" : utc_time ()}
229229 es .index (index = index_name , doc_type = "log" , body = doc_chatting )
230-
231230
232231 data = {
233232 "text" : text ,
234233 "room_id" : room_id ,
235234 "sender" : sender ,
236235 "type" : "normal" ,
237- "direct" : False , # react에서 dm인지 아닌지 확인할 수 있는 필드
238- "target" : "self"
236+ "direct" : False , # react에서 dm인지 아닌지 확인할 수 있는 필드
237+ "target" : "self"
239238 }
240239
241240 # front로부터 받은 data에 direct라는 필드가 있고 false 값이라면 브로드캐스팅을 하고
0 commit comments