net/socketio
A Socket.IO client: events, acknowledgements, namespaces and automatic reconnection.
import net.socketio
Socket.IO is the usual live messaging library in the Node.js world. This package is a client that connects to any Socket.IO version 4 server; it has no server of its own. Dial connects, On sets a listener for an event and the Emit... functions send events. Listeners are called while the program processes messages with Run, RunFor, Pump or Next.
The arguments of every event are a JSON array, read with ArgStr, ArgInt and the like. If the sender wants an answer, the event's ack_id is not negative and you answer it with Reply. For several namespaces on one connection, create a Manager.
Types
Endpoint
struct Endpoint| Name | Type | Description |
|---|---|---|
secure | bool = false | HTTPS or WSS. |
host | str = "localhost" | The host. |
port | int = 80 | The port; 80 or 443 if it is not given. |
path | str = "/socket.io" | The Socket.IO path. |
namespace | str = "/" | The namespace, from the URL path. |
query | str = "" | The query. |
ok | bool = false | The URL is valid. |
import net.socketio
func show(url: str):
e := socketio.ParseURL(url)
if not e.ok:
println url, "invalid"
ret
end
println e.host, e.port, e.secure, e.namespace, "query=" + e.query
println socketio.Origin(e)
end
func main:
show("http://localhost:3000")
show("https://example.com/admin/?token=abc")
show("ws://[::1]:8080/chat")
show("ftp://example.com")
endOptions
struct Options| Name | Type | Description |
|---|---|---|
path | str = "/socket.io" | The path of the Socket.IO server. |
query | str = "" | An extra query for the URL. |
auth | str = "" | Authentication data as JSON, sent when connecting to the namespace. |
headers | str = "" | Extra HTTP headers, one per line. |
transports | int | The transport, one of the TRANSPORT_... constants. |
reconnection | bool = true | Reconnect automatically after a disconnect. |
reconnection_attempts | int = 0 | The most attempts; zero means no limit. |
reconnection_delay | int = 1000 | The delay before the first attempt in milliseconds; it doubles every time. |
reconnection_delay_max | int = 5000 | The longest delay. |
randomization_factor | int = 50 | A random percentage added to or taken from the delay so that all clients do not come back at the same moment. |
timeout | int = 20000 | The connect timeout in milliseconds. |
insecure | bool = false | Do not check the TLS certificate; for testing only. |
auto_connect | bool = true | The client connects right away. |
event_queue | int = 256 | The most events in the queue. |
ack_timeout | int = 0 | The default acknowledgement timeout. |
retries | int = 0 | How many times to resend messages that got no acknowledgement. |
trailing_slash | bool = true | Add a slash to the end of the path, like the JavaScript client. |
remember_upgrade | bool = false | If the upgrade to WebSocket worked once, use WebSocket directly next time. |
import net.socketio
func main:
mut o := socketio.NewOptions()
println o.path, o.reconnection, o.reconnection_delay, o.timeout
println o.transports == socketio.TRANSPORT_AUTO
o.transports = socketio.TRANSPORT_WEBSOCKET
o.auth = `{"token":"abc"}`
o.auto_connect = false
println o.transports, o.auth, o.auto_connect
println socketio.TRANSPORT_POLLING, socketio.REASON_SERVER_DISCONNECT, socketio.REASON_PING_TIMEOUT
println socketio.PUMP_OK, socketio.PUMP_TIMEOUT, socketio.PUMP_CLOSED
endClient
struct Client| Name | Type | Description |
|---|---|---|
p | void* | The internal pointer. |
import net.socketio
import net.websocket
import str
mut server := websocket.Server {}
mut report := ""
func test_server():
mut conn := websocket.Accept(server)
_ := websocket.SendText(conn, `0{"sid":"s1","upgrades":[],"pingInterval":20000,"pingTimeout":5000}`)
mut going := true
until going:
m := websocket.Poll(conn, 3000)
if m.kind != websocket.TEXT:
break
end
packet := m.text.substr(1, m.text.len() - 1)
if packet == "0":
_ := websocket.SendText(conn, `40{"sid":"a1"}`)
else str.StartsWith(packet, `2["chat"`):
_ := websocket.SendText(conn, `42["chat","welcome"]`)
_ := websocket.SendText(conn, `429["question","2+2"]`)
else str.Contains(packet, `"add"`):
id := packet.substr(1, str.Find(packet, "[") - 1)
_ := websocket.SendText(conn, "43" + id + "[5]")
else str.StartsWith(packet, "39"):
report += "reply: " + packet.substr(2, packet.len() - 2)
else packet == "1":
going = false
end
end
websocket.Close(conn)
end
func main:
server = websocket.Listen(0)
t := spawn(test_server)
mut o := socketio.NewOptions()
o.transports = socketio.TRANSPORT_WEBSOCKET
o.reconnection = false
c := socketio.DialWith("http://127.0.0.1:" + websocket.Port(server), o)
println socketio.IsConnected(c), socketio.Sid(c), socketio.Id(c), socketio.Namespace(c), socketio.TransportName(c)
socketio.On(c, "chat", (e: socketio.Event):
println "message:", socketio.ArgStr(e, 0)
end)
socketio.On(c, "question", (e: socketio.Event):
println "question:", socketio.ArgStr(e, 0), e.ack_id >= 0
_ := socketio.ReplyStr(e, "four")
end)
println socketio.ListenerCount(c, "chat"), socketio.HasListeners(c, "news")
_ := socketio.EmitStr(c, "chat", "hello")
socketio.RunFor(c, 500)
mut a := socketio.NewArgs()
socketio.AddInt(a, 2)
socketio.AddInt(a, 3)
mut k := socketio.EmitAck(c, "add", a, 2000)
println k.ok, socketio.AckInt(k, 0)
socketio.AckFree(k)
socketio.ArgsFree(a)
socketio.Close(c)
join(t)
websocket.CloseServer(server)
println report
endManager
struct Manager| Name | Type | Description |
|---|---|---|
p | void* | The internal pointer. |
import net.socketio
func main:
mut o := socketio.NewOptions()
o.auth = `{"token":"abc"}`
o.auto_connect = false
m := socketio.NewManager("https://example.com", o)
socketio.SetReconnection(m, true)
socketio.SetReconnectionAttempts(m, 5)
socketio.SetReconnectionDelay(m, 500)
socketio.SetReconnectionDelayMax(m, 10000)
socketio.SetRandomizationFactor(m, 20)
socketio.SetTimeout(m, 5000)
println socketio.OptionsOf(m).reconnection_attempts
public := socketio.Of(m, "/")
admin := socketio.Of(m, "/admin")
socketio.SetAuth(admin, `{"role":"admin"}`)
println socketio.AuthOf(admin), socketio.Sockets(m).len()
if not socketio.Open(m):
println "error:", socketio.ManagerError(m)
ret
end
println socketio.IsOpen(m)
_ := socketio.Connect(public)
_ := socketio.Connect(admin)
if socketio.Refused(admin):
println "refused:", socketio.RefusalReason(admin)
end
println socketio.Active(public), socketio.Disconnected(public), socketio.Recovered(public)
println socketio.Transport(public), socketio.PingInterval(public), socketio.PingTimeout(public), socketio.MaxPayload(public)
println socketio.Buffered(public), socketio.Pending(public), socketio.Queued(public), socketio.Attempts(public)
println socketio.EndpointOf(public).host, socketio.ManagerOf(public).p == m.p
_ := socketio.PumpManager(m, 1000)
socketio.Disconnect(admin)
socketio.CloseManager(m)
endEvent
struct Event| Name | Type | Description |
|---|---|---|
kind | int | The kind of event. |
name | str = "" | The event name. |
nsp | str = "/" | The namespace. |
data | str = "[]" | The arguments as a JSON array. |
ack_id | int = -1 | The acknowledgement number if the sender wants one; otherwise -1. |
message | str = "" | A description, for error and disconnect events. |
bins | Vector | The binary parts. |
client | Client | The socket that received the event. |
The example for this item is shown with the ones above: net-socketio-Client.salam
Ack
struct Ack| Name | Type | Description |
|---|---|---|
ok | bool = false | The reply arrived before the timeout. |
id | int = -1 | The acknowledgement number. |
data | str = "[]" | The arguments as a JSON array. |
bins | Vector | The binary parts. |
The example for this item is shown with the ones above: net-socketio-Client.salam
Bytes
struct Bytes| Name | Type | Description |
|---|---|---|
ptr | void* | The pointer. |
len | int = 0 | The length. |
import net.socketio
func main:
mut b := socketio.BytesFromStr("Salam")
println b.len, socketio.BytesAt(b, 0)
println socketio.BytesToStr(b)
println socketio.BytesToBase64(b)
socketio.BytesFree(b)
mut c := socketio.NewBytes("hello" as void*, 4)
println socketio.BytesToStr(c)
socketio.BytesFree(c)
mut a := socketio.NewArgs()
socketio.AddStr(a, "file.txt")
socketio.AddBinaryStr(a, "abc")
println socketio.ArgsJSON(a, "upload")
println a.bins.len()
socketio.ArgsFree(a)
endPacket
struct Packet| Name | Type | Description |
|---|---|---|
kind | int = -1 | The kind. |
nsp | str = "/" | The namespace. |
id | int = -1 | The acknowledgement number; -1 means no acknowledgement. |
data | str = "" | The data as JSON. |
attachments | int = 0 | The number of binary parts. |
ok | bool = false | The packet was read correctly. |
import net.socketio
func main:
mut p := socketio.Packet {}
p.kind = socketio.PKT_EVENT
p.nsp = "/chat"
p.id = 7
p.data = `["hi",1]`
text := socketio.EncodePacket(p)
println text
d := socketio.DecodePacket(text)
println d.ok, d.kind, d.nsp, d.id, d.data
bad := socketio.DecodePacket("x")
println bad.ok
payload := socketio.EncodeEngine(socketio.EIO_MESSAGE, text)
println payload
println socketio.EngineKind(payload) == socketio.EIO_MESSAGE
println socketio.EngineBody(payload)
mut items := Vector {} as Vector<str>
items.push("2")
items.push(payload)
body := socketio.JoinPayloads(items)
parts := socketio.SplitPayloads(body)
println parts.len(), parts.get(0), parts.get(1)
arr := socketio.SplitJSONArray(`["a", {"b":[1,2]}, 3]`)
println arr.len(), arr.get(1)
ph := socketio.Placeholder(0)
println ph
println socketio.PlaceholderNum(ph), socketio.PlaceholderNum("12")
endArgs
struct Args| Name | Type | Description |
|---|---|---|
items | Vector | The arguments as JSON. |
bins | Vector | The binary parts. |
import net.socketio
import encoding.value
func main:
mut a := socketio.NewArgs()
socketio.AddStr(a, "hello \"world\"")
socketio.AddInt(a, 42)
socketio.AddFloat(a, 2.5)
socketio.AddBool(a, true)
socketio.AddNull(a)
socketio.AddJSON(a, `{"x":1}`)
println socketio.ArgsCount(a)
text := socketio.ArgsJSON(a, "message")
println text
println socketio.ItemCount(text)
println socketio.ItemStr(text, 1)
println socketio.ItemInt(text, 2)
println socketio.ItemFloat(text, 3)
println socketio.ItemBool(text, 4)
println socketio.Item(text, 6)
println socketio.Item(text, 9).len()
socketio.ArgsFree(a)
mut v := socketio.ItemValue(text, 2)
println value.IsNumber(v), value.AsInt(v)
mut a2 := socketio.NewArgs()
socketio.AddValue(a2, v)
socketio.AddBytes(a2, "xyz" as void*, 3)
println socketio.ArgsJSON(a2, "")
socketio.ArgsFree(a2)
value.ValueFree(v)
endConstants and variables
TRANSPORT_AUTO
const TRANSPORT_AUTO: i32 = 0The example for this item is shown with the ones above: net-socketio-Options.salam
TRANSPORT_WEBSOCKET
const TRANSPORT_WEBSOCKET: i32 = 1The example for this item is shown with the ones above: net-socketio-Client.salam
TRANSPORT_POLLING
const TRANSPORT_POLLING: i32 = 2The example for this item is shown with the ones above: net-socketio-Options.salam
Event kinds EV_…
kind field in the event that Next returns. A message event is one of the server's messages; the rest report on the connection itself: connecting and disconnecting, errors, reconnection attempts, pings, timeouts and the upgrade to WebSocket. Listeners are called with the English names of these events, such as connect and disconnect.| Name | Value |
|---|---|
EV_NONE | 0 |
EV_EVENT | 1 |
EV_CONNECT | 2 |
EV_DISCONNECT | 3 |
EV_CONNECT_ERROR | 4 |
EV_ERROR | 5 |
EV_RECONNECT | 6 |
EV_RECONNECT_ATTEMPT | 7 |
EV_RECONNECT_ERROR | 8 |
EV_RECONNECT_FAILED | 9 |
EV_PING | 10 |
EV_TIMEOUT | 11 |
EV_UPGRADE | 12 |
import net.socketio
import encoding.value
func main:
c := socketio.Dial("http://localhost:3000")
if not socketio.IsConnected(c):
println socketio.LastError(c)
ret
end
socketio.OnAny(c, (e: socketio.Event):
println "received:", e.name, socketio.ArgCount(e)
end)
socketio.Once(c, "welcome", (e: socketio.Event):
println socketio.Arg(e, 0)
end)
socketio.OnAnyOutgoing(c, (e: socketio.Event):
println "sent:", e.name
end)
socketio.PrependAny(c, (e: socketio.Event):
println "first of all:", e.name
end)
socketio.PrependAnyOutgoing(c, (e: socketio.Event):
println "sending:", e.name
end)
println socketio.AnyListenerCount(c)
_ := socketio.Emit(c, "ping")
_ := socketio.EmitInt(c, "score", 12)
_ := socketio.EmitFloat(c, "temp", 21.5)
_ := socketio.EmitBool(c, "ready", true)
_ := socketio.EmitJSON(c, "user", `{"name":"Ali"}`)
_ := socketio.EmitBytes(c, "file", "abc" as void*, 3)
_ := socketio.Send(c, "a plain message")
mut a := socketio.NewArgs()
socketio.AddStr(a, "room-1")
_ := socketio.EmitArgs(c, "join", a)
_ := socketio.EmitVolatile(c, "cursor", a)
_ := socketio.EmitWithAck(c, "join", a, 2000, (k: socketio.Ack):
println k.ok, socketio.AckCount(k), socketio.AckStr(k, 0)
println socketio.AckArg(k, 1), socketio.AckFloat(k, 1), socketio.AckBool(k, 2)
if socketio.AckIsBinary(k, 3):
println socketio.AckBytes(k, 3).len
end
mut v := socketio.AckValue(k, 0)
value.ValueFree(v)
end)
socketio.ArgsFree(a)
mut e := socketio.Next(c, 5000)
if e.kind == socketio.EV_EVENT:
println socketio.ArgInt(e, 0), socketio.ArgFloat(e, 1), socketio.ArgBool(e, 2)
if socketio.ArgIsBinary(e, 3):
b := socketio.ArgBytes(e, 3)
println b.len
end
if e.ack_id >= 0:
_ := socketio.ReplyJSON(e, `{"ok":true}`)
end
else e.kind == socketio.EV_DISCONNECT:
println "disconnected:", e.message
end
socketio.EventFree(e)
mut e2 := socketio.NextEvent(c, 5000)
mut v2 := socketio.ArgValue(e2, 0)
println value.IsNumber(v2)
value.ValueFree(v2)
socketio.EventFree(e2)
_ := socketio.Pump(c, 100)
socketio.Off(c, "welcome")
socketio.OffAny(c)
socketio.OffAnyOutgoing(c)
socketio.OffAll(c)
socketio.Run(c)
endDisconnect reasons REASON_…
message field of a disconnect event, telling why the connection ended: the server or the program itself closed it, a ping did not arrive in time, the transport closed or failed, or a packet could not be read.| Name | Value |
|---|---|
REASON_SERVER_DISCONNECT | "io server disconnect" |
REASON_CLIENT_DISCONNECT | "io client disconnect" |
REASON_PING_TIMEOUT | "ping timeout" |
REASON_TRANSPORT_CLOSE | "transport close" |
REASON_TRANSPORT_ERROR | "transport error" |
REASON_PARSE_ERROR | "parse error" |
The example for this item is shown with the ones above: net-socketio-Options.salam
Pump results PUMP_…
Pump and PumpManager: something arrived and was handled, the timeout ran out, or the connection is closed.| Name | Value |
|---|---|
PUMP_OK | 0 |
PUMP_TIMEOUT | 1 |
PUMP_CLOSED | 2 |
The example for this item is shown with the ones above: net-socketio-Options.salam
Engine packet kinds EIO_…
| Name | Value |
|---|---|
EIO_OPEN | 0 |
EIO_CLOSE | 1 |
EIO_PING | 2 |
EIO_PONG | 3 |
EIO_MESSAGE | 4 |
EIO_UPGRADE | 5 |
EIO_NOOP | 6 |
The example for this item is shown with the ones above: net-socketio-Packet.salam
Socket.IO packet kinds PKT_…
| Name | Value |
|---|---|
PKT_CONNECT | 0 |
PKT_DISCONNECT | 1 |
PKT_EVENT | 2 |
PKT_ACK | 3 |
PKT_CONNECT_ERROR | 4 |
PKT_BINARY_EVENT | 5 |
PKT_BINARY_ACK | 6 |
The example for this item is shown with the ones above: net-socketio-Packet.salam
Functions
ParseURL
func ParseURL(raw: str): Endpointhttp, https, ws and wss schemes are accepted.The example for this item is shown with the ones above: net-socketio-URL.salam
Origin
func Origin(e: Endpoint): strhttps://example.com; the default port is left out.The example for this item is shown with the ones above: net-socketio-URL.salam
EncodePacket
func EncodePacket(p: Packet): strThe example for this item is shown with the ones above: net-socketio-Packet.salam
DecodePacket
func DecodePacket(text: str): Packetok is false.The example for this item is shown with the ones above: net-socketio-Packet.salam
EncodeEngine
func EncodeEngine(kind: int, body: str): strThe example for this item is shown with the ones above: net-socketio-Packet.salam
EngineKind
func EngineKind(payload: str): intThe example for this item is shown with the ones above: net-socketio-Packet.salam
EngineBody
func EngineBody(payload: str): strThe example for this item is shown with the ones above: net-socketio-Packet.salam
SplitPayloads
func SplitPayloads(body: str): Vector<str>The example for this item is shown with the ones above: net-socketio-Packet.salam
JoinPayloads
func JoinPayloads(items: Vector<str>): strThe example for this item is shown with the ones above: net-socketio-Packet.salam
SplitJSONArray
func SplitJSONArray(text: str): Vector<str>The example for this item is shown with the ones above: net-socketio-Packet.salam
Placeholder
func Placeholder(num: int): strThe example for this item is shown with the ones above: net-socketio-Packet.salam
PlaceholderNum
func PlaceholderNum(frag: str): intThe example for this item is shown with the ones above: net-socketio-Packet.salam
NewBytes
func NewBytes(ptr: void*, n: int): BytesThe example for this item is shown with the ones above: net-socketio-Bytes.salam
BytesFromStr
func BytesFromStr(s: str): BytesThe example for this item is shown with the ones above: net-socketio-Bytes.salam
BytesToStr
func BytesToStr(b: Bytes): strThe example for this item is shown with the ones above: net-socketio-Bytes.salam
BytesToBase64
func BytesToBase64(b: Bytes): strThe example for this item is shown with the ones above: net-socketio-Bytes.salam
BytesAt
func BytesAt(b: Bytes, i: int): intThe example for this item is shown with the ones above: net-socketio-Bytes.salam
BytesFree
func BytesFree(b &: Bytes)The example for this item is shown with the ones above: net-socketio-Bytes.salam
NewArgs
func NewArgs(): ArgsThe example for this item is shown with the ones above: net-socketio-Client.salam
AddStr
func AddStr(a &: Args, s: str)The example for this item is shown with the ones above: net-socketio-Args.salam
AddInt
func AddInt(a &: Args, n: i64)The example for this item is shown with the ones above: net-socketio-Client.salam
AddFloat
func AddFloat(a &: Args, n: f64)The example for this item is shown with the ones above: net-socketio-Args.salam
AddBool
func AddBool(a &: Args, b: bool)The example for this item is shown with the ones above: net-socketio-Args.salam
AddNull
func AddNull(a &: Args)The example for this item is shown with the ones above: net-socketio-Args.salam
AddJSON
func AddJSON(a &: Args, raw: str)The example for this item is shown with the ones above: net-socketio-Args.salam
AddValue
func AddValue(a &: Args, v: value.Value)The example for this item is shown with the ones above: net-socketio-Args.salam
AddBytes
func AddBytes(a &: Args, ptr: void*, n: int)The example for this item is shown with the ones above: net-socketio-Args.salam
AddBinaryStr
func AddBinaryStr(a &: Args, s: str)The example for this item is shown with the ones above: net-socketio-Bytes.salam
ArgsCount
func ArgsCount(a: Args): intThe example for this item is shown with the ones above: net-socketio-Args.salam
ArgsFree
func ArgsFree(a &: Args)The example for this item is shown with the ones above: net-socketio-Client.salam
ArgsJSON
func ArgsJSON(a: Args, name: str): strThe example for this item is shown with the ones above: net-socketio-Args.salam
ItemCount
func ItemCount(raw: str): intThe example for this item is shown with the ones above: net-socketio-Args.salam
Item
func Item(raw: str, i: int): strThe example for this item is shown with the ones above: net-socketio-Args.salam
ItemStr
func ItemStr(raw: str, i: int): strThe example for this item is shown with the ones above: net-socketio-Args.salam
ItemInt
func ItemInt(raw: str, i: int): i64The example for this item is shown with the ones above: net-socketio-Args.salam
ItemFloat
func ItemFloat(raw: str, i: int): f64The example for this item is shown with the ones above: net-socketio-Args.salam
ItemBool
func ItemBool(raw: str, i: int): booltrue count as true.The example for this item is shown with the ones above: net-socketio-Args.salam
ItemValue
func ItemValue(raw: str, i: int): value.ValueThe example for this item is shown with the ones above: net-socketio-Args.salam
NewOptions
func NewOptions(): OptionsThe example for this item is shown with the ones above: net-socketio-Client.salam
NewManager
func NewManager(url: str, opts: Options): ManagerThe example for this item is shown with the ones above: net-socketio-Manager.salam
Of
func Of(m: Manager, nsp: str): ClientThe example for this item is shown with the ones above: net-socketio-Bytes.salam
ManagerOf
func ManagerOf(c: Client): ManagerThe example for this item is shown with the ones above: net-socketio-Manager.salam
Dial
func Dial(url: str): ClientLastError.The example for this item is shown with the ones above: net-socketio-Client.salam
DialWith
func DialWith(url: str, opts: Options): ClientThe example for this item is shown with the ones above: net-socketio-Client.salam
Connect
func Connect(c: Client): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
Disconnect
func Disconnect(c: Client)The example for this item is shown with the ones above: net-socketio-Manager.salam
CloseManager
func CloseManager(m: Manager)The example for this item is shown with the ones above: net-socketio-Manager.salam
Close
func Close(c: Client)The example for this item is shown with the ones above: net-socketio-Client.salam
Pump
func Pump(c: Client, timeout_ms: int): intThe example for this item is shown with the ones above: net-socketio-Options.salam
PumpManager
func PumpManager(m: Manager, timeout_ms: int): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
Next
func Next(c: Client, timeout_ms: int): EventEV_NONE if nothing arrived within the timeout. Listeners are called too.The example for this item is shown with the ones above: net-socketio-Ack.salam
NextEvent
func NextEvent(c: Client, timeout_ms: int): EventThe example for this item is shown with the ones above: net-socketio-Ack.salam
Run
func Run(c: Client)The example for this item is shown with the ones above: net-socketio-Client.salam
RunFor
func RunFor(c: Client, ms: int)The example for this item is shown with the ones above: net-socketio-Client.salam
On
func On(c: Client, name: str, cb: func(Event))The example for this item is shown with the ones above: net-socketio-Client.salam
Once
func Once(c: Client, name: str, cb: func(Event))The example for this item is shown with the ones above: net-socketio-Ack.salam
Off
func Off(c: Client, name: str)The example for this item is shown with the ones above: net-socketio-Ack.salam
OffAll
func OffAll(c: Client)The example for this item is shown with the ones above: net-socketio-Ack.salam
OnAny
func OnAny(c: Client, cb: func(Event))The example for this item is shown with the ones above: net-socketio-Ack.salam
OffAny
func OffAny(c: Client)The example for this item is shown with the ones above: net-socketio-Ack.salam
EmitArgs
func EmitArgs(c: Client, name: str, a: Args): boolconnect, are refused.The example for this item is shown with the ones above: net-socketio-Ack.salam
EmitVolatile
func EmitVolatile(c: Client, name: str, a: Args): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
Emit
func Emit(c: Client, name: str): boolThe example for this item is shown with the ones above: net-socketio-Client.salam
EmitStr
func EmitStr(c: Client, name: str, s: str): boolThe example for this item is shown with the ones above: net-socketio-Client.salam
EmitInt
func EmitInt(c: Client, name: str, n: i64): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
EmitFloat
func EmitFloat(c: Client, name: str, n: f64): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
EmitBool
func EmitBool(c: Client, name: str, b: bool): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
EmitJSON
func EmitJSON(c: Client, name: str, raw: str): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
EmitBytes
func EmitBytes(c: Client, name: str, ptr: void*, n: int): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
EmitAck
func EmitAck(c: Client, name: str, a: Args, timeout_ms: int): AckThe example for this item is shown with the ones above: net-socketio-Client.salam
EmitWithAck
func EmitWithAck(c: Client, name: str, a: Args, timeout_ms: int, cb: func(Ack)): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
Reply
func Reply(ev: Event, a: Args): boolThe example for this item is shown with the ones above: net-socketio-Client.salam
ReplyJSON
func ReplyJSON(ev: Event, raw: str): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
ReplyStr
func ReplyStr(ev: Event, s: str): boolThe example for this item is shown with the ones above: net-socketio-Client.salam
ArgCount
func ArgCount(ev: Event): intThe example for this item is shown with the ones above: net-socketio-Ack.salam
Arg
func Arg(ev: Event, i: int): strThe example for this item is shown with the ones above: net-socketio-Client.salam
ArgStr
func ArgStr(ev: Event, i: int): strThe example for this item is shown with the ones above: net-socketio-Client.salam
ArgInt
func ArgInt(ev: Event, i: int): i64The example for this item is shown with the ones above: net-socketio-Ack.salam
ArgFloat
func ArgFloat(ev: Event, i: int): f64The example for this item is shown with the ones above: net-socketio-Ack.salam
ArgBool
func ArgBool(ev: Event, i: int): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
ArgValue
func ArgValue(ev: Event, i: int): value.ValueThe example for this item is shown with the ones above: net-socketio-Ack.salam
ArgIsBinary
func ArgIsBinary(ev: Event, i: int): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
ArgBytes
func ArgBytes(ev: Event, i: int): BytesThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckCount
func AckCount(a: Ack): intThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckArg
func AckArg(a: Ack, i: int): strThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckStr
func AckStr(a: Ack, i: int): strThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckInt
func AckInt(a: Ack, i: int): i64The example for this item is shown with the ones above: net-socketio-Client.salam
AckFloat
func AckFloat(a: Ack, i: int): f64The example for this item is shown with the ones above: net-socketio-Ack.salam
AckBool
func AckBool(a: Ack, i: int): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckIsBinary
func AckIsBinary(a: Ack, i: int): boolThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckBytes
func AckBytes(a: Ack, i: int): BytesThe example for this item is shown with the ones above: net-socketio-Ack.salam
AckValue
func AckValue(a: Ack, i: int): value.ValueThe example for this item is shown with the ones above: net-socketio-Ack.salam
EventFree
func EventFree(ev &: Event)The example for this item is shown with the ones above: net-socketio-Ack.salam
AckFree
func AckFree(a &: Ack)The example for this item is shown with the ones above: net-socketio-Client.salam
IsConnected
func IsConnected(c: Client): boolThe example for this item is shown with the ones above: net-socketio-Client.salam
Id
func Id(c: Client): strThe example for this item is shown with the ones above: net-socketio-Client.salam
Sid
func Sid(c: Client): strThe example for this item is shown with the ones above: net-socketio-Client.salam
Namespace
func Namespace(c: Client): strThe example for this item is shown with the ones above: net-socketio-Client.salam
Recovered
func Recovered(c: Client): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
Transport
func Transport(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
LastError
func LastError(c: Client): strThe example for this item is shown with the ones above: net-socketio-Ack.salam
Buffered
func Buffered(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
Attempts
func Attempts(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
EndpointOf
func EndpointOf(c: Client): EndpointThe example for this item is shown with the ones above: net-socketio-Manager.salam
Send
func Send(c: Client, msg: str): boolmessage event with one string; like send in JavaScript.The example for this item is shown with the ones above: net-socketio-Ack.salam
PrependAny
func PrependAny(c: Client, cb: func(Event))OnAny, but called before the others.The example for this item is shown with the ones above: net-socketio-Ack.salam
OnAnyOutgoing
func OnAnyOutgoing(c: Client, cb: func(Event))The example for this item is shown with the ones above: net-socketio-Ack.salam
PrependAnyOutgoing
func PrependAnyOutgoing(c: Client, cb: func(Event))The example for this item is shown with the ones above: net-socketio-Ack.salam
OffAnyOutgoing
func OffAnyOutgoing(c: Client)The example for this item is shown with the ones above: net-socketio-Ack.salam
ListenerCount
func ListenerCount(c: Client, name: str): intThe example for this item is shown with the ones above: net-socketio-Client.salam
HasListeners
func HasListeners(c: Client, name: str): boolThe example for this item is shown with the ones above: net-socketio-Client.salam
AnyListenerCount
func AnyListenerCount(c: Client): intThe example for this item is shown with the ones above: net-socketio-Ack.salam
Disconnected
func Disconnected(c: Client): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
Active
func Active(c: Client): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
Pending
func Pending(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
Queued
func Queued(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
TransportName
func TransportName(c: Client): strwebsocket or polling.The example for this item is shown with the ones above: net-socketio-Client.salam
PingInterval
func PingInterval(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
PingTimeout
func PingTimeout(c: Client): intThe example for this item is shown with the ones above: net-socketio-Options.salam
MaxPayload
func MaxPayload(c: Client): intThe example for this item is shown with the ones above: net-socketio-Manager.salam
SetAuth
func SetAuth(c: Client, auth json: str)The example for this item is shown with the ones above: net-socketio-Manager.salam
AuthOf
func AuthOf(c: Client): strThe example for this item is shown with the ones above: net-socketio-Manager.salam
SetReconnection
func SetReconnection(m: Manager, enabled: bool)The example for this item is shown with the ones above: net-socketio-Manager.salam
SetReconnectionAttempts
func SetReconnectionAttempts(m: Manager, n: int)The example for this item is shown with the ones above: net-socketio-Manager.salam
SetReconnectionDelay
func SetReconnectionDelay(m: Manager, ms: int)The example for this item is shown with the ones above: net-socketio-Manager.salam
SetReconnectionDelayMax
func SetReconnectionDelayMax(m: Manager, ms: int)The example for this item is shown with the ones above: net-socketio-Manager.salam
SetRandomizationFactor
func SetRandomizationFactor(m: Manager, percent: int)The example for this item is shown with the ones above: net-socketio-Manager.salam
SetTimeout
func SetTimeout(m: Manager, ms: int)The example for this item is shown with the ones above: net-socketio-Manager.salam
OptionsOf
func OptionsOf(m: Manager): OptionsThe example for this item is shown with the ones above: net-socketio-Manager.salam
Sockets
func Sockets(m: Manager): Vector<Client>The example for this item is shown with the ones above: net-socketio-Manager.salam
Open
func Open(m: Manager): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
IsOpen
func IsOpen(m: Manager): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
ManagerError
func ManagerError(m: Manager): strThe example for this item is shown with the ones above: net-socketio-Manager.salam
Refused
func Refused(c: Client): boolThe example for this item is shown with the ones above: net-socketio-Manager.salam
RefusalReason
func RefusalReason(c: Client): strThe example for this item is shown with the ones above: net-socketio-Manager.salam