I am facing an unexpected weird issue. It could be lack of my understanding of autobahn or I am missing something for sure.
Writing a server using Autobahn for simple web socket (not WAMP).
I have multiple classes in my server, the three main classes are:
ClientManager class # suppose to have client instance (one instance means one client) this class is sub class of WebSocketServerProtocol class. and all onConnect, onOpen and onMessage functions are there. on connect and disconnect clients, I am registering and unregistering client (self.factory.unregister(self)) the register and unregister methods are in SocketManager class. this class also have two properties self.id and self.groups (self.groups = ), where I want to keep per client id and joined groups name. Clients (JS) can join different groups, at joining groups I append group name in ClientManager class groups property (self.groups.append(groupName)).
SocketManager class # Suppose to have server instance, so If I create two web socket servers on two different port like (9000 and 9200) then there will be two instance of SocketManager class. This class is sub class of WebSocketServerFactory class. In this class I am keeping the methods to send message to all clients and all.
ServerManager class # this is not much doing but creating instance of SocketManager class to create servers, current only one at 9000.
in class ServerManager there is nothing much than this method:
port = 9000
ws = WSManager(“ws://localhost:%d” % port, debug=True)
ws.protocol = ClientManager
The issue I am facing is: When I am adding (appending) an group name in group array for x client, some how it’s also adding in all other clients groups array. I want unique / different group arrays for each client.
Can any one tell me what is wrong I am doing in this. Incase I didn’t explain it correctly let me know what I am missing to make it more clear.