Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var init_ext = function() {
- Client.destroy_all();
- if (http_ext) {
- http_ext.close(function() {
- my.log('ext server closed');
- });
- }
- http_ext = net.createServer(function(c) { //'connection' listener
- var auth_buffer = new Buffer(0);
- var auth_obj = null;
- var client = null;
- my.log('server connected', auth_obj);
- c.on('data', function(d) {
- my.log("ctl", "conn", "read", d.length);
- if (!auth_obj) {
- auth_buffer = Buffer.concat([auth_buffer, d]);
- auth_obj = pir.unpack(auth_buffer).obj;
- if (auth_obj && auth_obj.type == "auth_obj") {
- client = Client.get_client(auth_obj);
- if (!client.int_conn) {
- client.set_int_conn(c);
- }
- my.log("client", "auth", client.auth_obj);
- }
- }
- if (auth_obj) {
- //other code here
- }
- });
- });
- http_ext.listen(config.ext_connectback_port, config.ext_connectback_host, function() { //'listening' listener
- my.log('ext server bound', config.ext_connectback_port, config.ext_connectback_host);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement