當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript socket.io.default類代碼示例

本文整理匯總了TypeScript中socket.io.default的典型用法代碼示例。如果您正苦於以下問題:TypeScript io.default類的具體用法?TypeScript io.default怎麽用?TypeScript io.default使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了io.default類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: express

			console.error("[FAIL]Module Name:" + modelFile);
			console.error('\x1b[36m', "err: "+err,'\x1b[0m');
		}
	});
}else{
	console.log("[ = disable modules = ]");
}
//
// ## SimpleServer `SimpleServer(obj)`
// Creates a new instance of SimpleServer with the following options:
//  * `port` - The HTTP port to listen on. If `process.env.PORT` is set, _it overrides this value_.
//
var router = express();
var server = _http.createServer(router);
engineio.attach(server);
var io = socketio.listen(server);

//router.use(function(req, res, next){
    //res.header("Content-Security-Policy", "default-src 'self';script-src 'self';object-src 'none';img-src 'self';media-src 'self';frame-src 'none';font-src 'self' data:;connect-src 'self';style-src 'self'");
    //next();
//});

//===============================================
// express config start
//===============================================
router.use(express.static(path.resolve(__dirname, 'public')));
router.set('view engine', 'ejs'); // set up ejs for templating
router.set('views',path.join(__dirname,'/app/views'));
router.use(compression());
//router.use(multer({ dest: './uploads/'}));
//router.use(busboy());
開發者ID:Lightnet,項目名稱:electron-threejs,代碼行數:31,代碼來源:server.ts

示例2: return

export const initializeServer = () => {
    const logger = new signale.Signale({ scope: 'Auto reloading' })
    logger.config({ displayTimestamp: true })

    // Since this port is hard-coded, it must match background.tsx
    const socketIOServer = io.listen(8890)
    logger.await('Ready for a browser extension to connect')
    socketIOServer.on('connect', () => {
        logger.info('Browser extension connected')
    })
    socketIOServer.on('disconnect', () => {
        logger.info('Browser extension disconnected')
    })

    return () => {
        if (Object.keys(socketIOServer.clients().connected).length === 0) {
            logger.warn('No browser extension has connected yet, so no reload was triggered')
            logger.warn("- Make sure it's enabled")
            logger.warn("- Make sure it's in developer mode (unpacked extension)")
            logger.warn('- Try manually reloading it 🔄')
        } else {
            logger.info('Triggering a reload of browser extensions')
            socketIOServer.emit('file.change', {})
        }
    }
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:26,代碼來源:auto-reloading.ts

示例3: init

function init () {

  socket = ioServer.listen(server)
  socket.sockets.on('connection', onSocketConnection)

  controlMaps = new cServerControlMaps(socket);

}
開發者ID:nalgorry,項目名稱:Multi,代碼行數:8,代碼來源:server.ts

示例4: constructor

    constructor(server){

        this.socketManager = io.listen(server);

        this.socketManager.set('log level', 1);

        this.socketManager.sockets.on('connection', socket => {
            console.log("received client".blue);

            socket.on("disconnect", () => console.log("disconnected".blue));
        });

    }
開發者ID:devshorts,項目名稱:htf-viewer,代碼行數:13,代碼來源:clientReloader.ts

示例5: sio

function sio(server) {

    var sio = socketio.listen(server);
    //sio.set('transports', ['websocket']);
    sio.sockets.on('connection', function (socket) {
        socket.on('server', function (data) {
            socket.broadcast.emit('client', {
                value: data.value
            });
        });

        socket.on("disconnect", function () {
        });
    });

}
開發者ID:7thCode,項目名稱:wmonsin,代碼行數:16,代碼來源:sio.ts

示例6: fn

function fn(server)
{
    var tid = 0
    
    sio.listen(server).sockets.on('connection', function(socket)
    {
        socket.on('createTerminal', function(term_id, func)
        {
            var name = term_id.split('§')[0]
            var host_ip = term_id.split('§')[1]
            var cmd:any

            if( !process.env.PRODUCTION ){
                //name = "hello-world2" //'-H', host_ip+':2375', 
                // cmd = ['exec', '-it', name, '/bin/bash']
            }
            cmd = ['-H', host_ip, 'exec', '-it', name, '/bin/bash'] 
            term_id = tid++

            console.log(cmd.join(' '))
            var term = pty.spawn('docker', cmd, {cwd: '/'})

            .on('data', function(data){
                socket.emit('data'+ term_id, data)
            })

            .on('exit', function(){
                socket.emit('exit', {})
            })
            
            socket.on('data'+ term_id, function(data){ 
                console.log(data)
                term.write(data)
            })
            .on('resize'+term_id, function(data){
                console.log(data)
                term.resize(data.cols, data.rows)
            })
            .on('disconnect', function(){
                term.destroy()
            })
            
            func(term_id) 
        })
        
    })
}
開發者ID:junjun16818,項目名稱:webos,代碼行數:47,代碼來源:terminal.ts

示例7: function

requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '../public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {

    var server = new DomoServer(new NoduinoObj({'debug': false}, NoduinoConnector, Logger), new static.Server('./domotique/public'));

    var app = http.createServer(server.handler);

    var io = socketio.listen(app);
    io.sockets.on('connection', function (socket) {
        server.noduino.connect(function(err, board) {
            var arduino = require('duino');
            if (err) { return console.log(err); }
            board.withAnalogInput({pin:  'A2'}, function(err, AnalogInput) {
                AnalogInput.on('change', function(a){
                    socket.emit('lightintensity', a.value);
                });
            });
        });
    });

    app.listen(8080);
    console.log('Server running at http://127.0.0.1:8080/');

});
開發者ID:geobarteam,項目名稱:NoduinoProjects,代碼行數:23,代碼來源:domoServerTyped.ts

示例8: start

    public start(){
        var controller = this;
        controller._io = socketio.listen(this._server);

        //Kill annoying debug output
        controller._io.set('log level', 1);

        //Force into xhr polling mode... AppFog has no WebSockets :(
        controller._io.configure(function () {
            controller._io.set("transports", ["xhr-polling"]);
            controller._io.set("polling duration", 10);
        });

        controller._io.sockets.on('connection', function (socket) {
            var id = socket.id;

            socket.on('getPublicStreams', function () {
                controller.getPublicStreams(function(items){
                    socket.emit('PublicStreams', items);
                });
            });

            socket.on('getVideoStream', function (id) {
                controller.getVideoStream(id,function(item){
                    socket.emit('VideoStream', item);
                });
            });

            socket.on('clientUpdate',function(data){
                controller.clientUpdate(data);
            });

            socket.on('disconnect', function(){
                controller.disconnect(id);
            });
        });
    }
開發者ID:JTLunsford,項目名稱:TwoCentSecurity,代碼行數:37,代碼來源:Socket.ts

示例9: require

/// <reference path="../../../typings/mocha/mocha.d.ts" />
/// <reference path="../../../typings/socket.io/socket.io.d.ts" />
import {expect} from 'chai';
import {
  DataFrame,
  FailureFrame,
  MutationFrame,
  RequestFrame,
  SocketIOClient,
  SocketIOServer
} from '../src/socket';

var Server = require('socket.io');
var Socket = require('socket.io-client');

var server: SocketIO.Server = new Server(8080);
var connHandler: Function = (socket: SocketIO.Socket): void => {};
server.on('connection', (socket: SocketIO.Socket) => connHandler(socket));

var options = {transports: ['websocket'], 'force new connection': true};

var key: Object = {key: true};
var cntxt: Object = {auth: true};

describe('SocketIOClient', () => {
  it("request should send a request frame to the server", (done) => {
    var ioSocket: SocketIO.Socket = Socket.connect('http://localhost:8080', options);
    var client: SocketIOClient = new SocketIOClient(ioSocket);

    connHandler = (socket: SocketIO.Socket) => {
      socket.on('request', (frame: RequestFrame) => {
開發者ID:alxhub,項目名稱:tactical,代碼行數:31,代碼來源:socket_spec.ts

示例10: function

app.use(function (req: express.Request, res: express.Response, next) {
    res.status(404);
    if (req.accepts('html')) {
        res.render('_shared/404');
        return;
    }
    if (req.accepts('json')) {
        res.send({ error: 'Not found' });
        return;
    }
    res.type('txt').send('Not found');
});
app.use(errorhandler({ dumpExceptions: true, showStack: true }));


// Start the server
var httpServer = http.createServer(app);

io = io.listen(httpServer);
io.set('log level', 1);

httpServer.listen(1337); // use 0 to assign random port
httpServer.on('listening', function () {
    console.log('listening on port: ', httpServer.address().port);
});

// var httpsServer = https.createServer(options, app);
// httpsServer.listen(443);

sockets.setupSockets(io);
開發者ID:irysius,項目名稱:NodeSiteTemplate,代碼行數:30,代碼來源:app.ts


注:本文中的socket.io.default類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。