1.pomelo Basic introduction http://blog.gfdsa.net/2013/06/04/pomelo/pomelo_study_two/

2. How to configure a gate The server

(1) First   Need to be in gameserver Under the  app.js Add the following code

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

(2) stay gameserver Under the config Of server.json  and adminServer.json  The configuration is as follows :

server.json

adminServer.json

(3) stay gameserver Of app/servers newly build gate/handler/gateHandler.js  The code can be copied connector/handler/entryHandler.js

module.exports = function(app) {
return new Handler(app);
}; var Handler = function(app) {
this.app = app;
}; /**
* New client entry.
*
* @param {Object} msg request message
* @param {Object} session current session object
* @param {Function} next next step callback
* @return {Void}
*/
Handler.prototype.entry = function(msg, session, next) {
var res = this.app.getServersByType('connector'); // get connector Type server The return value is connector An array of type servers
console.log(res[0].clientPort)
next(null, {code: 200,host: res[0].host,port: res[0].clientPort});// Take the first one connector Type of server ip And port
}; /**
* Publish route for mqtt connector.
*
* @param {Object} msg request message
* @param {Object} session current session object
* @param {Function} next next step callback
* @return {Void}
*/
Handler.prototype.publish = function(msg, session, next) {
var result = {
topic: 'publish',
payload: JSON.stringify({code: 200, msg: 'publish message is ok.'})
};
next(null, result);
}; /**
* Subscribe route for mqtt connector.
*
* @param {Object} msg request message
* @param {Object} session current session object
* @param {Function} next next step callback
* @return {Void}
*/
Handler.prototype.subscribe = function(msg, session, next) {
var result = {
topic: 'subscribe',
payload: JSON.stringify({code: 200, msg: 'subscribe message is ok.'})
};
next(null, result);
};

(4) Client request :( I use quick Realized , According to your own needs   As long as the route sends “gate.gateHandler.entry” Just go )

local route = "gate.gateHandler.entry"
 local msg = { uid = "luaClientWindows" }
 client:pomeloRequest(route,tostring(json.encode(msg)))

experimental result :

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAp0AAAAsCAIAAACovpSQAAAKiElEQVR4nO2dy9WsuA6FyadSIYMO4ZII446B4c2hUuhM7uhOTw94SbYky4Cxofa3zjrrL8r4IVvefkF1//nv/+N/f/39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ej6M6M+pdr0fdzqr9L9L1cRylskp2Mzf4y/oLbVlp+1jtULcnJuzgF2npfXPgTaA/PcZJu11+EO/hoKMBP0jF331ZB9nwuhdS7tz5uzltN+j6Al29qZ0XAO4Fv+cGwIuArgPw80DXAQAAgPcAXQcAAADeA3QdAAAAeA/QdQAAAOA9QNcBAACA9wBdBwAAAN4DdB0AAAB4D9B1AAAA4D1A1wEAAID3AF0HAAAA3kMpXY9/e2mmdnkBAACAN3NS1/8FvccNvN+WA0oAAAAASUVORK5CYII=" alt="" />

[ primary ]pomelo Basic knowledge of ( One ) More articles about

  1. Java Basic knowledge of 【 Next 】( Reprint )

    http://blog.csdn.net/silentbalanceyh/article/details/4608360 ( Finally decided to write a new one Java Basic content , Because I didn't write this chapter ...

  2. Oracle Database Basics

    oracle database plsql developer   Catalog (?)[-] One      SQL Basic knowledge of Create delete database Create delete modify table Add, modify, delete columns oracle cascade usage Add delete constraint primary key ...

  3. The illustration TCP/IP→ The first 2 Chapter two basic knowledge

    ####TCP.IP background ** key word :ARPANET,UNIX, Packet switching technology ,*ARPANET( ARPANET ), And the originator of the global Internet . The success of ARPANET also fully proves the feasibility of the communication method based on packet switching technology .*20 century 70 ...

  4. C++ Summary of the basic knowledge of sequential containers

    0. Preface This paper simply summarizes STL The knowledge points of the order container of . This paper does not involve specific implementation techniques , I didn't mention the details . First, different standard libraries have different implementations , Second, about the concrete realization <STL Source analysis > It has been shown in detail ...

  5. Spring Basic knowledge of

    Spring Basic knowledge of utilize spring Complete the loose coupling Interface public interface IOutputGenerator { public void generateOutput(); } Implementation class ...

  6. Oracl Basic knowledge of ( One )

    summary Oracle It has many functions , Contact Oracle It's not deep , Sort out the basic knowledge you come into contact with , In order to meet the needs of the time . The main contents are Expdp Instructions to achieve database backup ,Impdp Command to restore the database , And users . Definition of table space . The number of collations ...

  7. Java Basic knowledge series ——String

    Nothing's happened recently ( It's mainly about not working overtime and being single ), I just reviewed it Java Basic knowledge of . I review Java Basic knowledge is mainly based on Java API and The Java Tutorials. Today is the first article , Reviewed Strin ...

  8. ReactiveCocoa Basic knowledge content

    This article records something about learning ReactiveCocoa Basic knowledge content , about ReactiveCocoa If you don't know the related concepts, you can search online :RACSignal There are many ways to subscribe to different event types ,ReactiveCoc ...

  9. SQL server Basic knowledge of ( Table operations 、 Data constraints 、 Multi table link query )

    SQL server Basic knowledge of One . Basic knowledge of (1). Storage structure : database -> surface -> data (2). Management database increase :create database Database name Delete :drop database ...

Random recommendation

  1. Only by understanding these can we start to play jQuery The power of

    Due to the current jQuery So thunderous , I don't think it's necessary to introduce jQuery 了 , It's widely used in company code jQuery, But I found a problem when I looked at some children's code , What children use is just jQuery The fur of , Just use id choice ...

  2. Use PSD Validator Online verification PSD Quality of documents

     PSD Validator Can help you check online PSD Quality of documents , The rules used come from  Photoshop Etiquette.Photoshop Etiquette Tidy up PSD Specification of documents , For example, delete ...

  3. Spring Get... In the code bean In several ways

    Method 1 : Save on initialization ApplicationContext object Method 2 : adopt Spring Provided utils Class gets ApplicationContext object Method 3 : Inherited from abstract classes ApplicationObj ...

  4. jQuery Magnifier plug-in jqzoom Use

    Source download , Use the guidance address :http://www.mind-projects.it/projects/jqzoom/ Use the tutorial : 1. Import library file <script src="../js/jq ...

  5. Android Back Home Key monitoring

    Android Back Home Key monitoring Back Key monitoring about Back Key monitoring is easier , It can be intercepted at multiple system callbacks , For example activity Can be received in any of the following ways Back Key press event : @Overrid ...

  6. JAVA HashMap And HashTable difference

    HashTable and HashMap difference First of all , Different inheritance . public class Hashtable extends Dictionary implements Mappublic class Ha ...

  7. Python Common problems in getting started

    1. Run at terminal python, appear >>> Enter the code to execute , If you want to quit , Just execute exit() that will do . --> stay Python Interactive command line , You can enter code directly , And then execute , And immediately ...

  8. mysql New characteristics

    5.7 New characteristics sys library document store X protocol json Support Spatial data Virtual column query rewrite plugin Table space transfer innodb undo Table space Table space tube ...

  9. Vue The computational properties in are related to $watch

    Compute properties : It's very convenient to bind expressions in templates , But they're actually only for simple operations . Templates are designed to describe the structure of the view . Putting too much logic in a template makes it too heavy and difficult to maintain . That's why vue.js Limit the binding expression to one expression . ...

  10. JAVA Review the basic part ( 5、 ... and 、JAVA Reflection )

    About reflection : 1. Need to know jvm Class loading mechanism (java The high-level section will elaborate on ) 2. The reflection of the API In fact, just take a look API And the source code , It's easy to understand . Here is the code , Briefly explain the use of reflection : import java.lang ...