Jaseci-Labs / jaseci

The Official Jaseci Code Repository
https://jaseci.org
155 stars 213 forks source link

[WEBSOCKET]: Initial Implementation #1415

Open amadolid opened 3 weeks ago

amadolid commented 3 weeks ago

FEATURES:


WEBSOCKET

Walker Declaration

Websocket Connection

PROTOCOL: ws \ URL: /websocket \ HEADER (optional): Authorization: Bearer {{USER-TOKEN}} \ QUERY PARAM (optional): ?channel_id=anystring

  • once connected, you will recieved first event for connection information
  • there's two type of connection
  • Authenticated - with valid Authorization Token
  • Non Authenticated
  • you may specify your desired channel_id via query param
  • this will recieved notification from specific channel
  • usage: group chat/notification
    
    {
    "type": "connection",
    "data": {
    # your websocket client id
    "client_id": "1730887348:f46d85203c704c099e9f44e948322a20",
    # user's root_id
    "root_id": "n::672b35cec309e5ef8469c372",

    # non authenticated
    # "root_id": "n::000000000000000000000001",

    # user's channel id, random if not specified
    "channel_id": "1730887348:796ad2e9fa3e484ebe01f071c381b7e8"
}

}


## **`Client Valid Events`**
### Walker
- this will trigger a normal walker as if it was trigger via rest API
```python
{
    # event type
    "type": "walker",

    # walker's name
    "walker": "your_event_name",

    # if you want to recieve a notification for response
    "response": true,

    # walker's request context
    "context": {
        "val": 1
    }
}

User

Channel

Client

Walker Client Notification

PREREQUISITE

import:py from jac_cloud.plugin {WEBSOCKET_MANAGER as socket}

Self

User

Channel

Client

amadolid commented 2 weeks ago

BACKUP https://github.com/amadolid/jaseci/tree/websocket-backup

amadolid commented 2 weeks ago

Will continue to upgrade to support channels using https://github.com/encode/broadcaster

amadolid commented 1 week ago

REBASED