@gamefast/ching-sdk

```js import Client from '@gamefast/ching-sdk';

Usage no npm install needed!

<script type="module">
  import gamefastChingSdk from 'https://cdn.skypack.dev/@gamefast/ching-sdk';
</script>

README

Client Usage Examle

import Client from '@gamefast/ching-sdk';

const client = new Client({
    host: '127.0.0.1',
    port: 3001,
    secure: false
});

/** Player */
/**
 * @param data Object
 * {
 *   status: Boolean,
 *   room: {
 *     players: [
 *          { id: id1, name: String, avatar: String, ....? },
 *     ],
 *     bet: Number,
 *     type: String,
 *     id: String,
 *     timer: Number
 *   }
 *
 * }
 * */


client.onPlayerSubscribe(data => {
    console.log('======SUBSCRIBE========')
    console.log(data);
    console.log('=======================');
    client.ready(true);
});

/**
 *
 * @param timer Number
 *
 * */


/** Room */
client.onGameStart((data) => {
    console.log("===========Game Start============");
    console.log(data)
});

/**
 *
 * @param winnerId? String
 * @param draw? Boolean
 * /..YOUR_API_RESPONSE_DATA../
 * */

client.onGameFinish(data => {
    console.log("===========Game Finish============");
    console.log(data)
});

/**
 *
 * @param player
 * {
 *  id: String
 * }
 *
 * */

client.onPlayerLeave(player => {
    console.log('===========ROOM PLAYER LEAVE========');
    console.log(player);
});

/**
 *
 * @param player
 * {
 *  id: String,
 *  status: Boolean
 * }
 *
 * */
client.onPlayerReady(console.log);

/**
 * @param status Boolean
 */

client.onPlayerJoinRoom(({ status }) => {
    console.log('============PLAYER JOIN ROOM==========');
    console.log(status);
});

/**
 * @description If both players skipped their turns, e.g. timer expired
 */

client.onMatchFinish(() => {
    console.log('============ROOM MATCH FINISH==========');
});

//** Socket Events
client.onConnect(() => console.log('SocketCluster onConnect'));
client.onDisconnect(() => console.log('SocketCluster onDisconnect'));