ws

// jda::net::ws — WebSocket Protocol (RFC 6455)

Constants

WS_OP_CONTINUATION = 0x0
WS_OP_TEXT         = 0x1
WS_OP_BINARY       = 0x2
WS_OP_CLOSE        = 0x8
WS_OP_PING         = 0x9
WS_OP_PONG         = 0xA
WS_MAX_FRAME       = 65536    // 64 KB max frame (configurable)

Structs

WsConn

struct WsConn {
    stream:  TcpStream
    is_server: bool     // server-side conns don't mask outgoing frames
}

Functions

FunctionDescription
ws_accept
ws_connect
ws_recv
ws_read_frame
ws_send_text
ws_send_binary
ws_ping
ws_close
ws_send_frame
tcp_read_exact
sha1
rol32
base64_encode

Details

ws_accept

fn ws_accept(stream: own TcpStream) -> Result<;own WsConn, []i8>

ws_connect

fn ws_connect(host: ref []i8, port: u16, path: ref []i8)

ws_recv

fn ws_recv(conn: &WsConn, r: &mut Region) -> Result<;WsMessage, []i8>

ws_read_frame

fn ws_read_frame(conn: &WsConn, r: &mut Region)

ws_send_text

fn ws_send_text(conn: &WsConn, text: ref []i8)

ws_send_binary

fn ws_send_binary(conn: &WsConn, data: ref []u8)

ws_ping

fn ws_ping(conn: &WsConn)

ws_close

fn ws_close(conn: &WsConn, code: u16, reason: ref []i8)

ws_send_frame

fn ws_send_frame(conn: &WsConn, opcode: u8, data: []u8, mask: bool)

tcp_read_exact

fn tcp_read_exact(fd: i32, buf: *u8, n: i64) -> Result<;(), []i8>

sha1

fn sha1(msg: ref []i8, out: []mut u8)

rol32

fn rol32(x: u32, n: u32) -> u32 => (x << n) | (x >> (32 - n))

base64_encode

fn base64_encode(src: []u8, dst: []mut i8) -> i64