master
Michael Murtaugh 3 years ago
parent 8a8ca31c2c
commit bab3e94520

@ -1,20 +1,30 @@
import time, json, re
import flask
from flask import Flask, render_template
from flask import Flask
from flask_socketio import SocketIO, send, emit, join_room, leave_room, has_request_context, disconnect
import datetime, time, json, re
PACKETS_PER_SECONDS = 30
"""
## Notes from the python/flask port:
Still to do:
* NPC
* Language Filter
* Connection monitoring: PACKETS_PER_SECONDS
* serverMod.js!
## Notes from original/node:
The client and server version strings MUST be the same!
They can be used to force clients to hard refresh to load the latest client.
If the server gets updated it can be restarted, but if there are active clients (users' open browsers) they could be outdated and create issues.
If the VERSION vars are mismatched they will send all clients in an infinite refresh loop. Make sure you update sketch.js before restarting server.js
"""
VERSION = "1.0"
# TODO...
PACKETS_PER_SECONDS = 30
VERSION = "1.0"
with open("data.json") as datafile:
DATA = json.load(datafile)
@ -39,7 +49,7 @@ gameState = {
}
# save the server startup time and send it in case the clients need to syncronize something
START_TIME = datetime.datetime.now()
START_TIME = int(time.time()*1000) # datetime.datetime.now()
# a collection of banned IPs
# not permanent, it lasts until the server restarts
@ -47,9 +57,8 @@ banned = []
app = Flask(__name__, static_url_path='', static_folder='public')
# self.add_url_rule(f"{self.static_url_path}/<path:filename>", endpoint="static", host=static_host, view_func=lambda **kw: self_ref().send_static_file(**kw), # type: ignore # noqa: B950)
app.add_url_rule("/", view_func=lambda **kw: app.send_static_file("index.html", **kw))
app.config['SECRET_KEY'] = 'secret!'
# app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
connections = 0

Loading…
Cancel
Save