mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	[Clinet] Fix bug
This commit is contained in:
		
							parent
							
								
									c297b491d9
								
							
						
					
					
						commit
						5e5986f5f5
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,12 @@ const riot = require('riot');
 | 
			
		|||
 | 
			
		||||
class Connection {
 | 
			
		||||
	constructor(me, otherparty) {
 | 
			
		||||
		// BIND -----------------------------------
 | 
			
		||||
		this.onOpen =    this.onOpen.bind(this);
 | 
			
		||||
		this.onMessage = this.onMessage.bind(this);
 | 
			
		||||
		this.close =     this.close.bind(this);
 | 
			
		||||
		// ----------------------------------------
 | 
			
		||||
 | 
			
		||||
		this.event = riot.observable();
 | 
			
		||||
		this.me = me;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -20,8 +26,8 @@ class Connection {
 | 
			
		|||
 | 
			
		||||
	onMessage(message) {
 | 
			
		||||
		try {
 | 
			
		||||
			const message = JSON.parse(message.data);
 | 
			
		||||
			if (message.type) this.event.trigger(message.type, message.body);
 | 
			
		||||
			const msg = JSON.parse(message.data);
 | 
			
		||||
			if (msg.type) this.event.trigger(msg.type, msg.body);
 | 
			
		||||
		} catch(e) {
 | 
			
		||||
			// noop
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue