Compare commits

..

2 Commits

View File

@ -77,9 +77,13 @@ class NakamaManager {
async authenticateWithGameToken(gameToken) {
this.gameToken = gameToken;
// 生成唯一的 custom ID
const customId = `game_${Date.now()}_${Math.random().toString(36).substring(7)}`;
console.log('[Nakama] Authenticating with Custom ID:', customId);
// 获取或生成持久化的 custom ID
let customId = uni.getStorageSync('nakama_custom_id');
if (!customId) {
customId = `game_${Date.now()}_${Math.random().toString(36).substring(7)}`;
uni.setStorageSync('nakama_custom_id', customId);
}
console.log('[Nakama] Authenticating with Persistent ID:', customId);
// HTTP 认证请求
const scheme = this.useSSL ? 'https://' : 'http://';