From b18e28038870e7bc35087f9fdf33b2b41cb9480d Mon Sep 17 00:00:00 2001 From: Alexander Guryanov Date: Mon, 18 Nov 2024 13:12:28 +0300 Subject: [PATCH] update networking docs --- advanced-topics.html | 2 +- browser.html | 2 +- cloud-overview.html | 2 +- cloud-storage.html | 2 +- command-interface.html | 2 +- contributing-emulators.html | 2 +- create-a-game-bundle.html | 2 +- deployment.html | 2 +- documentation.html | 2 +- dos-api.html | 2 +- dosbox-direct.html | 2 +- dosbox-worker.html | 2 +- dosbox-x.html | 2 +- doszone.html | 2 +- emulators.html | 2 +- estimating-performance.html | 2 +- fork-drive.html | 2 +- getting-started.html | 2 +- install-windows.html | 2 +- jsdos-bundle.html | 2 +- mobile-support-v7.html | 2 +- mobile-support.html | 2 +- mouse-locking.html | 2 +- multiple-instances.html | 2 +- need-help.html | 2 +- networking.html | 4 ++-- node.html | 2 +- overview.html | 2 +- player-api.html | 26 +++++++++++++++----------- pure-js.html | 2 +- releases.html | 2 +- run-without-bundle.html | 2 +- save-load-game-progress.html | 2 +- save-load.html | 2 +- sockdrive.html | 2 +- subscription.html | 2 +- support-us.html | 2 +- system-images.html | 2 +- threejs.html | 2 +- v7.html | 2 +- virtual-keyboard.html | 2 +- working-with-fs.html | 2 +- 42 files changed, 57 insertions(+), 53 deletions(-) diff --git a/advanced-topics.html b/advanced-topics.html index 547afa0e..e4dc1bac 100644 --- a/advanced-topics.html +++ b/advanced-topics.html @@ -1,5 +1,5 @@ -

js-dos 8.xx Help

Networking

Some DOS games offer multiplayer gaming based on ipx, modem, or direct connection. Using a browser isn't possible to directly connect two clients. BUT, using js-dos cloud, you can emulate direct connection.

Here is tutorial video how to use networking with js-dos:

By default, users able to enjoy these games using the Netherlands server, which is provided by js-dos.

Deploy own ipx backend

As said js-dos provide Netherlands server for free, but it works well only for Europe region. To improve player experience you can deploy own instance of ipx backend.

The Server

The server code is licensed under GPL2 and you can find it here. This server works as relay it connects multiple js-dos clients together. You need to deploy it on some public available server.

  1. Download the server binary

  2. Run it as follows:

    ./server -c cert.pem -k privkey.pem -

    Argument

    Description

    ./server

    server binary

    -c cert.pem

    path to SSL certificate

    -k privekey.pem

    path to private key file

Configuring js-dos player

When server is started you can use it with js-dos player. For example, if your server is available on host myipx.com, js-dos configuration will be:

+

Argument

Description

./server

server binary

-c cert.pem

path to SSL certificate

-k privekey.pem

path to private key file

Configuring js-dos player

When server is started you can use it with js-dos player. For example, if your server is available on host myipx.com, js-dos configuration will be:

const params = new URLSearchParams(location.search); // ... Dos(el, { diff --git a/node.html b/node.html index 0d7b74ec..1ae2bd68 100644 --- a/node.html +++ b/node.html @@ -1,5 +1,5 @@ -

js-dos 8.xx Help

Player API

js-dos player provides a single entry point a Dos function, it takes two arguments:

  1. element where to create a player window

  2. options object to configure player

Dos(element: HTMLDivElement, options: DosOptions) => DosProps; -

It returns DosProps to a control created player

Options

option

description

type

default

url

url to js-dos bundle

URL

dosboxConf

if you omit url this will be used to configure DOSBox example

str

jsdosConf

additionally to dosboxConf you can provide jsdos configuration (jsdos.json)

Object

{}

initFs

additional files to init FS, read more

Array< { path: string, contents: Uint8Array } >

background

background image of player window

URL

pathPrefix

a way to set different path for emulators deployment

str

theme

the color theme of player

light, dark, cupcake, bumblebee, emerald, corporate, synthwave, retro, cyberpunk, valentine, halloween, garden, forest, aqua, lofi, pastel, fantasy, wireframe, black, luxury, dracula, cmyk, autumn, business, acid, lemonade, night, coffee, winter

light

lang

language

en, ru

auto

backend

default backend

dosbox, dosboxX

dosbox

backendLocked

possibility to change backend from UI

bool

false

backendHardware

reserved

-

workerThread

use Worker

bool

true

mouseCapture

lock the mouse in player window

bool

false

server

ipx server

netherlands, newyork, singapore

netherlands

room

ipx room

str

fullScreen

auto enter fullscreen mode

bool

false

onEvent

listener of js-dos events

function

autoStart

automatically starts emulation

boolean

false

kiosk

switch kiosk mode, in kiosk mode player ui is hidden

boolean

false

imageRendering

image rendering mode

pixelated, smooth

pixelated

renderBackend

the way to render dos screen

webgl, canvas

webgl

renderAspect

change the aspect of output window

AsIs, 1/1, 5/4, 4/3, 16/10, 16/9, Fit

AsIs

noNetworking

hide networking button

bool

true

noCloud

disable cloud feature

bool

false

key

set the key to access cloud services

string

scaleControls

set scale of controls

number

0.2

mouseSensitivity

set mouse sensitivity

number

1.0

noCursor

show/hide system cursor

bool

false

volume

set sound volume

number [0..1]

1.0

softKeyboardLayout

initial virtual keyboard layout, read more

srting[]

qwerty

softKeyboardSymbols

initial virtual keyboard symbols

map[]

en, ru

DosProps

DosProps is a properties that you can use to control player after creation, use it like this:

+

It returns DosProps to a control created player

Options

option

description

type

default

url

url to js-dos bundle

URL

dosboxConf

if you omit url this will be used to configure DOSBox example

str

jsdosConf

additionally to dosboxConf you can provide jsdos configuration (jsdos.json)

Object

{}

initFs

additional files to init FS, read more

Array< { path: string, contents: Uint8Array } >

background

background image of player window

URL

pathPrefix

a way to set different path for emulators deployment

str

theme

the color theme of player

light, dark, cupcake, bumblebee, emerald, corporate, synthwave, retro, cyberpunk, valentine, halloween, garden, forest, aqua, lofi, pastel, fantasy, wireframe, black, luxury, dracula, cmyk, autumn, business, acid, lemonade, night, coffee, winter

light

lang

language

en, ru

auto

backend

default backend

dosbox, dosboxX

dosbox

backendLocked

possibility to change backend from UI

bool

false

backendHardware

reserved

-

workerThread

use Worker

bool

true

mouseCapture

lock the mouse in player window

bool

false

ipx

ipx backend configuration (networking)

Object[]

ipxBackend

ipx backend name (should be one from ipx array)

str

netherlands

room

ipx room

str

fullScreen

auto enter fullscreen mode

bool

false

onEvent

listener of js-dos events

function

autoStart

automatically starts emulation

boolean

false

kiosk

switch kiosk mode, in kiosk mode player ui is hidden

boolean

false

imageRendering

image rendering mode

pixelated, smooth

pixelated

renderBackend

the way to render dos screen

webgl, canvas

webgl

renderAspect

change the aspect of output window

AsIs, 1/1, 5/4, 4/3, 16/10, 16/9, Fit

AsIs

noNetworking

hide networking button

bool

true

noCloud

disable cloud feature

bool

false

key

set the key to access cloud services

string

scaleControls

set scale of controls

number

0.2

mouseSensitivity

set mouse sensitivity

number

1.0

noCursor

show/hide system cursor

bool

false

volume

set sound volume

number [0..1]

1.0

softKeyboardLayout

initial virtual keyboard layout, read more

str[]

qwerty

softKeyboardSymbols

initial virtual keyboard symbols

map[]

en, ru

DosProps

DosProps is a properties that you can use to control player after creation, use it like this:

cost props = Dos(elem, options); props.setFullScreen(true); // switch to fullscreen mode -

property

description

arguments

setTheme

switch player theme

theme name

setLang

change language

en, ru

setBackend

change backend

dosbox, dosboxX

setBackendLocked

change is backend locked or not

bool

setWorkerThread

select execution mode

bool

setMouseCapture

set is mouse captured or not

bool

setServer

change ipx server

str

setRoom

change ipx room

str

setFrame

open named sidebar panel

network

setBackground

change background image

URL

setFullScreen

change fullscreen mode

bool

setAutoStart

change auto start

bool

setKiosk

change kisok mode

bool

setImageRendering

change image rendering

pixelated, smooth

setRenderBackend

change render backend (available only before emulation start)

webgl

setRenderAspect

change render aspect

AsIs, 1/1, 5/4, 4/3, 16/10, 16/9, Fit

setNoNetworking

show/hide networking button

bool

setNoCloud

disable/enable cloud feature

bool

setKey

set key to access cloud services

string / null

setScaleControls

set scale of controls

number

setMouseSensitivity

set mouse sensitivity

number

setPaused

pause/resume emulation

bool

setNoCursor

show/hide system cursor

bool

setVolume

set sound volume

number [0..1]

setSoftKeyboardLayout

set virtual keyboard layout

string[]

setSoftKeyboardSymbols

set virtual keyboard symbols

map[]

save

trigger to save changes in FS, return Promise<boolean>

-

stop

kill the emulation (use to stop player)

-

Events

You can listen to js-dos event by providing listener in Dos function:

+

property

description

arguments

setTheme

switch player theme

theme name

setLang

change language

en, ru

setBackend

change backend

dosbox, dosboxX

setBackendLocked

change is backend locked or not

bool

setWorkerThread

select execution mode

bool

setMouseCapture

set is mouse captured or not

bool

setIpx

change ipx backends (networking)

Object[]

setIpxBackend

change ipx backend

str

setRoom

change ipx room

str

setFrame

open named sidebar panel

network

setBackground

change background image

URL

setFullScreen

change fullscreen mode

bool

setAutoStart

change auto start

bool

setKiosk

change kisok mode

bool

setImageRendering

change image rendering

pixelated, smooth

setRenderBackend

change render backend (available only before emulation start)

webgl

setRenderAspect

change render aspect

AsIs, 1/1, 5/4, 4/3, 16/10, 16/9, Fit

setNoNetworking

show/hide networking button

bool

setNoCloud

disable/enable cloud feature

bool

setKey

set key to access cloud services

string / null

setScaleControls

set scale of controls

number

setMouseSensitivity

set mouse sensitivity

number

setPaused

pause/resume emulation

bool

setNoCursor

show/hide system cursor

bool

setVolume

set sound volume

number [0..1]

setSoftKeyboardLayout

set virtual keyboard layout

string[]

setSoftKeyboardSymbols

set virtual keyboard symbols

map[]

save

trigger to save changes in FS, return Promise<boolean>

-

stop

kill the emulation (use to stop player)

-

Events

You can listen to js-dos event by providing listener in Dos function:

Dos(elem, { onEvent: (event , ci?: [[[CommandInterface|command-interface.html]]]) => { console.log("js-dos event", event); } }); -

order

event

description

args

0

emu-ready

when emulators are fully loaded and ready to run the program

1

bnd-play

when play button is clicked

2

ci-ready

when backend is started and CommandInterface is available

CommandInterface

Stop/Restart player

  • To stop player and free all used resources, please call props.stop(), after this player is totally disposed.

  • To restart player dispose current player and start new one.

Typescript

js-dos provide Typescript types declaration. Just put it somewhere in your codebase, and declare Dos function:

+

order

event

description

args

0

emu-ready

when emulators are fully loaded and ready to run the program

1

bnd-play

when play button is clicked

2

ci-ready

when backend is started and CommandInterface is available

CommandInterface

Stop/Restart player

  • To stop player and free all used resources, please call props.stop(), after this player is totally disposed.

  • To restart player dispose current player and start new one.

Typescript

js-dos provide Typescript types declaration. Just put it somewhere in your codebase, and declare Dos function:

import {DosFn} from "types"; declare const Dos: DosFn; @@ -59,6 +59,11 @@ export type InitFsEntry = InitBundleEntry | InitFileEntry; export type InitFs = InitFsEntry | InitFsEntry[]; +export interface NamedHost { + name: string, + host: string, +} + export interface DosOptions { url: string, dosboxConf: string, @@ -74,17 +79,15 @@ lang: "ru" | "en", backend: "dosbox" | "dosboxX", backendLocked: boolean, - backendHardware: ((backend: "dosbox" | "dosboxX") => Promise<string | null>), + backendHardware: ((backend: "dosbox" | "dosboxX", sockdriveNative: boolean) => Promise<string | null>), workerThread: boolean, mouseCapture: boolean, onEvent: (event: DosEvent, ci?: any /* CommandInterface */) => void, - server: "netherlands" | "newyork" | "singapore", + ipx: NamedHost[], + ipxBackend: string, room: string, fullScreen: boolean, - sockdriveBackend: { - name: string, - host: string, - }, + sockdriveBackend: NamedHost, autoStart: boolean, kiosk: boolean, imageRendering: ImageRendering, @@ -108,7 +111,8 @@ setBackendLocked(locked: boolean): void; setWorkerThread(capture: DosOptions["workerThread"]): void; setMouseCapture(capture: DosOptions["mouseCapture"]): void; - setServer(server: DosOptions["server"]): void; + setIpx(ipx: DosOptions["ipx"]): void; + setIpxBackend(backend: string): void; setRoom(room: DosOptions["room"]): void; setFrame(frame: "network"): void; setBackground(background: string | null): void; diff --git a/pure-js.html b/pure-js.html index 9f3efb3c..0b8e2257 100644 --- a/pure-js.html +++ b/pure-js.html @@ -1,5 +1,5 @@ -