forked from Bearle/django-private-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shuayb A
committed
Nov 30, 2017
1 parent
75960f4
commit fb74e19
Showing
1 changed file
with
15 additions
and
12 deletions.
There are no files selected for viewing
27 changes: 15 additions & 12 deletions
27
django_private_chat/management/commands/run_chat_server_uvloop.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
import asyncio | ||
import websockets | ||
import uvloop | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
from django_private_chat import channels_uvloop as channels | ||
from django_private_chat import handlers | ||
from django_private_chat.utils import logger | ||
# from django_private_chat import channels_uvloop as channels | ||
|
||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) | ||
|
||
from django_private_chat import channels | ||
from django_private_chat import handlers | ||
from django_private_chat.utils import logger | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Starts message center chat engine with uvloop' | ||
help = 'Starts message center chat engine' | ||
|
||
def handle(self, *args, **options): | ||
asyncio.async( | ||
asyncio.ensure_future( | ||
websockets.serve( | ||
handlers.main_handler, | ||
settings.CHAT_WS_SERVER_HOST, | ||
settings.CHAT_WS_SERVER_PORT | ||
) | ||
) | ||
|
||
logger.info('Chat server started') | ||
|
||
asyncio.async(handlers.new_messages_handler(channels.new_messages)) | ||
asyncio.ensure_future(handlers.new_messages_handler(channels.new_messages)) | ||
#asyncio.async(handlers.users_changed_handler(channels.users_changed)) | ||
asyncio.async(handlers.gone_online_handler(channels.gone_online)) | ||
asyncio.async(handlers.check_online_handler(channels.check_online)) | ||
asyncio.async(handlers.gone_offline_handler(channels.gone_offline)) | ||
#asyncio.async(handlers.is_typing_handler(channels.is_typing)) | ||
asyncio.async(handlers.read_message_handler(channels.read_unread)) | ||
asyncio.ensure_future(handlers.gone_online_handler(channels.gone_online)) | ||
asyncio.ensure_future(handlers.check_online_handler(channels.check_online)) | ||
asyncio.ensure_future(handlers.gone_offline_handler(channels.gone_offline)) | ||
asyncio.ensure_future(handlers.is_typing_handler(channels.is_typing)) | ||
asyncio.ensure_future(handlers.read_message_handler(channels.read_unread)) | ||
asyncio.ensure_future(handlers.unread_msg_count_handler(channels.unread_msg_count)) | ||
loop = asyncio.get_event_loop() | ||
loop.run_forever() |