1
0
Fork 0
mirror of https://github.com/fastogt/fastocloud_admin.git synced 2025-03-09 23:38:52 +00:00

Message type

This commit is contained in:
topilski 2019-09-04 02:25:44 -04:00
parent a1617e16d0
commit 39f30ff466
4 changed files with 7 additions and 4 deletions

@ -1 +1 @@
Subproject commit 111b60787080a1443d3d1ac09ea793b2eb605ca2 Subproject commit 7d190acf4fce23ae19b6064a94b15c6548c00765

View file

@ -2,6 +2,7 @@ from app.common.service.entry import ServiceSettings
from app.service.service import Service from app.service.service import Service
from app.service.subscriber_client import SubscriberConnection from app.service.subscriber_client import SubscriberConnection
from app.common.subscriber.entry import Subscriber from app.common.subscriber.entry import Subscriber
from app.common.constants import PlayerMessage
from pyfastocloud.subscriber_client import Commands from pyfastocloud.subscriber_client import Commands
from pyfastocloud.client import make_utc_timestamp from pyfastocloud.client import make_utc_timestamp
from pyfastocloud.client_handler import IClientHandler, Request, Response, ClientStatus from pyfastocloud.client_handler import IClientHandler, Request, Response, ClientStatus
@ -213,7 +214,7 @@ class ServiceManager(IClientHandler):
return connections return connections
def send_message(self, email: str, message: str, ttl: int): def send_message(self, email: str, message: PlayerMessage):
for user in self._subscribers: for user in self._subscribers:
if user.info and user.info.email == email: if user.info and user.info.email == email:
user.send_message(user.gen_request_id(), message, ttl * 1000) user.send_message(user.gen_request_id(), message.message, message.type, message.ttl * 1000)

View file

@ -277,7 +277,7 @@ class ServiceView(FlaskView):
subscriber = Subscriber.objects(id=sid).first() subscriber = Subscriber.objects(id=sid).first()
form = MessageForm() form = MessageForm()
if request.method == 'POST' and form.validate_on_submit(): if request.method == 'POST' and form.validate_on_submit():
servers_manager.send_message(subscriber.email, form.message.data, form.ttl.data) servers_manager.send_message(subscriber.email, form.get_data())
return jsonify(status='ok'), 200 return jsonify(status='ok'), 200
return render_template('service/subscriber/send_message.html', form=form) return render_template('service/subscriber/send_message.html', form=form)

View file

@ -23,6 +23,8 @@
<br> <br>
{{ render_bootstrap_field(form.message) }} {{ render_bootstrap_field(form.message) }}
<br> <br>
{{ render_bootstrap_field(form.type) }}
<br>
{{ render_bootstrap_field(form.ttl) }} {{ render_bootstrap_field(form.ttl) }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">