Available

amalgame-net-websocket

RFC 6455 WebSocket client: text frames over ws://.

amc package add net-websocket GitHub ↗ ← Back to the ecosystem

Overview

WebSocket client (RFC 6455) over plain TCP (ws://). The SHA-1 + Base64 handshake is computed inside the package, without OpenSSL.

Features

  • ✓RFC 6455 client (no server)
  • ✓Text frames only
  • ✓Automatic pong to server pings
  • ✓Close frame sent by Close and honored on receipt

Planned for v0.2: wss:// (TLS).

Example

Minimal usage example — copy-paste runnable after install.

amc package add net-websocket

import Amalgame.Net.WebSocket

public class Program {
    public static void Main(string[] args) {
        let ws = WebSocket.Connect("echo.example.com", 80, "/ws")
        if (ws == null) {
            Console.WriteLine("connect failed")
            return
        }
        WebSocket.SendText(ws, "hello")
        let reply: string = WebSocket.ReceiveText(ws)
        Console.WriteLine("got: " + reply)
        WebSocket.Close(ws)
    }
}

At a glance

Related packages