1.0.1 • Published 6 years ago
@gamefast/ching-sdk v1.0.1
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'));