rtcnet

package module
v0.0.0-...-7e430b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 15 Imported by: 1

README

Go Reference

WebRTC Networking

This is my attempt at building and easy to use, client-server webrtc-based net.Conn implementation. Feel free to use it and file bug reports. I am by no means a webrtc expert, so if you see any problems with my implementation, then feel free to open an issue! Happy to answer any questions as needed!

Notes

  1. This is for client-server connections only! The main use case is if you want to use webrtc sockets in browser, but don't want to deal with the entire webrtc stack
  2. The connection is signaled over Websockets, so you don't need to use any ICE servers.

Platforms

I've tested this on:

  1. Browsers (Firefox, Chrome, Edge)
  2. Linux (desktop app)
  3. Windows (desktop app)

Things that I still need to do, but haven't yet

  • Replace logger with injectable logger interface
  • Ability for user to select the level of reliability/orderdness that they want on the data channel
  • Close websocket after webrtc negotiation has completed (currently ws stays open until net.Conn is closed)

Usage

import "github.com/unitoftime/rtcnet"

See Example

Used By

  1. I'm currently using this for an online game I'm building for browser. You can find it here

License

  1. MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(newLogger zerolog.Logger)

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func Dial

func Dial(address string, tlsConfig *tls.Config, ordered bool, iceServers []string) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type ListenConfig

type ListenConfig struct {
	TlsConfig      *tls.Config
	OriginPatterns []string
	IceServers     []string
}

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

func NewListener

func NewListener(address string, config ListenConfig) (*Listener, error)

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL