Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Dec 20, 2021
1 parent 00c2cd2 commit 6a3c22e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ app.start(port=5000)

## Features
- Under active development!
- Written in Russt, btw xD
- Written in Rust, btw xD
- A multithreaded Runtime
- Extensible
- A simple API
Expand Down
38 changes: 37 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ app = Robyn(__file__)
websocket = WS(app, "/web_socket")
```

Now, you can define 3 methods for every web_socket for their lifecycle, they are as follows:
Now, you can define 3 methods for every web_socket for their life cycle, they are as follows:

```python3
@websocket.on("message")
Expand Down Expand Up @@ -196,6 +196,42 @@ The three methods:

To see a complete service in action, you can go to the folder [../integration_tests/base_routes.py](../integration_tests/base_routes.py)

### Update(20/12/21)

Async functions are supported in Web Sockets now!

Async functions are executed out of order for web sockets. i.e. the order of response is not guaranteed. This is done to achieve a non blocking concurrent effect.

A blocking async web socket is in plans for the future.

### Usage

```python3
@websocket.on("message")
async def connect():
global i
i+=1
if i==0:
return "Whaaat??"
elif i==1:
return "Whooo??"
elif i==2:
return "*chika* *chika* Slim Shady."
elif i==3:
i= -1
return ""

@websocket.on("close")
async def close():
return "Goodbye world, from ws"

@websocket.on("connect")
async def message():
return "Hello world, from ws"

```


## MutliCore Scaling

To run Robyn across multiple cores, you can use the following command:
Expand Down

0 comments on commit 6a3c22e

Please sign in to comment.