Skip to content

Socket IO integration and Websocket documentation - #82

Merged
eadwinCode merged 22 commits into
mainfrom
websocket_documentation
May 4, 2023
Merged

Socket IO integration and Websocket documentation#82
eadwinCode merged 22 commits into
mainfrom
websocket_documentation

Conversation

@eadwinCode

@eadwinCode eadwinCode commented Apr 18, 2023

Copy link
Copy Markdown
Collaborator

Whats new

  • moved serialiser package to core
  • Added a new Gateway Control that fully supports Socket IO
class MessageData(Serializer):
    data: t.Any


class MessageRoom(Serializer):
    room: str


class MessageChatRoom(Serializer):
    room: str
    data: t.Any


@WebSocketGateway(name='gatewaytest', async_mode='asgi', cors_allowed_origins='*')
class EventGateway:
    @subscribe_message('my_event')
    async def my_event(self, message: MessageData = WsBody()):
        return WsResponse('my_response', {'data': message.data}, room=self.context.sid)

    @subscribe_message('my_broadcast_event')
    async def my_broadcast_event(self, message: MessageData = WsBody()):
        await self.context.server.emit('my_response', {'data': message.data})

    @subscribe_message('join')
    async def join(self, message: MessageRoom = WsBody()):
        self.context.server.enter_room(self.context.sid, message.room)
        await self.context.server.emit('my_response', {'data': 'Entered room: ' + message.room}, room=self.context.sid)

    @on_connected()
    async def connect(self):
        await self.context.server.emit('my_response', {'data': 'Connected', 'count': 0}, room=self.context.sid)

    @on_disconnected()
    async def disconnect(self):
        print('Client disconnected')

@eadwinCode eadwinCode changed the title Socket IO integration and Websocket documentation WIP: Socket IO integration and Websocket documentation Apr 18, 2023
@codecov-commenter

codecov-commenter commented Apr 28, 2023

Copy link
Copy Markdown

Codecov Report

Merging #82 (c71cfc4) into main (ceda55b) will increase coverage by 0.10%.
The diff coverage is 98.37%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   96.97%   97.07%   +0.10%     
==========================================
  Files         186      205      +19     
  Lines        6141     6539     +398     
==========================================
+ Hits         5955     6348     +393     
- Misses        186      191       +5     
Impacted Files Coverage Δ
ellar/common/decorators/controller.py 98.52% <ø> (ø)
ellar/common_types.py 100.00% <ø> (ø)
ellar/core/conf/mixins.py 100.00% <ø> (ø)
ellar/core/modules/base.py 100.00% <ø> (ø)
ellar/core/modules/interfaces.py 0.00% <0.00%> (ø)
ellar/core/serializer/__init__.py 98.91% <ø> (ø)
ellar/core/services/__init__.py 100.00% <ø> (ø)
ellar/core/services/reflector.py 97.29% <ø> (ø)
ellar/socket_io/context.py 88.23% <88.23%> (ø)
ellar/core/routing/builder.py 95.23% <95.23%> (ø)
... and 65 more

... and 2 files with indirect coverage changes

@eadwinCode eadwinCode changed the title WIP: Socket IO integration and Websocket documentation Socket IO integration and Websocket documentation May 4, 2023
@eadwinCode
eadwinCode merged commit 72bfca4 into main May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants