feat: 使 Nakama custom ID 持久化以确保用户身份一致性
This commit is contained in:
parent
83377543f8
commit
241722e1af
@ -77,9 +77,13 @@ class NakamaManager {
|
|||||||
async authenticateWithGameToken(gameToken) {
|
async authenticateWithGameToken(gameToken) {
|
||||||
this.gameToken = gameToken;
|
this.gameToken = gameToken;
|
||||||
|
|
||||||
// 生成唯一的 custom ID
|
// 获取或生成持久化的 custom ID
|
||||||
const customId = `game_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
let customId = uni.getStorageSync('nakama_custom_id');
|
||||||
console.log('[Nakama] Authenticating with Custom ID:', customId);
|
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 认证请求
|
// HTTP 认证请求
|
||||||
const scheme = this.useSSL ? 'https://' : 'http://';
|
const scheme = this.useSSL ? 'https://' : 'http://';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user