web.livekit.meet #
LiveKit Meet
V implementation of livekit meet. This server handles the backend of livekit meet, and serves prebuilt front end from a v web server.
The templates and static assets in this repo are thus overwritten frequently. The recommended approach is to use the build script in the original repository to make changes to the app. The app, when run, automatically downloads latest pushed templates from the github pages of livekit_meet, which we use sort of like a cdn for the purpose of this project. Note: after updateing templates by rebuilding and pushing original react app, this app must be run twice (first one fetches templates, second one compiles with updated templates)
Example
~/code/github/freeflowuniverse/crystallib/examples/webserver/livekit/meet_example.vsh
fn build #
fn build(config BuildConfig) !
fn new #
fn new(config AppConfig) &App
Main entry point
fn new_access_token #
fn new_access_token(api_key string, api_secret string, options AccessTokenOptions) !AccessToken
Constructor for AccessToken
fn new_token_verifier #
fn new_token_verifier(api_key string, api_secret string) !TokenVerifier
Constructor for TokenVerifier
fn update_templates #
fn update_templates() !
type TTLValue #
type TTLValue = int | string
TTLValue represents either seconds as int or duration as string
struct AccessToken #
struct AccessToken {
mut:
api_key string
api_secret string
grants ClaimGrants
identity string
ttl TTLValue
}
AccessToken class
fn (AccessToken) add_video_grant #
fn (mut token AccessToken) add_video_grant(grant VideoGrant)
Method to add a video grant to the token
fn (AccessToken) to_jwt #
fn (token AccessToken) to_jwt() !string
Method to generate a JWT token
struct AccessTokenOptions #
struct AccessTokenOptions {
pub mut:
ttl TTLValue // TTL in seconds or a time span (e.g., '2d', '5h')
name string // Display name for the participant
identity string // Identity of the user
metadata string // Custom metadata to be passed to participants
}
Define AccessTokenOptions struct
struct App #
struct App {
veb.StaticHandler
pub:
build_url string = 'https://freeflowuniverse.github.io/livekit_meet' // the url in which the next.js application is built
asset_prefix string = '/static'
livekit_url string @[required]
api_key string
api_secret string
}
App struct with livekit.Client
, API keys, and other shared data
fn (App) custom #
fn (app &App) custom(mut ctx Context) veb.Result
fn (App) download_static #
fn (app App) download_static() !
fn (App) download_templates #
fn (app App) download_templates() !
fn (App) index #
fn (app &App) index(mut ctx Context) veb.Result
fn (App) install #
fn (app App) install() !
fn (App) participant_endpoint #
fn (app &App) participant_endpoint(mut ctx Context) veb.Result
GET endpoint to handle participant token generation
fn (App) room #
fn (app &App) room(mut ctx Context) veb.Result
fn (App) run #
fn (mut app App) run(params RunParams)
struct AppConfig #
struct AppConfig {
pub:
livekit_url string @[required]
livekit_api_key string @[required]
livekit_api_secret string @[required]
}
struct BuildConfig #
struct BuildConfig {
pub:
repo_url string = 'https://github.com/freeflowuniverse/livekit_meet' // url of the livekit meet app repository
static_url string = 'https://freeflowuniverse.github.io/livekit_meet' // url of where the static assets are served
base_path string // base path of app (ie: /meet if root is /meet)
livekit_url string @[required]
livekit_api_key string @[required]
livekit_api_secret string @[required]
}
struct ClaimGrants #
struct ClaimGrants {
pub mut:
video VideoGrant
iss string
exp i64
nbf int
sub string
name string
}
Struct representing grants
struct ConnectionDetails #
struct ConnectionDetails {
server_url string @[json: 'serverUrl']
room_name string @[json: 'roomName']
participant_token string @[json: 'participantToken']
participant_name string @[json: 'participantName']
}
Struct for ConnectionDetails
struct Context #
struct Context {
veb.Context
}
Context struct embedding veb.Context
fn (Context) not_found #
fn (mut ctx Context) not_found() veb.Result
Custom 404 handler
struct Lobby #
struct Lobby {
pub:
rooms []Room
meetings []Meeting
}
fn (Lobby) html #
fn (lobby Lobby) html() string
struct Meet #
struct Meet {}
fn (Meet) html #
fn (meet Meet) html() string
struct Meeting #
struct Meeting {}
struct Room #
struct Room {
pub:
url string
id string
name string
creation_time time.Time
num_participants int
is_active bool
metadata string
}
fn (Room) html #
fn (room Room) html() string
struct RunParams #
struct RunParams {
pub:
port int = 8080
}
struct TokenVerifier #
struct TokenVerifier {
api_key string
api_secret string
}
TokenVerifier class
fn (TokenVerifier) verify #
fn (verifier TokenVerifier) verify(token string) !ClaimGrants
Method to verify the JWT token
struct VideoGrant #
struct VideoGrant {
pub mut:
room string
room_join bool @[json: 'roomJoin']
room_list bool @[json: 'roomList']
can_publish bool @[json: 'canPublish']
can_publish_data bool @[json: 'canPublishData']
can_subscribe bool @[json: 'canSubscribe']
}
VideoGrant struct placeholder
- README
- fn build
- fn new
- fn new_access_token
- fn new_token_verifier
- fn update_templates
- type TTLValue
- struct AccessToken
- struct AccessTokenOptions
- struct App
- struct AppConfig
- struct BuildConfig
- struct ClaimGrants
- struct ConnectionDetails
- struct Context
- struct Lobby
- struct Meet
- struct Meeting
- struct Room
- struct RunParams
- struct TokenVerifier
- struct VideoGrant