appended xpub fork-specifc notes to README

master
Michael Murtaugh 2 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.
# 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):
st = 0
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
while not self.queue.empty():
task_id, callback, time, interval = self.queue.get()
@ -31,7 +31,7 @@ class IntervalTaskMaster ():
print (f"deleting task {task_id}")
del self.tasks_by_id[task_id]
st = self.calc_current_sleep_time_ms()
print (f"taskmaster sleeping {st}")
# print (f"taskmaster sleeping {st}")
self.socketio.sleep(st/1000)
def calc_current_sleep_time_ms(self):

@ -64,11 +64,6 @@ connections = 0
from interval_tasks import IntervalTaskMaster
# def background_task():
# while True:
# print ("I'm running in the background")
# socketio.sleep(5)
@socketio.on('connect')
def connect(sid=None, environ=None, auth=None):
@ -230,7 +225,13 @@ def join (playerInfo):
@socketio.on('intro')
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}")
# verify the id to make sure a hacked client can"t fake players
if (obj is not None):

@ -60,6 +60,8 @@ VIPList = []
def initMod (io, gameState, DATA, taskmaster):
""" called at the beginning """
return
print("MOD: Initialized");
# EVERYTHING GLOBALLLLL
@ -136,23 +138,23 @@ def initMod (io, gameState, DATA, taskmaster):
taskmaster.setInterval(consonant_interval, 60*1000)
# # 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
# def experimentsJoin(player, roomId):
# # print("MOD: " + player.nickName + " entered room " + roomId)
# pass
# 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
def experimentsJoin(player, roomId):
# print("MOD: " + player.nickName + " entered room " + roomId)
pass
# def experimentsLeave(player, roomId):
# # print("MOD: " + player.nickName + " exited room " + roomId)
# pass
def experimentsLeave(player, roomId):
# print("MOD: " + player.nickName + " exited room " + roomId)
pass
# def experimentsTalkFilter(player, message):
# """ wouldn't it be funny if cetain rooms modified your messages? """
def experimentsTalkFilter(player, message):
""" wouldn't it be funny if cetain rooms modified your messages? """
# # print("MOD: " + player.nickName + " said " + message);
# # message = re.sub('[aeiou]', '', message, flags=re.I)
# # make sure it returns a message
# return message
# print("MOD: " + player.nickName + " said " + message);
# message = re.sub('[aeiou]', '', message, flags=re.I)
# make sure it returns a message
return message

Loading…
Cancel
Save