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

TypeScript socket.io-client.default类代码示例

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

本文整理汇总了TypeScript中socket.io-client.default的典型用法代码示例。如果您正苦于以下问题:TypeScript io-client.default类的具体用法?TypeScript io-client.default怎么用?TypeScript io-client.default使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了io-client.default类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

  it("broadcast should send a data frame to all connected clients", (done) => {
    var clientA: SocketIO.Socket = Socket.connect('http://localhost:8080', options);
    var clientB: SocketIO.Socket = Socket.connect('http://localhost:8080', options);
    var socketServer: SocketIOServer = new SocketIOServer(null, server);
    var clients: number = 0;

    var version: string = 'foobase';
    var data: Object = {foo: 'foo'};
    var mutationId: Object = {id: -1};

    var dataHandler: Function = (frame: DataFrame) => {
      expect(frame.version).to.equal(version);
      expect(frame.key).to.deep.equal(key);
      expect(frame.data).to.deep.equal(data);
      expect(frame.mutationId).to.deep.equal(mutationId);
      if (--clients == 0) {
        clientA.disconnect(true);
        clientB.disconnect(true);
        done();
      }
    };

    clientA.on('data', dataHandler);
    clientB.on('data', dataHandler);

    connHandler = (socket: SocketIO.Socket) => {
      if (++clients == 2) {
        socketServer.broadcastData(key, version, data);
      }
    };
  });
开发者ID:alxhub,项目名称:tactical,代码行数:31,代码来源:socket_spec.ts


示例2: enableCache

 /**
  * @param communibaseAdministrationId
  * @param socketServiceUrl
  */
 public enableCache(communibaseAdministrationId: string, socketServiceUrl: string):void {
   this.cache = {
     getIdsCaches: {},
     aggregateCaches: {},
     dirtySock: socketIoClient.connect(socketServiceUrl, { port: '443' }),
     objectCache: {},
     isAvailable(objectType, objectId) {
       return this.cache.objectCache[objectType] && this.cache.objectCache[objectType][objectId];
     },
   };
   this.cache.dirtySock.on('connect', () => {
     this.cache.dirtySock.emit('join', `${communibaseAdministrationId}_dirty`);
   });
   this.cache.dirtySock.on('message', (dirtyness:string) => {
     const dirtyInfo = dirtyness.split('|');
     if (dirtyInfo.length !== 2) {
       winston.warn(`${new Date()}: Got weird dirty sock data? ${dirtyness}`);
       return;
     }
     this.cache.getIdsCaches[dirtyInfo[0]] = null;
     this.cache.aggregateCaches[dirtyInfo[0]] = null;
     if ((dirtyInfo.length === 2) && this.cache.objectCache[dirtyInfo[0]]) {
       this.cache.objectCache[dirtyInfo[0]][dirtyInfo[1]] = null;
     }
   });
 }
开发者ID:kingsquare,项目名称:communibase-connector-js,代码行数:30,代码来源:index.ts


示例3: connected

function connected(dbConnection) {
  console.log("Connected with mongo: ", dbHost);
  db = dbConnection;

  console.log("Connecting with socket.io:  ", host);
  socket = client.connect(host);
  socket.on('connect', function () {
    console.log("Connected with socket.io: ", host);
  });

  socket.on('*', reportSignal);
}
开发者ID:filipstachura,项目名称:sensas-platform,代码行数:12,代码来源:index.ts


示例4: it

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

    var mutationFrame:
        MutationFrame = {key: key, base: 'foobase', data: {foo: 'baz'}, context: context};

    connHandler = (socket: SocketIO.Socket) => {
      socket.on('mutation', (frame: MutationFrame) => {
        expect(frame).to.deep.equal(mutationFrame);
        socket.disconnect(true);
        done();
      });
    };

    client.mutate(key, mutationFrame.data, mutationFrame.base, context);
  });
开发者ID:angular,项目名称:tactical,代码行数:17,代码来源:socket_spec.ts


示例5: require

const register = (name, bussUrl) => {
  console.log('Registering client ', name, ' to ', bussUrl);
  var io = require('socket.io-client');
  // var middleware = require('socketio-wildcard')();
  // io().use(middleware);
  var socket = io.connect(bussUrl, {reconnect: true});
  console.log('Connected client ', name, ' to ', bussUrl);
  socket.on('connect', function () { // TIP: you can avoid listening on `connect` and listen on events directly too!
    console.log('Connected'); // data will be 'woot'
    socket.emit('REGISTER_CLIENT', name);
    console.log('Sent REGISTER_CLIENT client ', name, ' to ', bussUrl);
  });

  var patch = require('socketio-wildcard')(io.Manager);
  patch(socket);

  //socket.on('*', function(){ /* … */ })

  return socket;
};
开发者ID:knsv,项目名称:crib-ui,代码行数:20,代码来源:mq.service.ts



注:本文中的socket.io-client.default类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript socket.io-parser.Decoder类代码示例发布时间:2022-05-25
下一篇:
TypeScript socket.io-client类代码示例发布时间: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