0.0.4 • Published 1 year ago

@jasakode/wsc v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

WSC

wesocket client easy to use,

Connecting

import WSC, { Message, MessageForm, Config } from "wsc";

const config : Config = {
    host: `wss://${window.location.host}`,
    autoConnect: false,
    connection: "close",
    reconnecting: false,
    reconnectingTime: 10000,
};

const ws = new WSC(); // config optional
ws.connect("ws://127.0.0.1:8080/ws");

create Authenctication

const { ActionAuth } = ws.injectAction({
    Auth: "authentication"
});

ActionAuth.onMessage((msg) => {
    const message: MessageForm<any> = {
        action: "authentication",
        status: "OK",
        message: "",
        headers: {},
        data: {
            username: "admin",
            password: "admin"
        },
    };
    ActionAuth.respon(msg.id, message);
});
0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago