Hi,
sorry for the newbie question. I’m trying to setup a server-authoritative on Windows 10 machine.
after I finished installing CockroachDB & Nakama. My game can now connect to server, start matchmaking, play against other player without any problem.
but my TypeScript runtime seem not to work.
When Nakama server start, I can see log text from InitModule.
but other match handler function didn’t show log text at all.
Could anyone point out what I have done wrong in my code below?
Thanks in advance for any help!
let InitModule : nkruntime.InitModule = function(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer) {
logger.info('My Custom Module initialized.');
initializer.registerMatch('lobby', {
matchInit,
matchJoinAttempt,
matchJoin,
matchLoop,
matchLeave,
matchTerminate,
matchSignal
});
}
const matchInit = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, params: {[key: string]: string}) : {state: nkruntime.MatchState, tickRate: number, label: string} => {
logger.info('My Custom Match initialized.');
return {
state: { },
tickRate: 1,
label: ''
};
};
const matchJoinAttempt = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, presences: nkruntime.Presence, metadata : {[key : string]: any}) : {state: nkruntime.MatchState, accept: boolean, rejectMessage?: string | undefined} | null => {
logger.info('My Custom Match JoinAttempt');
return {
state,
accept: true
};
};
const matchJoin = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, presences: nkruntime.Presence[]) : {state: nkruntime.MatchState} | null => {
logger.info('My Custom Match Join');
return {state};
};
const matchLeave = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, presences: nkruntime.Presence[]) : {state: nkruntime.MatchState} | null => {
logger.info('My Custom Match Leave');
return {state};
};
const matchLoop = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, messages: nkruntime.MatchMessage[]) : {state: nkruntime.MatchState} | null => {
return {state};
};
const matchTerminate = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, graceSeconds: number) : {state: nkruntime.MatchState} | null => {
return {state};
};
const matchSignal = (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, dispatcher: nkruntime.MatchDispatcher, tick: number, state: nkruntime.MatchState, data: string) : {state: nkruntime.MatchState, data?: string} | null => {
logger.debug('Lobby match signal recieved: ' + data);
return {state, data};
};