def sendChat(self): text = self.chatBox.get() text = text.strip(' \t\n\r') if text != '': global client # self.chatArea.config(state="normal") # self.chatArea.insert(END, text + "\n") # self.chatArea.config(state="disabled") # client.sendChat(client.s, text) client.sendMessage(text) self.chatBox.delete(0, 'end')
def menu(client, email): print(f"You have {mail.Mail.countMails()} Mail(s)") print("\nTo go to mail Box press 1\nTo send a email press 2\n") command = input() if command == '1': mail.Mail.readMailBox() elif command == '2': print("Put the destination") destination = input() print("Put the message") msg = input() client.sendMessage( f"SEND {email.getUser()} " + f"{destination:<{constant.HEADERSIZE-len(email.getUser())-len(destination)}} " + msg)
def sendData(board,user,c): writeFile(board,"arrangement2.txt") if user=="s": newBoard=makeBoard(server.Main(c)) if user=="c": newBoard=makeBoard(client.sendMessage(c)) print "data inteperated" return newBoard
def broadcast(self, message): for client in self.clients.values(): client.sendMessage(message)
def sendGreeting(self, client): client.sendMessage(toClient.GreetingMessage("Hello!"))
if '/exit' in message: # quitting the program by using /exit self.closeSocket() if '/help ' in message: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((Client.host, Client.port)) sock.send("/help") reply=sock.recv(1024) print(reply) def closeSocket(self): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((Client.host, Client.port)) print("System shutdown...") sock.close() exit(0) def shutDown(self): print("System shutdown...") exit(0) def __del__(self): self.closeSocket() import client client = Client() while 1: client.sendMessage()
def test_send_sample_msg(self): sock = initSocket('SOCK_STREAM') sock = connectNode(sock, '127.0.0.1', 9999) self.assertEqual(sendMessage(sock, "some msg"), 0)
if event.type == pygame.MOUSEMOTION: pygame.draw.rect(screen, BLACK, (0, 0, width, SQUARESIZE)) posx = event.pos[0] if turn == PLAYER: pygame.draw.circle(screen, RED, (posx, int(SQUARESIZE / 2)), RADIUS) pygame.display.update() if event.type == pygame.MOUSEBUTTONDOWN: pygame.draw.rect(screen, BLACK, (0, 0, width, SQUARESIZE)) # print(event.pos) # Ask for Player 1 Input robotMessage = captureEmotion.captureEmotion() client.sendMessage(robotMessage) if turn == PLAYER: posx = event.pos[0] col = int(math.floor(posx / SQUARESIZE)) if is_valid_location(board, col): row = get_next_open_row(board, col) drop_piece(board, row, col, PLAYER_PIECE) if winning_move(board, PLAYER_PIECE): label = myfont.render("Player 1 wins!!", 1, RED) screen.blit(label, (40, 10)) game_over = True turn += 1 turn = turn % 2