Socket import sending variables help (Python)

52 Views Asked by At

So I have been working on a chat room client, except I have one problem. I have been wanting to be able to list who is online and the easiest way I would do that would be with variables. I would have a starting variable that would be for example:

OnlineClients = []

Which other clients when they join I want their client to send the variable 'OnlineClients.append(name)' to add it to the list. When they quit it should also send the command 'OnlineClients.remove(name)'. Is there any way I can do this?

This is a snippet of my code of my attempts to send variables:

#This list is important because it is used for listing who is on the chat
OnlineClients = ["Person1", "Person2", "Person3"]
ListOnline = (" ".join(OnlineClients))

#THIS IS TEST 1 FOR VARIABLE SENDING
#In future update remove own name from online list
#!to_varlist = (OnlineClients.append(name))
s.send(OnlineClients.append("Apple").encode())

#to_send = (person1 = name)
#s.send(to_send.encode())

#to_var = a = b
#s.send(to_var.encode())

#s.send(a=b.encode())
0

There are 0 best solutions below