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

TypeScript socket.io-client类代码示例

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

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



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

示例1: constructor

 constructor() {
     super();
     this.socket = io(HOST);
     this._app = feathers()
         .configure(socketio(this.socket))
         .configure(hooks())
 }
开发者ID:yberstad,项目名称:angular2-quickstart,代码行数:7,代码来源:feathers.service.ts


示例2: constructor

 constructor() {
   this.socket = io(HOST);
   this._app = feathers()
     .configure(socketio(this.socket))
     .configure(hooks())
     .configure(authentication({ storage: localstorage }));
 }
开发者ID:s-robertson,项目名称:things-front,代码行数:7,代码来源:feathers.service.ts


示例3: chimes

 chimes() {
   const socket = io.connect('http://chimes-us.teropa.info/chimes');
   return Observable.create((observer) => {
     socket.on('chime', (chime) => observer.next(chime));
     return () => socket.close();
   });
 }
开发者ID:TheLarkInn,项目名称:windchimes,代码行数:7,代码来源:remote.service.ts


示例4: return

    return (dispatch, getState) => {
        dispatch({ type: 'CONNECTING' });
        // const socket = io({
        //     path: '/api/socket.io'
        // });
        const socket = io();

        socket.on('connect', () => {
            let username = getState().user.username;
            if (username) {
                socket.emit('login', { username }, (resp: Protocol.Response) => {
                    if (!resp.success) {
                        dispatch({ type: 'LOGOUT' });
                    } else {
                        dispatch({
                            type: 'CONNECTED',
                            payload: socket
                        });
                    }
                });
            } else {
                dispatch({
                    type: 'CONNECTED',
                    payload: socket
                });
            }
        });

        socket.on('disconnect', () => {
            dispatch({ type: 'DISCONNECTED' });
        });

        socket.on('canvas:history:new', (event: Protocol.NewHistoryEvent) => {
            dispatch({
                type: 'CANVAS_HISTORY_NEW',
                payload: event.entry
            });
        });

        socket.on('canvas:user:join', (event: Protocol.UserEvent) => {
            dispatch({
                type: 'CANVAS_USER_JOIN',
                payload: event.user
            });
        });

        socket.on('canvas:user:leave', (event: Protocol.UserEvent) => {
            dispatch({
                type: 'CANVAS_USER_LEAVE',
                payload: event.user
            });
        });

        socket.on('canvas:user:update', (event: Protocol.UserEvent) => {
            dispatch({
                type: 'CANVAS_USER_UPDATE',
                payload: event.user
            });
        });
    }
开发者ID:cschram,项目名称:drawgaiden,代码行数:60,代码来源:connection.ts


示例5: initSocket

export function initSocket(context: Context) {
  const core = context.getMethodsOf<CoreSpec>('core');
  if (!core.isDevServerOn()) {
    return;
  }

  socket = io();
  socket.on(SERVER_MESSAGE_EVENT_NAME, handleServerMessage);
  socket.on(RENDERER_MESSAGE_EVENT_NAME, handleRendererMessage);

  return () => {
    if (socket) {
      socket.off(SERVER_MESSAGE_EVENT_NAME, handleServerMessage);
      socket.off(RENDERER_MESSAGE_EVENT_NAME, handleRendererMessage);
      socket = undefined;
    }
  };

  function handleServerMessage(msg: Message) {
    context.emit('serverMessage', msg);
  }

  function handleRendererMessage(msg: Message) {
    context.emit('rendererResponse', msg);
  }
}
开发者ID:skidding,项目名称:cosmos,代码行数:26,代码来源:socket.ts


示例6: tweets

 tweets() {
   const socket = io.connect('http://tweets-us.teropa.info/tweets');
   return Observable.create((observer) => {
     socket.on('tweet', (tweet) => observer.next(tweet));
     return () => socket.close();
   });
 }
开发者ID:1337programming,项目名称:twitter-sentiment-analysis,代码行数:7,代码来源:remote.service.ts


示例7: constructor

  constructor(opts: { port?: number; namespace?: string } = {}) {
    this.port = opts.port;
    this.namespace = opts.namespace || 'admin';

    if (!AppContext.isServer && !WsAdapter.io) {
      WsAdapter.io = connect(
        '/admin',
        { secure: true, reconnectionDelay: 10e3, reconnectionDelayMax: 60e3 },
      );

      WsAdapter.io.on('connect', () => {
        logger.log('[connect]', { id: WsAdapter.io.id, AppContext });
        AppContext.dispatch(appActions.heartbeat());
      });
      WsAdapter.io.on('reconnect', () => {
        logger.log('[reconnect]', { id: WsAdapter.io.id, AppContext });
        AppContext.dispatch(appActions.heartbeat());
      });
      WsAdapter.io.on('disconnect', () => {
        const { heartbeat } = AppContext.store.select(state => state.app);
        logger.error('[disconnect]', { id: WsAdapter.io.id, heartbeat });
        if (heartbeat) {
          AppContext.dispatch(appActions.heartbeatStop());
        }
      });
      WsAdapter.io.on('error', error => {
        const { heartbeat } = AppContext.store.select(state => state.app);
        logger.error('[error]', { id: WsAdapter.io.id, heartbeat, error });
        if (heartbeat) {
          AppContext.dispatch(appActions.heartbeatStop());
        }
      });
    }
  }
开发者ID:danielwii,项目名称:asuna-admin,代码行数:34,代码来源:ws.ts


示例8: Promise

  it(`should handle message (2 gateways)`, async () => {
    app = await createNestApp(ApplicationGateway, NamespaceGateway);
    await app.listenAsync(3000);

    ws = io.connect('http://localhost:8080');
    io.connect('http://localhost:8080/test').emit('push', {})
    ws.emit('push', {
      test: 'test',
    });
    await new Promise(resolve =>
      ws.on('pop', data => {
        expect(data.test).to.be.eql('test');
        resolve();
      }),
    );
  });
开发者ID:a1r0,项目名称:nest,代码行数:16,代码来源:gateway.spec.ts


示例9: constructor

 constructor(http: Http, threadService: ThreadService) {
   this._io = io.connect();
   this._http = http;
   this._threadService = threadService;
   this.messages = new Observable(observer => this._messagesObservers = observer).share();
   this._dataStore = { messages: [] };
   this._socketOn();
 }
开发者ID:Crazy-Ace,项目名称:MEAN-Blueprints,代码行数:8,代码来源:message.service.ts


示例10:

 }).then((t: PushToken) => {
   this.socket = io.connect('http://'+SOCKET_LINK);
   this._storage.setToStorage('@device:token' , {token: t.token})
   // alert('token:' + t.token)
   this.socket.emit('save-device' , {affiliate: resJson.result.affiliate , token: t.token , server:'AU'})
   this._store.dispatch(this._userAction.addUserToStorage({key:resJson.result.key , user:resJson.result.user}))
   this._loader.loaded()
   this.navCtrl.setRoot(ShowMoreJobPage)
 });
开发者ID:hivoova,项目名称:travelsafe-operator,代码行数:9,代码来源:register.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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