fix: matchmaking support start stop, multi connection
This commit is contained in:
		@ -14,7 +14,7 @@ class MatchMaking
 | 
			
		||||
		this.searching = false;
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
	async start(func, mode)
 | 
			
		||||
	async start(receive_func, disconnect_func, mode)
 | 
			
		||||
	{
 | 
			
		||||
		if (!await this.client.isAuthentificate())
 | 
			
		||||
			return null;
 | 
			
		||||
@ -25,10 +25,21 @@ class MatchMaking
 | 
			
		||||
		
 | 
			
		||||
		this.searching = true;
 | 
			
		||||
 | 
			
		||||
		this.receive_func = receive_func;
 | 
			
		||||
		this.disconnect_func = disconnect_func;
 | 
			
		||||
 | 
			
		||||
		this._socket.onmessage = function (event) {
 | 
			
		||||
			const data = JSON.parse(event.data);
 | 
			
		||||
			func(data.game_id)
 | 
			
		||||
			receive_func(data);
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		this._socket.onclose = this.onclose.bind(this);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	onclose(event)
 | 
			
		||||
	{
 | 
			
		||||
		this.stop();
 | 
			
		||||
		this.disconnect_func()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	async stop()
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user