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


TypeScript socket.io-client函數代碼示例

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


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

示例1: LoadEnvironment

$(() => {
  LoadEnvironment();
  RegisterBindingHandlers();
  RegisterComponents();
  InitializeSettings();
  if ($("#tracker").length) {
    let viewModel = new TrackerViewModel(io());
    ko.applyBindings(viewModel, document.body);
    viewModel.ImportEncounterIfAvailable();
    viewModel.GetWhatsNewIfAvailable();
  }
  if ($("#playerview").length) {
    let encounterId = env.EncounterId;
    const playerView = new ReactPlayerView(
      document.getElementById("playerview__container"),
      encounterId
    );
    playerView.LoadEncounterFromServer();
    playerView.ConnectToSocket(io());
  }
  if ($("#landing").length) {
    let launcherViewModel = new LauncherViewModel();
    ko.applyBindings(launcherViewModel, document.body);
  }
  $(".loading-splash").hide();
});
開發者ID:zipzav,項目名稱:improved-initiative,代碼行數:26,代碼來源:Index.ts

示例2: socketioClient

  mounted: () => {
    const liveButton = document.getElementById('live-button');
    const socket = socketioClient(
        SOCKET, {reconnectionDelay: 300, reconnectionDelayMax: 300});
    socket.connect();

    socket.on('connect', () => {
      liveButton.style.display = 'block';
      liveButton.textContent = 'Test Live';
    });

    socket.on('accuracyPerClass', (accPerClass: AccuracyPerClass) => {
      plotAccuracyPerClass(accPerClass);
    });

    socket.on('disconnect', () => {
      liveButton.style.display = 'block';
      document.getElementById('waiting-msg').style.display = 'block';
      document.getElementById('table').style.display = 'none';
    });

    liveButton.onclick = () => {
      liveButton.textContent = 'Loading...';
      socket.emit('live_data', '' + true);
    };
  },
開發者ID:AIED-ECNU,項目名稱:tfjs-examples,代碼行數:26,代碼來源:app.ts

示例3: _connectSocket

  private async _connectSocket(socketServerUrl: string) {
    // Connect to the server
    const socket = io(socketServerUrl);
    // Add the socket io listeners
    socket.on('list:changes', (data) => {
      console.log(JSON.stringify(data));
      this._getListChanges(data).then((changes: any) => {
        console.log(JSON.stringify(changes));
        if (changes != "") {
          let web = new Web(this.context.pageContext.web.absoluteUrl);
          // get a specific item by id
          web.lists.getById(changes[0].ListId).items.getById(changes[0].ItemId).get().then((item: any) => {
            console.log(item);
            this._lastQueryDate = moment();

            // Create the notification panel
            this._createNotification(item.Title, item.SPFxThumbnail.Url);

            // After x seconds the place holder is removed from the DOM
            let that = this;
            setTimeout(
              function () {
                // Delete the notification panel
                that._deleteNotification();
              }, 10000);
          });
        }
      });
    });
  }
開發者ID:AdrianDiaz81,項目名稱:sp-dev-fx-extensions,代碼行數:30,代碼來源:WebhooksToastNotificationsApplicationCustomizer.ts

示例4: apiSaga

export function* apiSaga() {
  const { apiHost }: ApplicationState = yield select();
  yield fork(getComponents);
  yield fork(syncWorkspaceState);
  yield fork(createSocketIOSaga(io(apiHost)));
  yield fork(handlePingPong);
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:7,代碼來源:api.ts

示例5: it

    it('Delete socket new Point', done => {
        var data = {
            firstName: 'Jose', lastName: LAST_NAME_TEST, email: 'jose@fito.gmail',
            contactNumber: '23234234234', address: 'jose fito address',
            latitude: 28.4666304, longitude: -16.3213076, ip: '19.16.2.3'
        };

        let socket = io('http://localhost:3000');

        socket.on(EMIT_REMOVED_POINT, (point: any) => {
            assert.equal(point.firstName, 'Jose');
            socket.disconnect();
            done();
        });

        request.post(
            'http://localhost:3000/api/points',
            { form: data },
            (error: any, response: any, body: any) => {
                if (!error && response.statusCode == 200) {
                    var newPoint = JSON.parse(body);

                    request.del(`http://localhost:3000/api/points/${newPoint._id}`,
                        (error: any, response: any, body: any) => {
                            if (!error && response.statusCode == 200) {
                            } else {
                                done(`${response.statusCode} - ${error}\n ${body}`);
                            }
                        });
                } else {
                    done(error);
                }
            }
        );
    });
開發者ID:najor,項目名稱:ng2-md-arcgis,代碼行數:35,代碼來源:serverSocketTest.ts

示例6: io

 this.store.select(state => state.data.authentication.jwtToken).take(1).subscribe((token: string) => {
     this.socket = io(BACKEND, {query: "jwttoken=" + token});
     this.socket.on("UPDATE_REDUX", action => {
         info("Realtime update coming in!");
         this.store.dispatch(action)
     });
 });
開發者ID:brechtbilliet,項目名稱:winecellar,代碼行數:7,代碼來源:realtime.ts

示例7: beforeEach

        beforeEach(done => {
            appConfig = {
                name         : 'Test API Server',
                version      : '0.0.1',
                database     : database,
                authenticator: authenticator
            };

            app = createApp(appConfig);
            listener = new SocketListener();
            listenerConfig = {
                action : sinon.stub().returns(Promise.resolve(actionResult)),
                adapter: sinon.stub().returns(Promise.resolve(adapterResult))
            };
            listener.on('test', listenerConfig);
            app.register('/', listener);
            app.on('error', () => undefined);

            (app.webServer as any).listen(testPort);

            socketClient = io(`http://localhost:${testPort}`, {
                query: { authorization: `token ${authToken}` }
            });

            socketClient.on('connect', done);
            socketClient.on('error', done);
        });
開發者ID:herculesinc,項目名稱:nova-server,代碼行數:27,代碼來源:SocketListener.spec.ts

示例8: done

            beforeEach(done => {
                app = createApp(appConfig);
                app.on('error', () => undefined);

                listener = new SocketListener();
                listenerConfig = {
                    action : sinon.stub().returns(Promise.resolve(actionResult)),
                    adapter: sinon.stub().returns(Promise.resolve(adapterResult))
                };
                listener.on('test', listenerConfig);
                app.register('/', listener);

                (app.webServer as any).listen(testPort);

                socketClient = io(`http://localhost:${testPort}`, {
                    query: { authorization: `token ${authToken}` }
                });

                socketClient.on('error', done);
                socketClient.on('connect', () => {
                    socketClient.emit('unknown', payload, err => {
                        if (!err) {
                            return done('Should return error');
                        }

                        socketError = err;
                        done();
                    });
                });
            });
開發者ID:herculesinc,項目名稱:nova-server,代碼行數:30,代碼來源:SocketListener.spec.ts


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