-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server #26
Comments
Several ways to do this:
client-only (browser) |
@deathcap would love to talk about this with you |
I'm maintaining the voxel-client and voxel-server modules these days, but they are due for some changes, a documentation update, and a hello-world. The modules have been reworked to be agnostic to the transport medium (webrtc, websockets, locally, or whatever you can dream up). The voxel-server can now be run in a browser. Right now the server basically only handles managing connections, sending over initial chunks, maintaining the authoritative version of the world, and forwarding a whitelist of events (eg chat). I then extend that functionality with a project-specific wrapper of the server and client that send and react to additional events. |
Also: If you're planning on doing multiplayer, do it early, b/c it changes the way you do everything else |
Cool thanks, the new voxel-client/server looks great I'll definitely look into it. I ought to get setup with IRC too, someday.. Meanwhile, have been playing around with the Minecraft protocol (https://github.com/deathcap/voxel-clientmc), figured it could help inform what might be needed in a voxel-based game client/server protocol, or how to (or how to not) do things. Used to be much worse but they completely redesigned it for MC 1.7, not too bad. |
Testing running index.js through
|
The plugins could key off the |
Hmm, I guess I don't understand how you have the plugin loading set up |
voxel-plugins iterates over the plugin config map, Added a few more checks, current progress:
|
small correction: its just |
fixed, thx as for the webworker problem, found this: https://github.com/cramforce/node-worker - could be useful for supporting server-side "webworkers" |
…b-bindings-ui, voxel-chest, voxel-console, voxel-debug, voxel-drop, voxel-engine, voxel-fly, voxel-gamemode, voxel-inventory-dialog, voxel-inventory-hotbar, voxel-mine, voxel-player, voxel-plugins, voxel-plugins-ui, voxel-reach, voxel-start, voxel-texture-shader, voxel-voila, voxel-walk, voxel-workbench deathcap/artpacks@4c3883e Add XHR existence check deathcap/inventory-window@262a0e9 Existence check document for non-browser environments deathcap/kb-bindings-ui@dd19d5b Client-only plugin deathcap/kb-bindings-ui@ddce974 Add browser check, enable strict mode voxel/voxel-chest@20fd3e8 Only create ChestDialog if game.isClient voxel/voxel-chest@438cb7e Existence check document for non-browser voxel/voxel-chest@20131af craftingrecipes is a regular dependency voxel/voxel-console@6464501 voxel-console is client-only deathcap/voxel-debug@bf70d6b Client-only plugin voxel/voxel-drop@8680806 voxel-drop is client-only deathcap/voxel-engine@500427b Revert "Increase atlas size to 2048x2048 from 512x512" deathcap/voxel-fly@739d417 client-only for now voxel/voxel-gamemode@90403ff No server-side support yet voxel/voxel-inventory-dialog@939dc56 Only supported on client for now voxel/voxel-inventory-hotbar@c363f2d Refactor into common/client classes for client/server support voxel/voxel-mine@dff4356 Textures only on client deathcap/voxel-player@c904eb0 client-only voxel/voxel-plugins@eb3a34d Add clientOnly flag to pluginInfo voxel/voxel-plugins@7fdd18d Only call voxel-engine notCapable() in browser environment (requires window to check for canvas) voxel/voxel-plugins@7633174 Split instantiate/scanAndInstantiate voxel/voxel-plugins-ui@c8e789b Client-only plugin voxel/voxel-plugins-ui@1b47560 Add browser check voxel/voxel-reach@6f46c4a Client-only checks for interact/mouse events deathcap/voxel-start@dcd0b13 voxel-start is client-only deathcap/voxel-texture-shader@73806ef Increase default atlas size to 2048x2048 voxel/voxel-voila@caf865c voxel-voila is client-only deathcap/voxel-walk@0676bbc voxel-walk is client-only voxel/voxel-workbench@f40689e Only create WorkbenchDialog if game.isClient Commit message generated by https://github.com/deathcap/lmno-cl
Updated all plugins (except one) to at least load on server, if applicable (not necessarily functional). Some are only intended for server, and can be tagged with clientOnly: true for voxel-plugins to skip loading if on server. Others are both client and server - example of client/sever refactoring in voxel/voxel-inventory-hotbar@c363f2d - a shared InventoryHotbarCommon class to store the selected slot index (applicable to both client and server, but maybe should move the selected index to voxel-carry instead), and InventoryHotbarClient inheriting from InventoryHotbarCommon to display the GUI. voxel-land remains a problem due to its use of web workers. The NodeJS "web worker" (API) module node-worker has been unmaintained for several years, wouldn't run on 0.10 but updated it so at least the example works at https://github.com/deathcap/node-worker. Spawns a new process for the worker. There may be better solutions nowadays (threads-a-gogo?) |
As of 7c2bdb9 'node index.js' now loads, though doesn't do much (using https://github.com/deathcap/unworkify instead of https://github.com/audreyt/node-webworker-threads on server-side for now) |
Looking into this some more, WebRTC is definitely the way to go (vs WebSockets - though they can still be used for the signaling protocol). Though mainly intended for audio/video (real-time communication), it supports "data channels" as well. Uses UDP if possible for lowest latency, STUN and TURN for compatibility with various network topologies, and is easy to use with https://github.com/rtc-io/rtc-quickconnect and https://github.com/kumavis/rtc-data-stream . References: http://www.youtube.com/watch?v=p2HzZkd2A40 Real-time communication with WebRTC: Google I/O 2013 Another problem: how/when to load the engine. Currently, voxel-plugins loads voxel-engine as the "master" plugin, loaded very first and passed to all plugins. However, both voxel-server and voxel-client load voxel-engine themselves. Tentative design plan:
|
I've been struggling with having the server in the browser in my own projects. It works fine on its own, but when in the same window with a client, it makes that tab lag really bad. I tried to put the server in a webworker, but webRtc primitives are not yet implemented in webworkers (chrome 32.0.1700.77), so I had to pipe all connections across the window/worker divide via |
Hmm, I'm not seeing this lag. Just got voxel-server and voxel-client running together, communicating with themselves over WebRTC locally. Not using webworkers or anything, both run together. I still have the main voxel-engine instance (3 voxel-engine instances total, I need to fix this) though, so amusingly, the stats counter shows double fps: =) presumably since two clients are running simultaneously. Still have to refactor wrt the voxel-plugins system, later, but I'll push what I have if you want to compare. One thing I'm doing differently is passing the voxel-engine module to voxel-client/voxel-server instead of having each add their own voxel-engine dependencies, but I don't think that would matter. Is the serialization/deserialization bottleneck in JSONStream? I noticed serious performance issues with JSON in https://github.com/deathcap/voxel-clientmc - switched to sending binary data ArrayBuffers and parsing the packets on the client. Much faster than JSON decoding large amounts of binary data, at least in that particular instance. Another idea: avoid serialization entirely (when client + server are in same browser tab) by passing the data directly? Instead of through WebRTC or webworkers. This would mean the entire server wouldn't run concurrently from the client, but specific CPU-intensive areas of the server could still be factored out into their own webworkers. For me, the most intensive server task was terrain generation - so https://github.com/deathcap/voxel-land runs it in a worker (https://github.com/rachel-carvalho/voxel-mars also uses workers similarly) |
voxel/voxel-clientmc@1636597 Use bit-twiddle popCount deathcap/voxel-cs@95709e7 Update voxel-client, voxel-server deathcap/voxel-cs@563de76 Attempt to connect client to server stream deathcap/voxel-cs@3f8d3d6 Add voxel-engine dependency, module passed to voxel-server + voxel-client deathcap/voxel-cs@987d281 Start adding client Commit message generated by https://github.com/deathcap/lmno-cl
I wasn't really getting the performance hit until another player joined. For communicating locally I was using // create virtual connection for local player
var clientTransport = Duplex()
var serverTransport = Duplex()
clientTransport.on('_data', function (data) {
process.nextTick(function(){
serverTransport.emit('data',data)
})
})
serverTransport.on('_data', function (data) {
process.nextTick(function(){
clientTransport.emit('data',data)
})
}) I would love to take a look at your multiplayer code, b/c I think this side-by-side client-server setup is important |
Ah, I haven't tried multiple players joining yet. I'll probably hit the same issue then. Will have to see after I fix up voxel-plugins for multiplayer. I'm thinking I'll have voxel-cs (client/server) load as the 'master' plugin, in turn loading voxel-engine. But yeah, agreed side-by-side client/server is crucial. The way I see it, this design will force all plugins to consider client/server separately so there will be no 'singleplayer-only' plugins; everything would have to support multiplayer by design. |
+1 to that. It also allows people's voxel.js hacks to be no-setup and self-scaling. As long as the CDN can handle serving the static content, the game servers are created by the players themselves so you don't have to worry about A) setting up a dedicated server or B) being overwhelmed by a sudden spike. |
To this end, we need to create a multiplayer hello world repo. |
Problem: voxel-client only creates the voxel-engine instance when the server connection is established, but voxel-plugins loads all plugins before then. The voxel-engine game instance is not available at this time.. but the current design for plugins is to pass (game,opts) where game=the voxel-engine instance. Needs more work. Ref voxel/voxelmetaverse#26
Indeed. Running into a lot of interesting issues trying to convert everything at once ;) Think I figured out how to load client/server plugins, though. Separate voxel-plugins instance for client and server (obvious in retrospect, but..). The 'game' variable is either the client or server voxel-engine instance, depending on if loaded from voxel-client or voxel-server. Using a new module I call voxel-fuel to setup these two engines, passed all the plugin options from the top-level application to set it all up. Several fixes in 4ade5f2 but many issues remain:
wondering if it would be faster/simpler to switch to a pure binary protocol..
Long way to go, but its a start. |
Yeah I came up with a similar conclusion regarding the plugins. |
…te inventory-window, voxel-chest, voxel-commands, voxel-console, voxel-fly, voxel-fuel, voxel-inventory-dialog, voxel-inventory-hotbar, voxel-workbench deathcap/inventory-window@9fefff7 0.2.0 deathcap/inventory-window@885300e Update to cube-icon ~0.1.0 deathcap/inventory-window@7805eb8 Update to CoffeeScript 1.7.0 deathcap/inventory-window@b1e48d1 Update cube-icon: add CSS brightness filters to enhance 3D appearance voxel/voxel-chest@6a3d702 Update to inventory-window ~0.2.0 voxel/voxel-commands@99e3a2f Add support for sending and receiving chat messages voxel/voxel-console@928c0d7 Update to CoffeeScript 1.7.0 deathcap/voxel-fly@66e0fc8 Remove unused dependencies deathcap/voxel-fuel@4e1c9dd Add synthetic voxel-client/voxel-server plugin instances to voxel-plugins for other plugins to conveniently access deathcap/voxel-fuel@9cb9b7f Fix creating multiple client instances. Closes GH-3 deathcap/voxel-fuel@5eb7c76 Update to my branch of rtc-data-stream deathcap/voxel-fuel@b3449f8 Add exposeGlobal option for debugging deathcap/voxel-fuel@1f7d383 Catch RTC error, more RTC configuration voxel/voxel-inventory-dialog@83e8043 Update to inventory-window ~0.2.0 voxel/voxel-inventory-hotbar@89fad7f Update to inventory-window ~0.2.0 voxel/voxel-workbench@98057e3 Update to inventory-window ~0.2.0 Commit message generated by https://github.com/deathcap/lmno-cl
@kumavis Sounds awesome. Any interest in compatibility with voxel-plugins? |
…t. Ref GH-26 deathcap/voxel-fuel@6db7fc7 Update voxel-client, voxel-plugins, voxel-server Commit message generated by https://github.com/deathcap/lmno-cl
Server now basically works as of 3259094 (can open same URL+hash in another window, client joins, can see moving around) - though there is still much to be done. Filing separate issues in: https://github.com/deathcap/voxel-fuel/issues?state=open |
@deathcap very interested in compatibility / migrating to your plugin system, though i haven't had a chance to explore it yet. The goal for my project is to have the player build the game as they go, making their own monsters etc, so being able to enable and disable new game plugins at runtime would be a big win. |
@deathcap so what is your goal with |
Essentially, yeah, I see it as a sort of 'reference implementation' including many of the latest voxel.js plugins. Wrote some more about where I'm coming from here: voxel/voxel-land#6 - but ultimately, would like to grow the voxel.js ecosystem so its a very viable platform for building sophisticated voxel-based games |
@deathcap, is it possible to run a multiplayer voxpopuli in the current state? if so, how? |
@ahdinosaur It is supposed to be possible to join a multiplayer game by loading the same URL (with the #room_identifier hash at the end, which is automatically added when 'hosting' a game - i.e., by default) in another browser, however this currently doesn't work because I swapped out the rtc.io signaller for an in-memory messenger deathcap/voxel-fuel@667c3ea for development (to avoid hitting the remote server while testing). Suppose I should restore it but multiplayer is still in a very primitive state ref #40 |
Note: removed server for now in 216c390 |
After sleeping on this for a while, I'm now thinking the way forward is to work towards Minecraft-protocol server compatibility. There is an actively-maintained nodejs protocol module: https://github.com/PrismarineJS/node-minecraft-protocol and command-line api client: https://github.com/andrewrk/mineflayer for MC 1.8, and I previously prototyped a websocket/minecraft proxy (last updated for MC 1.6): https://github.com/deathcap/wsmc which worked alongside a (very incipient) voxel.js plugin: https://github.com/deathcap/voxel-clientmc The downside of this approach is it constrains functionality to match what can be expressed in the MC protocol, so kumavis' nodejs-based voxeljs-specific voxel-client/voxel-server would still be useful, separately, but for this project at least, I think the benefits primarily of compatibility with the vast MC server ecosystem is too good to pass up. Specifically, potential interoperability with at least some of these very interesting server projects:
Next steps: to dust off wsmc and voxel-clientmc, update, voxel/voxel-clientmc#5, etc. |
New server, been working on for a bit as a break from voxel.js: https://github.com/GlowstonePlusPlus/GlowstonePlusPlus (Glowstone++, based on Glowstone as listed above, but with enhancements including switching to the Spigot-Bukkit 1.8.3 API and new features, and compatible with Bukkit2Sponge for partially supporting SpongeAPI plugins). Glowstone++ server works with voxel-clientmc client, built on top of PrismarineJS's node-minecraft-protocol and mineflayer. Usable, can move around, place blocks, though not much else yet. The client is more incomplete, open issues: https://github.com/deathcap/voxel-clientmc/issues and server: https://github.com/GlowstonePlusPlus/GlowstonePlusPlus/issues some in https://github.com/GlowstoneMC/Glowstone/issues |
Ah, this old issue again. Still I think supporting a Minecraft-compatible protocol for server interoperability is the way to go. Re-examining the current landscape, there are at least three compelling open source Minecraft-compatible server projects now:
The MC-compatible server ecosystem is well-covered. Compatible clients, on the other hand...:
|
Update: have since updated voxel-clientmc to 1.8.9, large refactoring, updates to wsmc as well, added Forge support and can run in a Sponge plugin in addition to Bukkit or standalone. Should be relatively straightforward to keep voxel-clientmc updated for MC updates since it largely depends on mineflayer for interpreting the protocol behavior, and node-minecraft-protocol / minecraft-data for packet serialization. As long as those projects continue to be actively maintained, should be feasible to update voxel-clientmc. Active development in voxel-clientmc-app instead of here, but could transition voxelmetaverse to be essentially a voxel-clientmc client, once there is voxel/voxel-clientmc#29 server selection UI. Until then, developing in voxel-clientmc-app because its included server-side plugins make testing with a server more convenient. Going forward, plugins requiring client/server support e.g. voxel-workbench could be updated to integrate with voxel-clientmc as the backend voxel/voxel-clientmc#23. Plugins like voxel-land could be transitioned to server-side, perhaps recast as flying-squid plugins. |
No description provided.
The text was updated successfully, but these errors were encountered: