def main(): threads = [] # ana soket oluşturuluyor ve hangi iplerden bağlantı kabul edileceği, port numarası bilgileri giriliyor.. mySocket = socket.socket() # Create a socket object host = "0.0.0.0" # Accesible by all of the network port = yay.SERVER_PORT mySocket.bind((host, port)) # Bind to the port mySocket.listen(5) # Now wait for client connection, # with 5 queued connections at most logQueue = queue.Queue() exitFlag = False Logger = yay.loggerThread("Logger", "log.txt", logQueue, exitFlag) Logger.start() userInputThread = yay.UserInputThread("User Input Thread", logQueue) userInputThread.start() arayUz = ArayuzThread("Arayüz Thread", logQueue) arayUz.start() # for i in range(2): while True: try: log = "Waiting for connection from any client via port number " + str( port) logQueue.put(time.ctime() + "\t\t - " + log) print("Waiting for connection from any client via port number ", port) c, addr = mySocket.accept( ) # Establish connection with client. #blocking fonksiyon#c=soket,addr =adress of client log = "Got connection from " + str(addr) logQueue.put(time.ctime() + "\t\t - " + log) print('Got connection from', addr) serverThread = yay.ServerThread("Server Thread", c, yay.myUUID, yay.SERVER_HOST, yay.SERVER_PORT, yay.TYPE, logQueue, exitFlag) serverThread.start() threads.append(serverThread) except KeyboardInterrupt: break # clientThread = ClientThread("Client Thread") # clientThread.start() # threads.append(clientThread) for t in threads: t.join()
def sendMyBlog(self): request = "SBLOG:" + self.ui.username_field.text( ) + ": " + self.ui.Twit_field.toPlainText() + "\n" myClient = yay.ClientThread("Client Thread", self.ip, self.port, request, self.logQueue) response = myClient.control() self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")
def pubkey_button(self): # pubkey buttonuna basıldığında gerçekleştirilecek eylem request="PBKEY:"+"BUNUIMZALA" # myClient = yay.ClientThread("Client Thread", self.UUIDtoConnect ,self.ip, self.port, request, self.logQueue) myClient = yay.ClientThread("Client Thread", self.ip, self.port, request, self.logQueue) response = myClient.control() self.ui.LogLabel_field.setText("XXX"+response+"XXX")
def users_button(self): # LSUSR komutu uygulanan metot suggest_checkboxlist = [] usernamelist = [] request="LSUSR" myClient = yay.ClientThread("Client Thread", self.ip, self.port, request, self.logQueue) response = myClient.control() self.ui.LogLabel_field.setText("XXX"+response+"XXX") users = response[6:].split("$") i=0; userList=dict() for u in users: print(u) x=u.split(",") userList[x[0]] = [ x[1],x[2],x[3],x[4], None ] suggest_checkboxlist.append(userList[x[0]]) usernamelist.append(x[3]) suggest_checkboxlist.append(self.ui.sugchbx1) self.ui.sugchbx1.setText(usernamelist[0]) suggest_checkboxlist.append(self.ui.sugchbx2) self.ui.sugchbx2.setText(usernamelist[1]) suggest_checkboxlist.append(self.ui.sugchbx3) self.ui.sugchbx3.setText(usernamelist[2]) suggest_checkboxlist.append(self.ui.sugchbx4) self.ui.sugchbx4.setText(usernamelist[3]) suggest_checkboxlist.append(self.ui.sugchbx5) self.ui.sugchbx5.setText(usernamelist[4])
def logout_button(self): # logout ui kapatma olarak tasarlanmıştır. ileride connection close olarak değiştirilebilir # self.close() request = "PBKEY:" + "BUNUIMZALA" myClient = yay.ClientThread("Client Thread", self.ip, self.port, request, self.logQueue) response = myClient.control() self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")
def get_host_with_port(self): # ip ve port alma işlemi self.ip = self.ui.ip_field.text() self.port = self.ui.port_field.text() #self.name = self.ui.username_field.text() self.UUID ="AraciUUID" yay.userInfoDict[self.UUID]=[ self.ip,self.port,"ARACIname","NEGOTIATOR", None ] with open('../Yayinci_Blogger/data.json', 'w') as fp: json.dump(yay.userInfoDict, fp) name=self.ui.username_field.text() request="UINFO" myClient=yay.ClientThread("Client Thread", self.ip, self.port, request, self.logQueue) response=myClient.control() self.ui.LogLabel_field.setText("XXX" + response + "XXX")