Skip to content

Commit

Permalink
Use counter for sessid
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McGuire committed Feb 18, 2014
1 parent 239c2b7 commit fb11792
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions flask_socketio/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class TestServer(object):
def __init__(self):
self.sockets = {}

def add_socket(self, socket):
def new_socket(self):
socket = TestSocket(self, counter)
self.sockets[self.counter] = socket
self.counter += 1
return socket

def remove_socket(self, socket):
for id, s in self.sockets.items():
Expand All @@ -22,10 +24,9 @@ def remove_socket(self, socket):


class TestSocket(object):
def __init__(self, server):
import random
def __init__(self, server, sessid):
self.server = server
self.sessid = str(random.random())[2:]
self.sessid = sessid
self.namespace = {}

def __getitem__(self, ns_name):
Expand Down Expand Up @@ -68,8 +69,7 @@ class SocketIOTestClient(object):

def __init__(self, app, socketio, ns_name=None):
self.socketio = socketio
self.socket = TestSocket(self.server)
self.server.add_socket(self.socket)
self.socket = self.server.new_socket()
self.connect(app, ns_name)

def __del__(self):
Expand Down

0 comments on commit fb11792

Please sign in to comment.