Skip to content

Module: Server

Aviril edited this page Mar 16, 2024 · 2 revisions

━ APIs

━ vNetwork.create() (Shared)

@Objective: Creates a vNetwork server.
const server: cServer = vNetwork.create(
  object: options // (Optional): server's connection options
)

// Client Options:
options: {
  port: 3000, // Server's port
  hostname: "localhost", // If left unspecified, will fallback to 'window.location.hostname'
  isSSL: true // Bool indicating whether SSL is enabled on server
}

// Server Options:
options: {
  port: 3000, // Server's port,
  bandwidth: 1, // Server's max bandwidth in mb
  isCaseSensitive: false, // Determines whether the routes are case-sensitive
  cors: {} // Cors options
}

━ vNetwork.setSSLCert() (Server)

@Objective: Sets/Revokes SSL-Cert.
const bool: state = vNetwork.setSSLCert(
  object: sslcert // (Optional): Omitting will result in SSL-Cert to be revoked (If any)
)

━ Methods

━ server.destroy() (Shared)

@Objective: Destroys existing vNetwork server.
const bool: state = cServer.destroy()

━ server.fetchConfig() (Shared)

@Objective: Retrieves server's config.
const object: config = cServer.fetchConfig()

━ server.fetchServer() (Shared)

@Objective: Retrieves server's specified server.
const object: server = cServer.fetchServer(
  string: index // Index could be either of "express", "http"
)

━ server.isConnected() (Shared)

@Objective: Retrieves server's connectivity status.
// Client Syntax:
const bool: state = cServer.isConnected(
  bool: isSync // (Optional): If enabled, retrieves result immediately
  bool: fetchHealth // (Optional): If enabled, fetches server's realtime health via health-point
)

// Server Syntax:
const bool: state = cServer.isConnected(
  bool: isSync // (Optional): If enabled, retrieves result immediately
)

━ server.connect() (Shared)

@Objective: Connects to server.
const bool: state = cServer.connect()