mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-06-27 16:10:34 +08:00
2b6a9bcb966da1de18179da0b428d38ff93e51da
GarageServer.IO
A simple, lightweight, HTML multiplayer game server (and client) for Node.js
Features
- Authoritative Game Server
- Client Side / Input Prediciton
- Client Side Smooting
- Entity Interpolation
- Server State History
- Server and Client Messaging
Quick Start
Client
Server
API
Client
GarageServerIO.initializeGarageServer(path, options)
options = {
onPlayerConnect(callback),
onPlayerDisconnect(callback),
onPlayerReconnect(callback),
onPlayerUpdate(callback(state)),
onEntityUpdate(callback(state)),
onPlayerRemove(callback(id)),
onEntityRemove(callback(id)),
onEvent(callback(data)),
onWorldState(callback(state)),
onPing(callback(pingDelay)),
onUpdatePlayerPhysics(callback(state, inputs, deltaTime)),
onInterpolation(callback(previousState, targetState, amount)) : newState,
onReady(callback),
logging: true
}
GarageServerIO.addInput(input)
GarageServerIO.getStates(callback([player1State, player2State, ...], [entity1State, entity2State, ...]))
GarageServerIO.getId() : playerid
GarageServerIO.sendServerEvent(data)
Server
require('.garageserver.io').createGarageServer(io, options) : GarageServerIO
options = {
stateInterval: 45,
logging: true,
clientSidePrediction: true,
interpolation: true,
interpolationDelay: 100,
smoothingFactor: 0.3,
pingInterval: 2000,
maxUpdateBuffer: 120,
maxHistorySecondBuffer: 1000,
worldState: {},
onPlayerConnect(callback(socket)),
onPlayerInput(callback(socket, input)),
onPlayerDisconnect(callback(socket)),
onPing(callback(socket, data)),
onEvent(callback(data))
}
GarageServerIO.start()
GarageServerIO.stop()
GarageServerIO.getPlayers() : [{ id, state, [input1, input2,...], [{ state1, executionTime1 }, { state2, executionTime2 }, ...] }]
GarageServerIO.getEntities() : [{ id, state, [{ state1, executionTime1 }, { state2, executionTime2 }, ...] }]
GarageServerIO.updatePlayerState(id, state)
GarageServerIO.updateEntityState(id, state)
GarageServerIO.addEntity(id)
GarageServerIO.removeEntity(id)
GarageServerIO.sendPlayerEvent(id, data)
GarageServerIO.sendPlayersEvent(data)
Resources
License
Description
Languages
JavaScript
97.7%
Pug
1.5%
CSS
0.8%