I am working on a mutliplayer game and decided to use NodeJS aspart of the system. The nodeJS is linked to mc# game emulator via TCP.
However how would I send messages to certain user ID? Each individual user in the database is sided by a unique user ID (EG 1)
How can I do this so if a user in game does a certain thing and that sends a message from Node ONLY TO THEM.
Since I can't run node on the same port as my cms (Port 80). I need a method in which I can use PHP to pull the ID or something.
Use as Jquery and 'GET'? I'm suck.
By message I mean data such as sending a javascript window.
Options available: JQuery Javascript PHP Node
I thought of a method were the user id is presented within a div through a parameter in PHP (EG $ID) and then javascript checked against the div and the message to see if the ids matched. Then within the message the users ID would be included, then somehow I could split the message? so its "","" (ID,MESSAGE)
Code:
var socket = io.connect(' http://dev.com '); socket.on('field', function (data) {
if ($("#userid").text().indexOf(data) > -1)
{
window.alert('lol');
console.log(data);
$("#field").html(data);
}
else
{
window.alert("Something has gone wrong with the node server...");
}
});
It didn't work.
THE PAGE: THE C#: THE NODE:
Based on your response in the comments:
Inside the messages are just html that node sends to the page via a Node HTTP server. The messages aren't big just little things like "window.open("google.com");. Messages are only triggered if a user clicks a certain thing within game and no.
It sounds to me like what you really want is some sort of RPC. There's a solid NPM module called Socket.IO which wraps all this up nicely for you. Fire an event, it can be handled server-side, and any callback data gets sent back to the client.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.