We are building some installation of a multiplayer game. Our computer (running a node.js server) projects the game on a large screen and the players connect with their mobiles through websockets (html5). We already figured out the client side (no need for animation there, only some buttons inputs), the question is how to connect the game visualization on the server side (either in processing or processing.js) with the clients. In particular:
can the server side javascript, which runs outside of a browser (from the terminal, using node.js) supports canvas-like graphics (eg., using raphael or processing.js) ?
alternatively, how can a processing sketch running on the server machine connect with nodejs?
any other solutions are welcome - thanks!
jonathan
You need three parts here.
clients with buttons, which you already have
a node.js server, which you already have
client with your game running in a browser on your wall.
Both (1) and (3) set up a websocket connection to node.js, and then you have node.js accept player input from (1), which it then sends to (3). The page at (3) should have the sketch running with a JS binding, and have a socket data handling function, so that when the handler function sees data coming from node, it can pass that on into your sketch, which can then update itself according to the input.
You don't need to run the game server-side, just run it client side using Processing.js (I assume your game is in Processing because of the tags you used for the question)
Related
I want to create LUDO game using MERN stack and socket.io . can anyone suggest me how to do this ?
I need guidance that how can I build a game like LUDO
Answer is assuming you want to understand role of various tech for the project.
Create React(for web) or React native (for mobile apps) Project with Socket.IO client library and any other library(component or css).
Create a backend project with express and MongoDB, where express will handle the connections from ReactJS application and all the data (score and game records will be stored in mongodb.)
Socket library will be used to create a full-duplex connection for real-time connection.
React project would basically be a rendering medium of the actual board, that'll be present on the server.
Server will host single or multiple rooms in which players will be able to join and leave, and play the game(moves and all). Each room will maintain it's state (score, turn, win/loose etch).
Each time a player makes a move, event would be emitted from React project and received & processed by the server and then new resultant event will be emitted and that'll be processed by the react client.
This loop of event will continue till the player is in a game or in the app(depending on how you implement it)
I have a nodejs app that is acting as a server that's controlling multiple industrial machines and I want to make a dashboard with electron that presents real time data of the various machine's states (this information being stored on the server). How can I establish some sort of connection between my nodejs server and my electron application/dashboard (and update its contents accordingly)?
I have written a similar Electron app, in my case, an app that periodically interrogates an application over the network that is connected to / controls an HF Amateur radio via a raw Socket.
From the electron app's main.js, I start up a service that polls the radio control application over the Socket. In your case, I'm assuming the would be an http client.
When the response comes back, I use Electron's ipcRenderer to push the data from the main electron process to the GUI app, in your case, your dashboard.
The connection code is a bit complex, due to the need to reconnect automatically if the connection is dropped (e.g. the radio is turned off, and then turned back on), but for an example, you can have a look at my repo.
I have a linux machine on which I want to run a local server using ExpressJS. To that machine a couple of instruments are connected via a USB-to-RS485-adapter which can be controlled and updated using NodeJS. What I want to do is display a live status feed of the instruments (mostly pressure gauges) and update some graphs that display the current pressure that the gauges are measuring. I already have a Server that runs ExpressJS, but I don't know how to make the Node code for controlling the hardware influence the status. Do I have to run the node code server side and then send data to the client with socket.io or is there some easier way. I'm completely new to expressJS and webapps, so it would be nice if you could point me in the right direction and explain to me how that works.
Express is a framework to make a web server, while very good for what it does, real time is not what it does.
Instead, socket.io is really good at real time transmissions.
What you should do is serve your "status" page with Express, page that connect to socket.io and subscribe for your "data" event.
Then all you have to do is, when you retrieve the data, send event with socket.io to make the data appear in near real-time on the web page.
this is my first post here so I hope I do well.
So, for a school project I'm handling our game's networking and we have chosen to create a multiplayer fighting game where users are able to use their phones as controllers. Originally, we were going to use phone mobile browsers and so I had some crazy Websocket server, TCP server combination going on.
Since then, we have decided to use a Unity app on the phone instead which has removed the need for the Websocket server. Before I explain the steps, these are two Github gists of the relevant code snippets that you can open in other tabs in order for this to be a bit easier to follow:
NodeJS TCP Server: https://gist.github.com/JesseLeitch/dce3f51eea893ea5872c
Unity TCP Client: https://gist.github.com/JesseLeitch/59212d34a6fad41a2efc
Now, my problem:
I will walk through the process here:
1) I start up my NodeJS TCP server on my laptop.
2) I start up a Unity game, receiving a message from the server that it has connected.
3) My team mate starts up a Unity "game"(it's our controller) on his laptop that connects to the server with a successful connection message once again from the server.
4) My friend presses a button on the controller.
5) The button sends a message to the server. For example, "Jump".
6) Here is where my problem arises. What should happen is the server then sends the message down to the game, the message is processed within the OpenStream function and then it is passed off to a movement script. This is not happening. Nothing is being read in the game and I do not know why.
I know that the writing function is working fine because the console.log on line 14 is outputting properly with his command. What I am unsure of is why the c.write(d) is not seemingly working properly - especially because this worked previously when I was using our previous Game <-> TCP <-> WS <-> Mobile browser set-up.
Any help people can offer is greatly appreciated as I'm stumped and I haven't seemed to find anything relevant in my searching because the server seems to communicate fine except for this issue.
Thanks!
~Camel
I am writing a multiplayer real time game for the browser with the server as a master instance and the clients as input devices and slaves to show the graphics.
I have to send out changes in the game world very often and very fast and it doesn't matter if some of the data sometimes gets lost on the way because a couple of milliseconds later there will be the next update anyway.
Right now I am using Socket.io to talk between the server and the clients but this uses TCP which makes the update come in unnecessary late sometimes.
I know that there is WebRTC with data channels where I would be able to send my updates through wit UDP which would be very awesome and exactly what I want. And it even seems to be implemented in Firefox and Chrome already https://stackoverflow.com/a/12864512/63779
What I now need is some Node library which would allow me to use data channels to send my data (for now just JSON strings) with help of UDP to the clients which are browsers. On the browser I would be able to use webkitRTCPeerConnection() but I have no idea how to start something like that on the Node server. Any suggestions? If there is no Node module for that, would it be possible to write something in some other language and just send the data via Unix domain sockets or something?