def build_and_append_to_outbox(conn, cmd, data): """ build message using chatlib.build_message according to the protocol and append to messages_to_send """ global messages_to_send msg = chatlib.build_message(cmd, data) messages_to_send.append((conn, msg)) return
def build_and_send_message(conn, cmd, data): """ Builds a new message using chatlib, wanted cmd and message. Prints debug info, then sends it to the given socket. Paramaters: conn (socket object), cmd (str), data (str) Returns: Nothing """ full_msg = chatlib.build_message(cmd, data) conn.send(full_msg.encode())
def build_and_send_message(conn, command_code, data): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Paramaters: conn (socket object), code (str), msg (str) Returns: nothing """ message = chatlib.build_message(command_code, data) conn.send(message.encode())
def build_and_send_message(conn, code, msg): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Parameters: conn (socket object), code (str), data (str) Returns: Nothing """ msg = chatlib.build_message(code, msg) messages_to_send.append((conn, msg)) print("[SERVER] ", msg) # Debug print
def build_and_send_message(conn, code, data): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Paramaters: conn (socket object), code (str), data (str) Returns: Nothing """ protocol_msg = chatlib.build_message(code, data) # print('DEBUG_MSG: build_and_send_message(' + code + ', ' + data + ') return :' + protocol_msg) conn.send(protocol_msg.encode())
def build_and_send_message(conn, cmd, data: str): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Parameters: conn (socket object), code (str), data (str) Returns: Nothing """ msg = chatlib.build_message(cmd, data) # if msg is not None: # conn.send(msg.encode()) messages_to_send.append((conn, msg))
def build_and_send_message(conn, code, data): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Paramaters: conn (socket object), code (str), data (str) Returns: Nothing """ # Implement Code msg = chatlib.build_message(code, data) conn.send(msg.encode()) #send data to server print('data sent -> command: ' + code + ' data: ' + data)
def build_and_send_message(conn, cmd, data): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Parameters: conn (socket object), code (str), data (str) Returns: Nothing """ code = chatlib.build_message(cmd, data) if code is not None: conn.send(code.encode())
def build_and_send_message(conn, cmd, data=""): """ Builds a new message using chatlib and sends it. :param conn: message destination (socket object) :param cmd: command (str) matching the protocol :param data: content (str) to be sent, may be empty ("") :return: """ msg = chatlib.build_message(cmd, data) conn.send(msg.encode()) return
def check_build(input_cmd, input_data, expected_output): print("Input: ", input_cmd, input_data, "\nExpected output: ", expected_output) try: output = chatlib.build_message(input_cmd, input_data) except Exception as e: output = "Exception raised: " + str(e) if output == expected_output: print(".....\t SUCCESS") else: print(".....\t FAILED, output: ", output)
def build_and_send_message(conn, command_code, data): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Paramaters: conn (socket object), code (str), msg (str) Returns: nothing """ global messages_to_send message = chatlib.build_message(command_code, str(data)) messages_to_send.append((conn, message.encode())) # Debug Info print("-----------------------------") print("We Sent The Client: \n" + message)
def build_and_send_message(code, data): """ Builds a new message using chatlib, wanted code and message. Prints debug info, then sends it to the given socket. Paramaters: conn (socket object), code (str), data (str) Returns: Nothing """ try: protocol_msg = chatlib.build_message(code, data) top.conn.send(protocol_msg.encode()) except ConnectionResetError: from gui import trivia trivia.vp_start_gui()
def recv_message_and_parse(conn): """ Receives a new message from given socket, then parses the message using chatlib. Parameters: conn (socket object) Returns: cmd (str) and data (str) of the received message. If error occurred, will return None, None """ try: full_msg = conn.recv(MAX_MSG_LENGTH).decode() except (ConnectionResetError, ConnectionAbortedError): full_msg = chatlib.build_message(chatlib.PROTOCOL_CLIENT['logout_msg'], '') if full_msg != '': cmd, data = chatlib.parse_message(full_msg) print(datetime.datetime.now(), '[CLIENT]', conn.getpeername(), full_msg) return cmd, data
def build_and_send_message(conn, cmd, msg): full_msg = chatlib.build_message(cmd, msg) conn.send(full_msg.encode()) print_debug_message(DEBG_MSG["server"], conn, full_msg) # Debug print
def build_and_send_message(conn, code, data): global messages_to_send full_msg = chatlib.build_message(code, data) messages_to_send.append((conn, full_msg))
def build_and_send_message(conn, code, data): msg = chatlib.build_message(code, data) t = (conn, msg) messages_to_send.append(t) print("[SERVER] ", msg)
def build_and_send_message(conn, code, data): msg = chatlib.build_message(code, data) conn.send(msg.encode())