GithubHelp home page GithubHelp logo

webzocket's Introduction

webzocket

A very dumb websocket client, but it works! And not only it works, it even works with TLS and has a simple API.

Installation

Add this to the .dependencies section in your build.zig.zon file:

.webzocket = .{
  .url = "https://github.com/trailriver/webzocket/archive/refs/tags/v0.0.1.tar.gz",
  .hash = "1220653b2f726203cd07c1b9a5ce8adc07a1358f1658a26a7b1362384887143dad7a"
}

And something like this to your build.zig file:

const webzocket = b.dependency("webzocket", .{
    .target = target,
    .optimize = optimize,
});

// ...

exe.addModule("webzocket", webzocket.module("webzocket"))

Usage

const std = @import("std");
const wz = @import("webzocket");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();

    var client = wz.client.init(gpa.allocator());
    defer client.deinit();

    var conn = try client.connect("wss://ws.ifelse.io"); // an echo server
    defer conn.deinit();

    try conn.send("hello");
    try conn.send("world");

    var hello = try conn.receive();
    var world = try conn.receive();

    std.debug.print("{} {}\n", .{hello, world});
}

webzocket's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.