@gamefast/ching-sdk
1.0.1 • Public • Published
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'));
Versions
Version | Downloads (Last 7 Days) | Tag |
---|
1.0.1 | 3 | latest |
Version History
Version | Downloads (Last 7 Days) | Published |
---|
1.0.1 | 3 | |
1.0.0 | 0 | |
Package Sidebar
Install
npm i @gamefast/ching-sdk
Weekly Downloads