Skip to content

Commit

Permalink
Remove un-needed code
Browse files Browse the repository at this point in the history
  • Loading branch information
Qirky committed Jan 25, 2019
1 parent 3002801 commit 81ce9b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
12 changes: 0 additions & 12 deletions src/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,6 @@ class TidalCyclesStack(TidalCycles):
TidalCycles.get_name() : TidalCycles.get_short_name(),
TidalCyclesStack.get_name() : TidalCyclesStack.get_short_name() }

# LANGUAGE_IDENT = { "foxdot" : "FoxDot",
# "tidalcycles" : "TidalCycles",
# "tidalcyclesstack" : "TidalCycles (Stack)" }

# LANGUAGE_NAMES = { "FoxDot": 0, "TidalCycles": 1, "TidalCycles (Stack)": 2 }

# LANGUAGE_ID_NUM = { }

# LANGUAGE_CLASS = { LANGUAGE_NAMES["FoxDot"] : FoxDot,
# LANGUAGE_NAMES["TidalCycles"] : TidalCycles,
# LANGUAGE_NAMES["TidalCycles (Stack)"] :TidalCyclesStack }

def get_interpreter(name):
return LANGUAGE_IDENT.get(name.lower(), None)

Expand Down
30 changes: 13 additions & 17 deletions src/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def __init__(self, interpreter, **kwargs):

# Instantiate server process

RequestHandler.set_master(self)

ThreadedServer.__init__(self, (self.listening_address, self.port), RequestHandler)

self.server_thread = Thread(target=self.serve_forever)
Expand Down Expand Up @@ -228,10 +226,6 @@ class RequestHandler(socketserver.BaseRequestHandler):
master = None
error_message = ""

@classmethod
def set_master(cls, server):
cls.master = server

def get_user_details(self):
# Get name and password

Expand All @@ -249,22 +243,24 @@ def get_user_details(self):
password = data[1]
lang_id = data[2]

if not self.master.authenticate(password):
if not self.server.authenticate(password):

raise LoginError("Failed Login - Incorrect password.")

elif not self.master.check_lang_id(lang_id):
elif not self.server.check_lang_id(lang_id):

raise LoginError("Failed Login - Incorrect interpreter. Please use '{}' to connect to the server.".format(self.master.app.lang.get_name()))
raise LoginError("Failed Login - Incorrect interpreter. Please use '{}' to connect to the server.".format(self.server.app.lang.get_name()))

self.name = username
self.user_id = self.master.add_new_client(self.client_address, self.request, self.name)
self.user_id = self.server.add_new_client(self.client_address, self.request, self.name)

return self.user_id, self.name

def handle(self):
""" Overload """

print(self.server, self.server, self.server is self.server)

try:

data = self.get_user_details()
Expand Down Expand Up @@ -299,7 +295,7 @@ def handle(self):

print("Client disconnected from {}".format(self.client_address))

self.master.remove_from_server(self.client_address)
self.server.remove_from_server(self.client_address)

break

Expand All @@ -312,7 +308,7 @@ def process_data(self, data):

# Handle on the server side

self.master.add_to_queue(data)
self.server.add_to_queue(data)

return

Expand All @@ -330,7 +326,7 @@ def handle_new_connection(self):

# Rest the seed

self.send( MESSAGE_SEED(seed=self.master.get_seed()) )
self.send( MESSAGE_SEED(seed=self.server.get_seed()) )

# Grab current code

Expand All @@ -341,26 +337,26 @@ def handle_new_connection(self):
def pull_all_code(self):
""" Sends all current codelet data to the client """
# Get all the connected users
for id_num, user in list(self.master.users.items()):
for id_num, user in list(self.server.users.items()):
if id_num != self.get_user_id():
self.send(MESSAGE_NAME(id_num, user.get_name()))

# Get all the code
for codelet in self.master.app.get_codelets():
for codelet in self.server.app.get_codelets():
data = MESSAGE_HISTORY(-1, codelet.get_id(), codelet.get_history(), codelet.get_order_id(), codelet.is_hidden())
self.send(data)

return

def send(self, data):
""" Sends the data to THIS connected client """
self.master.send_to_client(self.user_id, data)
self.server.send_to_client(self.user_id, data)
return

def send_to_all(self, data):
""" Forwards 'data' to all connected clients """

for socket in self.master.connections():
for socket in self.server.connections():

send_to_socket(socket, data)

Expand Down

0 comments on commit 81ce9b7

Please sign in to comment.