appended xpub fork-specifc notes to README

master
Michael Murtaugh 3 years ago
parent 5b95d4a90e
commit 76c491f4e7

@ -61,3 +61,14 @@ PORT = 3000
``` ```
The admin names are reserved. Logging in as "adminname|pass" (nickname and password separated by a "|") will grant the user admin priviledges such as banning IP or sending special messages. The admin names are reserved. Logging in as "adminname|pass" (nickname and password separated by a "|") will grant the user admin priviledges such as banning IP or sending special messages.
# XPUB FORK
Notes on the XPUB Fork.
The version of socketio used is **not the most recent**. The [requirements.txt](requirements.txt) file reflects the correct versions for flasksocketio etc. Note that it was important to clone and generate the documentation of these older dependencies to avoid problems with changes (namely in the first implementation I used the "to=" paramter to calls to **emit** and **send** which doesn't even give an error, but which isn't correct as the old API uses "room=").
Replacing calls to javascript's setInterval and setTimeout required the implementation of a small class called IntervalTaskMaster (See: <interval_tasks.py>). It uses pythonsocketio's start_background_task method (and hopefully remains intact if/when deployed with say uwsgi, should test this ;)
At the moment the serverMod is only partially implemented.

@ -14,7 +14,7 @@ class IntervalTaskMaster ():
def background_task(self): def background_task(self):
st = 0 st = 0
while True: while True:
print (f"IntervalTaskMaster is running with {len(self.tasks_by_id)} pending tasks") # print (f"IntervalTaskMaster is running with {len(self.tasks_by_id)} pending tasks")
# Add any items in the queue # Add any items in the queue
while not self.queue.empty(): while not self.queue.empty():
task_id, callback, time, interval = self.queue.get() task_id, callback, time, interval = self.queue.get()
@ -31,7 +31,7 @@ class IntervalTaskMaster ():
print (f"deleting task {task_id}") print (f"deleting task {task_id}")
del self.tasks_by_id[task_id] del self.tasks_by_id[task_id]
st = self.calc_current_sleep_time_ms() st = self.calc_current_sleep_time_ms()
print (f"taskmaster sleeping {st}") # print (f"taskmaster sleeping {st}")
self.socketio.sleep(st/1000) self.socketio.sleep(st/1000)
def calc_current_sleep_time_ms(self): def calc_current_sleep_time_ms(self):

@ -64,11 +64,6 @@ connections = 0
from interval_tasks import IntervalTaskMaster from interval_tasks import IntervalTaskMaster
# def background_task():
# while True:
# print ("I'm running in the background")
# socketio.sleep(5)
@socketio.on('connect') @socketio.on('connect')
def connect(sid=None, environ=None, auth=None): def connect(sid=None, environ=None, auth=None):
@ -230,7 +225,13 @@ def join (playerInfo):
@socketio.on('intro') @socketio.on('intro')
def intro (newComer, obj): def intro (newComer, obj):
""" when I receive an intro send it to the recipient """ """ when I receive an intro send it to the recipient
intro messages are sent by the client in reponse to a playerJoin message of a "new" player
obj is a "auto biography" from the sender to relay to newComer
containing info (like avatar) that the server merely relays
"""
# print (f"intro {newComer} {obj}") # print (f"intro {newComer} {obj}")
# verify the id to make sure a hacked client can"t fake players # verify the id to make sure a hacked client can"t fake players
if (obj is not None): if (obj is not None):

@ -60,6 +60,8 @@ VIPList = []
def initMod (io, gameState, DATA, taskmaster): def initMod (io, gameState, DATA, taskmaster):
""" called at the beginning """ """ called at the beginning """
return
print("MOD: Initialized"); print("MOD: Initialized");
# EVERYTHING GLOBALLLLL # EVERYTHING GLOBALLLLL
@ -136,23 +138,23 @@ def initMod (io, gameState, DATA, taskmaster):
taskmaster.setInterval(consonant_interval, 60*1000) taskmaster.setInterval(consonant_interval, 60*1000)
# # custom function called on the server side when a player successfully enters or exits the room # custom function called on the server side when a player successfully enters or exits the room
# # executed before it's broadcast to the other players # executed before it's broadcast to the other players
# def experimentsJoin(player, roomId): def experimentsJoin(player, roomId):
# # print("MOD: " + player.nickName + " entered room " + roomId) # print("MOD: " + player.nickName + " entered room " + roomId)
# pass pass
# def experimentsLeave(player, roomId): def experimentsLeave(player, roomId):
# # print("MOD: " + player.nickName + " exited room " + roomId) # print("MOD: " + player.nickName + " exited room " + roomId)
# pass pass
# def experimentsTalkFilter(player, message): def experimentsTalkFilter(player, message):
# """ wouldn't it be funny if cetain rooms modified your messages? """ """ wouldn't it be funny if cetain rooms modified your messages? """
# # print("MOD: " + player.nickName + " said " + message); # print("MOD: " + player.nickName + " said " + message);
# # message = re.sub('[aeiou]', '', message, flags=re.I) # message = re.sub('[aeiou]', '', message, flags=re.I)
# # make sure it returns a message # make sure it returns a message
# return message return message

Loading…
Cancel
Save