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


TypeScript net.Server類代碼示例

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


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

示例1: bind

  /**
   * Binds Http/Https server to the LegacyPlatformProxifier.
   * @param server Server to bind to.
   */
  public bind(server: Server) {
    const oldServer = this.server;
    this.server = server;

    for (const [eventName, eventHandler] of this.eventHandlers) {
      if (oldServer !== undefined) {
        oldServer.removeListener(eventName, eventHandler);
      }

      this.server.addListener(eventName, eventHandler);
    }
  }
開發者ID:Jaaess,項目名稱:kibana,代碼行數:16,代碼來源:legacy_platform_proxifier.ts

示例2: Promise

    return new Promise((resolve) => {
      this.server = createServer((socket:Socket) => {

        socket.on("data", (data) => {
          console.log(data);
        });

        socket.on("close", () => {
          console.log("disconnected");
        });
      });

      this.server.on("error", (error: Error) => {
        console.log(error);
      });

      this.server.listen(
        this.port,
        this.address,
        () => {
          resolve();
        }
      );
    });
開發者ID:no0dles,項目名稱:janner,代碼行數:24,代碼來源:server.ts

示例3: it

        it("Does not get enough keep alive", function(done) {
            let serverSocket: SocketHandler = null;
            let count = 0;

            let server: Server = net.createServer(function(socket: Socket) {
                serverSocket = new SocketHandler(socket, function () {
                    count++;
                    console.log("Count: " + count);

                    if (count < 10) {
                        serverSocket.send(new SocketMessage(Global.KeepAliveMessage));
                    } else {
                        // serverSocket.disconnect();
                    }
                });
            }).listen(9000);

            let socket = net.connect(9000, "localhost", function () {
                let handler = new SocketHandler(socket, function () {
                    keepAlive.received();
                });

                let keepAlive = new KeepAlive(handler);
                keepAlive.pingPeriod = 50;
                keepAlive.warningThreshold = 10;
                keepAlive.windowPeriod = 1000;

                let gotError = false;
                keepAlive.start(function () {
                    if (gotError) {
                        return;
                    }
                    gotError = true;
                    // This should get hit
                    keepAlive.stop();
                    socket.end();
                    server.close(function () {
                        done();
                    });
                });
            });
        });
開發者ID:bespoken,項目名稱:bst,代碼行數:42,代碼來源:keep-alive-test.ts

示例4: constructor

  constructor(private readonly log: Logger, private readonly server: Server) {
    super();

    // HapiJS expects that the following events will be generated by `listener`, see:
    // https://github.com/hapijs/hapi/blob/v14.2.0/lib/connection.js.
    this.eventHandlers = new Map(
      ServerEventsToForward.map(eventName => {
        return [
          eventName,
          (...args: any[]) => {
            this.log.debug(`Event is being forwarded: ${eventName}`);
            this.emit(eventName, ...args);
          },
        ] as [string, (...args: any[]) => void];
      })
    );

    for (const [eventName, eventHandler] of this.eventHandlers) {
      this.server.addListener(eventName, eventHandler);
    }
  }
開發者ID:austec-automation,項目名稱:kibana,代碼行數:21,代碼來源:legacy_platform_proxy.ts

示例5: Promise

 return new Promise((resolve, reject) => {
   this.server.listen(
     port,
     host,
     (err: Error) => (err ? reject(err) : resolve())
   )
 })
開發者ID:aranja,項目名稱:tux,代碼行數:7,代碼來源:Server.ts

示例6: getConnections

  /**
   * Neither new nor legacy platform should use this method directly.
   */
  public getConnections(callback: (error: Error | null, count?: number) => void) {
    this.log.debug('"getConnections" has been called.');

    // This method is used by `even-better` (before we start platform).
    // It seems that the latest version of parent `good` doesn't use this anymore.
    this.server.getConnections(callback);
  }
開發者ID:austec-automation,項目名稱:kibana,代碼行數:10,代碼來源:legacy_platform_proxy.ts

示例7: getConnections

 /**
  * Neither new nor legacy platform should use this method directly.
  */
 public getConnections(callback: (error: Error | null, count?: number) => void) {
   // This method is used by `even-better` (before we start platform).
   // It seems that the latest version of parent `good` doesn't use this anymore.
   if (this.server) {
     this.server.getConnections(callback);
   } else {
     callback(null, 0);
   }
 }
開發者ID:Jaaess,項目名稱:kibana,代碼行數:12,代碼來源:legacy_platform_proxifier.ts

示例8: done

 keepAlive.start(function () {
     if (gotError) {
         return;
     }
     gotError = true;
     // This should get hit
     keepAlive.stop();
     socket.end();
     server.close(function () {
         done();
     });
 });
開發者ID:bespoken,項目名稱:bst,代碼行數:12,代碼來源:keep-alive-test.ts

示例9: Promise

	await new Promise((resolve) => {
		if (server != null) {
			server.close(resolve);
		}
	});
開發者ID:andrew-w-ross,項目名稱:fuse-debug,代碼行數:5,代碼來源:index.ts

示例10: address

  /**
   * Neither new nor legacy platform should use this method directly.
   */
  public address() {
    this.log.debug('"address" has been called.');

    return this.server.address();
  }
開發者ID:austec-automation,項目名稱:kibana,代碼行數:8,代碼來源:legacy_platform_proxy.ts


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