def main(): # Init motion detection and socketserver socketClient = SocketClient() motion = Motion(socketClient) #capture = Capture() # Start program motion.start() socketClient.start() #capture.start() # Wait until threads die motion.join() socketClient.join()
def main(): # Init motion detection and socketserver socketClient = SocketClient() motion = Motion(socketClient) #capture = Capture() # Start program motion.start() socketClient.start() #capture.start() # Wait until threads die motion.join() socketClient.join()
def main(): # Init socket comm socketServer = SocketServer() socketClient = SocketClient() # Start threads socketServer.start() # Always start the server before the client socketClient.start() time.sleep(1) # Allow the sockets to be setup before using them try: receivedMessages = Queue.Queue() # Init a queue to store received messages in # Send/Recv example while(True): socketClient.send("Hasse gillar kaffe \n") # VERY IMPORTANT!!!! ALWAYS PROVIDE A NEWLINE AT THE END OF THE MESSAGE OR THE RECV FUNCTION WILL NEVER STOP! time.sleep(1) # Make sure that our message has been received (Remove in real code) receivedMessages = socketServer.getMessages() handleMessages(receivedMessages) except (KeyboardInterrupt, SystemExit): raise finally: # Let threads die gracefully socketClient.kill() socketServer.kill() # Wait until threads die socketClient.join() socketServer.join()
# -*- coding: utf-8 -*- """ Created on Mon Jul 16 11:10:21 2018 @author: Sander Oosterveld """ from MainScreen import MainScreen from Widget import TextWidget, Position from SocketClient import SocketClient from queue import Queue from ConnectionWidget import ConnectionWidget q = Queue() data = {'BackgroundColour': 'white'} screen = MainScreen(q) socket = SocketClient('130.89.226.101', 51234, q, data) connectionWidget = ConnectionWidget(screen, socket.getConnectionData()) connectionWidget.make() connectionWidget.updateConnection(socket) socket.start() screen.start() socket.join()