• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript socket.io.default类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript sockets.comm_socket类代码示例发布时间:2022-05-25
下一篇:
TypeScript socket.io.Socket类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap