No description
Find a file
2023-02-26 18:07:37 +05:30
examples Initial commit. 2022-12-30 15:05:47 +05:30
src Intermediate changes: Fix bugs. 2023-02-26 18:07:37 +05:30
tests More stuff that missed Initial commit. 2022-12-30 16:34:05 +05:30
.nimblebuild Add nimble files. 2022-12-30 15:50:01 +05:30
engineio.nimble More stuff that missed Initial commit. 2022-12-30 16:34:05 +05:30
README.md More stuff that missed Initial commit. 2022-12-30 16:34:05 +05:30

Engine.IO Client Library for Nim

This is a library for connecting to and communicating with an Engine.IO server using Nim. It provides a simple interface for sending and receiving messages over a WebSocket connection.

Installation

To install the library, run the following command:

nimble install engineio

Usage

To use the library, import it and create a new EngineIoClient object:

import engineio

let client = engineio.new("ws://localhost:3000")

You can then use the sendMessage and onEvent procedures to send messages to and receive messages from the server:

# Send a message to the server
engineio.sendMessage(client, "hello", %*{"name": "John"})

# Set up an event handler for the "greeting" event
engineio.onEvent(client, "greeting", (data: JsonNode) =>
  echo "Received greeting from the server: ", data.getStr()
)

API

new(url: string, asyncHandlers = true, threadHandlers = false): EngineIoClient

Creates a new EngineIoClient object and connects to the specified Engine.IO server.

sendMessage(client: EngineIoClient, event: string, data: JsonNode)

Sends a message to the server.

onEvent(client: EngineIoClient, event: string, handler: proc(data: JsonNode))

Registers a handler for the specified event.

License