Skip to content

Instantly share code, notes, and snippets.

syntax on
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nu
set nowrap
set smartcase
/ handle websocket messages
.z.ws: {value x}
/ handle closure of websockets
.z.wc: {delete from `subs where handle = x}
/ function to generate data
gendata: {
/ convert to a list if x is atom (to handle random generating function '?'
if [0 > type x; x: 1#x];
import websockets
import json
import asyncio
uri = "ws://localhost:5511"
async def subscribe(*args):
async with websockets.connect(uri) as websocket:
# subcription
import asyncio
import websockets
uri = "ws://localhost:5511"
async def query(x):
async with websockets.connect(uri) as websocket:
params = f'ClientResponse `{x}'
await websocket.send(params)