EzDevInfo.com

pomelo

A fast,scalable,distributed game server framework for Node.js. Pomelo home pomelo is a fast, scalable, distributed game server framework for node.js. it provides the basic development framework and a lot of related components, including libraries and tools. pomelo is also suitable for realtime web application, its distributed architecture makes pomelo scale better than other realtime web frameworks.

Does NetEase's Pomelo use Udp or Tcp?

I recently decided to make a multiplayer FPS game using Nodejs (server) and Unity3D (client). I already did a POC with socket.io and deployed it on heroku for testing which failed miserably ( the packet delivery was too slow which created lag). After digging around I found out that socket.io uses TCP which is not ideal for a face paced FPS game. Then I came across Pomelo and it seemed interesting.

But before I spend time on its POC, I need to know. Does Pomelo only use TCP or does it also support UDP?

Thanks :)


Source: (StackOverflow)

My Socket.io on IOS fails to handshake with the websocket server

I have a Node.js server running Websocket. (using Pomelo). I am able to run a web application and connect to it (localhost @port 3104).

however, when I try to use socket.io (SocketRocket) for IOS and connect to the same localhost and port, I get this error:

> http://127.0.0.1:3014/socket.io/1/?t=16807 
> "ERROR: handshake failed ... The request timed out"

detail of the error:

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x6c723c0 
{NSErrorFailingURLStringKey=http://127.0.0.1:3014/socket.io/1/?t=16807, NSErrorFailingURLKey=http://127.0.0.1:3014/socket.io/1/?t=16807, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x6c72400 "The request timed out."}

i tried. 127.0.01, localhost... even explicit IP address.. all fail

any idea what I should check? and should it be "http" protocol ? or wss?


Source: (StackOverflow)

Advertisements

Unity Pomelo Client not working in android and window when using domain name

When I use IP address of the server then I can connect to it and get a valid response. But if I use domain name instead of IP address then I dont receive any response. (For Windows and Android)

Here is the code snippet :

private string gateServerUrl = "http://mydomaincom:3014";

//private string gateServerUrl = "00.00.000.00:3014";

pclient = new PomeloClient (gateServerUrl);
pclient.request ("gate.gateHandler.getConnector", user, new System.Action (OnResponse));

And the same code for the MAC and iOS works just fine.

Please let me know why i am getting this issue and how i can solve it.


Source: (StackOverflow)

Unity Pomelo broadcast message is not received sometimes

We are using Pomelo for networking in our game. Unity Client is registered for some broadcast events, in very rare cases broadcast messages are not received by the unity client. But the messages are broadcasted from the server.

I have tried putting logs in SocketMessage method of PomeloClient but no logs were printed. If anyone has any clue or suggestions about the problem, then please reply.

/// <summary>
    /// When message from server comes, it invoke.
    /// </summary>
    /// <param name='sender'>
    /// Sender.
    /// </param>
    /// <param name='e'>
    /// E.
    /// </param>
    private void SocketMessage (object sender, MessageEventArgs e) {
        UnityEngine.Debug.Log("Unfiltered Message from  server :" + e.Message);

        if ( e!= null && e.Message.Event == "message") {
            string msg = e.Message.MessageText;
            if (msg.IndexOf(ARRAY_FLAG) == 0) {
                this.processMessageBatch(msg);
            } else {
                this.processMessage(msg);
            }
        }
    }

Source: (StackOverflow)

pomelo can't pushMessage to unity3d when the number of requests are high

I made a multiplayer game using pomelo and unity3d. When I tried to test pomelo server with less requests i got this error in pomelo :

http://www.imageupload.co.uk/56hz

Server info :

CPU - Dual Code
RAM - 1 GB

I wonder how lord of pomelo demo support 486 online player in MMORpg whereas my game can't . I used flowing conditions for testing server : In my game each player send 300 request per second and when I connected two player to server it gave me that error (as shown in image) whereas I have just two player connected to server-it mean's 600 req/s - communicating with each other and not a mmorpg game like lord of pomelo that has 486 player in just one scene.

I am confused, I am using socket.io in pomelo because websocket worked more bad. Hear are my main codes for pomelo game server:

app.js :

var pomelo = require('pomelo');
var dispatcher = require('./app/util/dispatcher');

// route definition for field server
var fieldRoute = function(session, msg, app, cb) {
    var fieldServers = app.getServersByType('field');
    if(!fieldServers || fieldServers.length === 0) {
        cb(new Error('can not find field servers.'));
        return;
    }
    var res = dispatcher.dispatch(session.get('rid'), fieldServers);
    cb(null, res.id);
};
/**
 * Init app for client.
 */
var app = pomelo.createApp();
app.set('name', 'f_s_socketIO');

// app configuration
app.configure('production|development', 'connector', function(){
  app.set('connectorConfig',
    {
      connector : pomelo.connectors.sioconnector,
      //websocket, htmlfile, xhr-polling, jsonp-polling, flashsocket
      transports : ['websocket'],
      heartbeats : true,
      closeTimeout : 60,
      heartbeatTimeout : 60,
      heartbeatInterval : 25
    });
});

app.configure('production|development', 'gate', function(){
    app.set('connectorConfig',
        {
            connector : pomelo.connectors.sioconnector,
        });
});

app.configure('production|development', function() {
    // route configures
    app.route('field', fieldRoute);
});
// start app
app.start();

process.on('uncaughtException', function (err) {
  console.error(' Caught exception: ' + err.stack);
});

connector.js :

module.exports = function(app) {
  return new Handler(app);
};

var Handler = function(app) {
  this.app = app;
};

var handler = Handler.prototype;

var oppnent_user="";
var opponent_guns;
var opponent_fxs;

handler.entry = function(msg, session, next) 
{
    var self = this;
    var rid = msg.rid;
    var uid = msg.uid;
    var guns = msg.guns;
    var fxs = msg.fxs;
    var sessionService = this.app.get('sessionService');

    //duplicate log in  
    if( !! sessionService.getByUid(uid) ) 
    {
        next(null, {
            code: 500,
            error: true
        });
        return;
    }

    session.bind(uid);
    session.set('rid', rid);
    session.pushAll();


    session.on('closed', onUserLeave.bind(null, self.app));

    //put user into channel
    // befor we can push message to client first we must creat jchanels
    self.app.rpc.field.userRemote.add(session, uid, self.app.get('serverId'), rid, true, function(){
       console.log('callback from rpc add to chanel');
        next(null, {
            code: 200,
            error: 'false'
        });
    });

};


var onUserLeave = function(app, session) {
    if(!session || !session.uid) {
        return;
    }
    //app.rpc.chat.chatRemote.kick(session, session.uid, app.get('serverId'), session.get('rid'), null);
};

fieldHandler.js : for pushMessage :

module.exports = function(app) {
    return new Handler(app);
};

var Handler = function(app) {
    this.app = app;
};

var handler = Handler.prototype;

/**
 * Send messages to users
 *
 * @param {Object} msg message from client
 * @param {Object} session
 * @param  {Function} next next stemp callback
 *
 */


handler.rot = function(msg, session,next) {
    //console.log(session.get('frontendId'));
    //var backEndSession = this.app.get('backendSessionService');

    var opponent_uid = msg.oppo_id;
    var x_rot = msg.x;
    var y_rot = msg.y;
    var z_rot = msg.z;
    var w_rot = msg.w;
    var gun_number = msg.gun_no;

    var rid = session.get('rid');
    var channelService = this.app.get('channelService');
    channel = channelService.getChannel(rid, false);

    var param_defender = {
        x: x_rot,
        y: y_rot,
        z: z_rot,
        w: w_rot,
        gun_no: gun_number
    };


    var tsid = channel.getMember(opponent_uid)['sid'];
    channelService.pushMessageByUids('OnRotate', param_defender, [{
        uid: opponent_uid,
        sid: tsid
    }]);

    next();
   /* next(null, {
        ttt:'game started'
       });
    */  


       /* var asd = backEndSession.getByUid(session.frontendId,msg.uid,function(data){
        console.log('callback of backendSessionService');
        console.log(data);
    });
    */

    /*var rid = session.get('rid');
    var uid = session.uid;
    var guns = session.get('guns');
    //var username = session.uid.split('*')[0];
    var channelService = this.app.get('channelService');
    var param = {
        opponent_id: uid,
        oppenent_guns: guns,
        opponent_fxs: msg.fxs
    };
    channel = channelService.getChannel(rid, false);


   // channel.pushMessage('onChat', param);

    //the target is specific user

    var tuid = msg.uid;
   // var tsid = channel.getMember(tuid)['sid'];
    channelService.pushMessageByUids('OnMessage', param, [{
        uid: tuid,
       // sid: tsid
    }]);

    next(null, {
        route: msg.route
    });*/
};

and fieldRemote.j for making channels :

module.exports = function(app) {
    return new userRemote(app);
};

var userRemote = function(app) {
    this.app = app;
    this.channelService = app.get('channelService');
};

/**
 * Add user into chat channel.
 *
 * @param {String} uid unique id for user
 * @param {String} sid server id
 * @param {String} name channel name
 * @param {boolean} flag channel parameter
 *
 */
userRemote.prototype.add = function(uid, sid, name, flag, cb) {
    var channel = this.channelService.getChannel(name, flag);
    var username = uid;
    /*var param = {
        route: 'OnStart',
        user: username
    };
    channel.pushMessage(param);
    */
    if( !! channel) {
        channel.add(uid, sid);
    }
    cb();
};

Source: (StackOverflow)

node.js light call-response framework

I am interested in a node.js framework that offers a request-response type of data transmission. With pure node.js, you can't have a linked request-response type of action. Basically, when i make a call from the client, a would like to wait for a response until a proceed.

I know for a fact that there is such a framework, pomelo. The thing is that it is a gaming framework and i would prefer if i could keep everything lite.


Source: (StackOverflow)

how to use rpc to get i need area when architect multiple connector, area?

This is link picture architect of lordofpomelo: enter image description here

I don't know call from area to another area.

Can you explain help me?

I only see use line command at process connector:

var onUserLeave = function (app, session, reason) {
if(!session || !session.uid) {
return;
}
app.rpc.area.playerRemote.playerLeave(session, {playerId: session.get('playerId'), instanceId: session.get('instanceId')}, function(err){
if(!!err){
logger.error('user leave error! %j', err);
}
});
};

and function handler at process area:

exp.playerLeave = function(args, cb){
var playerId = args.playerId;
var area = pomelo.app.areaManager.getArea(args.instanceId);
var player = area.getPlayer(playerId);
....
....
};

Source: (StackOverflow)

nodeJS Gameserver and Android Clients

I googled yet a lot. Nothing matched my issues.

We want to have a NodeJS Gameserver.

You should be able to connect with Android as client. There should be "rooms" to go into, like tables.

We want to join 4 android clients in one room. They shall play a game and send some timestamps and urls to each other.

At the end of a round, we want them to leave that specific room they are in.

Do you have some suggestions for us, what would the best framework look like? Is there a framework to achieve that? Would Pomelo.js meet our customs?

We are all new to android-programming and server-side JS.

Best regards,

Michael


Source: (StackOverflow)

How to get user count from several node.js servers?

I use POMELO framework. I have one gate server and three game logic servers. How to get active user count on each game logic servers from gate server to decide on which of three logic servers new user should be redirected?

I am try use RPC getUsersInArea but it execute on one of tree logic servers(but i need to execute this procedure on all logic servers) and i don't know exactly on which of them:

var Code = require('../../../../../shared/code');
var dispatcher = require('../../../util/dispatcher');

/**
 * Gate handler that dispatch user to connectors.
 */
module.exports = function(app) {
return new HandlerGate(app);
};

var HandlerGate = function(app) {
this.app = app;
};

var proGate = HandlerGate.prototype; // need for local debugging at WebStorm

proGate.queryEntry = function(msg, session, next) {
var uid = msg.uid;
if (!uid) {
    next(null, {code: Code.FAIL});
    return;
}

var arg1, arg2;
this.app.rpc.area.playerRemote.getUsersInArea(
    session,
    function(usersAmount) {
        //  ...
        console.log("usersAmount="+usersAmount);
    });

var connectors = this.app.getServersByType('connector');
if (!connectors || connectors.length === 0) {
    next(null, {code: Code.GATE.NO_SERVER_AVAILABLE});
    return;
}

var res = dispatcher.dispatch(uid, connectors);
next(null, {code: Code.OK, host: res.host, port: res.clientPort});
};

Source: (StackOverflow)

Can't connect to a Pomelo based server using Cocos2d-x

I'm trying to run a demo provided by the Pomelo creators but unfortunately I get the "Failed to connect to server" error.

// try to connect to server.
    if(pc_client_connect(client, &address)) {
        CCLOG("fail to connect server.\n");
        pc_client_destroy(client);
        return ;
    }

This is the demo I'm trying to launch: https://github.com/NetEase/pomelo-cocos2dchat

This is server: https://github.com/NetEase/chatofpomelo


Source: (StackOverflow)

pomelo framework chat demo issues on Azure

Hello I have installed Pomelo server chat demo on Azure VM and opened opened ports ( 3001, 3050, 3051,3052, 3500, 3150,3005 ) in the End points section.

But If I open the server url, I'm getting some error with socket connection.

Here is the URL. http://multiplayerdemo.cloudapp.net:3001/

I have tried the same setup on local VM and I didn't face any issue.

Can any one help me out.


Source: (StackOverflow)