Skip to content

Releases: ZilaWS/server

v2.2.1

12 Jul 20:45
cc28095
Compare
Choose a tag to compare
  • Dependency upgrades

v2.2.0

09 Feb 21:03
Compare
Choose a tag to compare
  • Dependency upgrades

v2.1.0

27 Dec 15:46
9ac8cc5
Compare
Choose a tag to compare

Additions

  • More types are exported to make extending the ZilaServer class much easier.
  • README typo fix

v2.0.5

26 Dec 17:44
78bb719
Compare
Choose a tag to compare
  • README fix

v2.0.4

26 Dec 13:29
2456a47
Compare
Choose a tag to compare
  • README changes

v2.0.3

24 Dec 12:59
f9993a7
Compare
Choose a tag to compare
  • Type dependency fix

v2.0.2

24 Dec 01:32
3ff6771
Compare
Choose a tag to compare
  • Bug fixed with event listeners

v2.0.1

24 Dec 01:04
d696794
Compare
Choose a tag to compare
  • Devdependency change

v2.0.0

23 Dec 23:49
cdbbf61
Compare
Choose a tag to compare

Additions

Cookies

  • The cookies from the WS client's browser now can be accessed via the cookies property.
  • You can now set cookies from the server-side if the client is connected from a browser using setCookie.
  • You can now delete cookies from the targeted client's browser directly from the server-side using the removeCookie function.
  • The client can now sync the cookies to the server-side
    • New local event: onCookieSync

Extendable clients

  • When creating a server you can now specify a custom ZilaClient class

    class MyClient extends ZilaClient {
      public clientData: {
        rank: "admin" | "user";
        username: string;
      }
    
    constructor(socket: WebSocket, ip: string | undefined, server: ZilaServer, isBrowser: boolean, headers: IncomingHttpHeaders, cookies?: Map<string, string>) {
      super(socket, ip, server, isBrowser, headers, cookies);
    
        //This is the best place to authenticate the user.
        if(isBrowser && !AuthUserByBrowser(cookies?.get("loginToken"))) {
          this.kick("Wrong token");
          return;
        }else if (!AuthUserByHeader(headers["authorization"])) {
          this.kick("Wrong token");
          return;
        }
    
        this.clientData = {
          rank: "admin",
          username: "SomeUsername"
        }
      }
    }
    
    const server = new ZilaServer<MyClient>({
      port: 6589,
      logger: true,
      verbose: true,
      clientClass: MyClient
    });
    
    server.onceMessageHandler("Anything", (socket) => {
      socket.clientData == {
        rank: "admin",
        username: "SomeUsername"
      }; //--> true
    });

Waiting for clients

  • This update solves a major security issue waiters
  • Two new functions: waiterTimeout and broadcastWaiterTimeout. Both has a maxWaitingTime parameter. This parameter constains the max time the server should wait for the client / each connected client
  • The waiter's and waiterBroadcast's now has max waiting time and it is the server's maxWaiterTime setting.
  • A server's maxWaiterTime can be set in the settings upon server creation or directly using the server's corrresponding property.

Others

  • Checks for passing a function down to a client has been removed. The built-in JSON serializer ingores functions by default.
  • An array of the server's actively connected clients can now be accessed through a the clients property of the corresponding server.
  • ILogger interface typeguard for text parameter.
  • Added property isBrowser to ZilaClient. This determines if the client's environment is a browser on not.
  • The WS server is now powered with a seperate HTTP/HTTPS server.
  • If the client is already banned by the server while connecting, the connection gets terminated about 4 times faster.

v1.1.2

03 Nov 20:57
Compare
Choose a tag to compare
  • Babel security fix