Remove ping, update to latest spec proposal
This commit is contained in:
		
					parent
					
						
							
								82d04e347c
							
						
					
				
			
			
				commit
				
					
						90eb9cb0c8
					
				
			
		
					 2 changed files with 4 additions and 19 deletions
				
			
		
							
								
								
									
										18
									
								
								js/api.js
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								js/api.js
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -294,8 +294,6 @@ window.textsecure.api = function() {
 | 
			
		|||
			var params = $.param({});
 | 
			
		||||
 | 
			
		||||
		var reconnectSemaphore = 0;
 | 
			
		||||
		var pingInterval;
 | 
			
		||||
 | 
			
		||||
		var socketWrapper = { onmessage: function() {}, ondisconnect: function() {}, onconnect: function() {} };
 | 
			
		||||
 | 
			
		||||
		var connect = function() {
 | 
			
		||||
| 
						 | 
				
			
			@ -307,7 +305,6 @@ window.textsecure.api = function() {
 | 
			
		|||
 | 
			
		||||
			socket.onerror = function(socketEvent) {
 | 
			
		||||
				console.log('Server is down :(');
 | 
			
		||||
				clearInterval(pingInterval);
 | 
			
		||||
				reconnectSemaphore--;
 | 
			
		||||
				setTimeout(function() { connect(); }, reconnectTimeout);
 | 
			
		||||
				socketWrapper.ondisconnect();
 | 
			
		||||
| 
						 | 
				
			
			@ -315,7 +312,6 @@ window.textsecure.api = function() {
 | 
			
		|||
 | 
			
		||||
			socket.onclose = function(socketEvent) {
 | 
			
		||||
				console.log('Server closed :(');
 | 
			
		||||
				clearInterval(pingInterval);
 | 
			
		||||
				reconnectSemaphore--;
 | 
			
		||||
				setTimeout(function() { connect(); }, reconnectTimeout);
 | 
			
		||||
				socketWrapper.ondisconnect();
 | 
			
		||||
| 
						 | 
				
			
			@ -323,14 +319,6 @@ window.textsecure.api = function() {
 | 
			
		|||
 | 
			
		||||
			socket.onopen = function(socketEvent) {
 | 
			
		||||
				console.log('Connected to server!');
 | 
			
		||||
				pingInterval = setInterval(function() {
 | 
			
		||||
					console.log("Sending server ping message.");
 | 
			
		||||
					if (socket.readyState == socket.CLOSED || socket.readyState == socket.CLOSING) {
 | 
			
		||||
						socket.close();
 | 
			
		||||
						socket.onclose();
 | 
			
		||||
					} else
 | 
			
		||||
						socket.send(JSON.stringify({type: 2}));
 | 
			
		||||
				}, reconnectTimeout / 2);
 | 
			
		||||
				socketWrapper.onconnect();
 | 
			
		||||
			};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -343,9 +331,7 @@ window.textsecure.api = function() {
 | 
			
		|||
					return;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (message.type == 3)
 | 
			
		||||
					console.log("Got pong message");
 | 
			
		||||
				else if ((message.type === undefined && message.id !== undefined) || message.type === 4)
 | 
			
		||||
				if ((message.type === undefined && message.id !== undefined) || message.type === 4)
 | 
			
		||||
					socketWrapper.onmessage(message);
 | 
			
		||||
				else
 | 
			
		||||
					console.log("Got invalid message from server: " + message);
 | 
			
		||||
| 
						 | 
				
			
			@ -368,7 +354,7 @@ window.textsecure.api = function() {
 | 
			
		|||
		//XXX
 | 
			
		||||
		var socketWrapper = { onmessage: function() {}, ondisconnect: function() {}, onconnect: function() {} };
 | 
			
		||||
		setTimeout(function() {
 | 
			
		||||
			socketWrapper.onmessage({type: 4, message: "404-42-magic"});
 | 
			
		||||
			socketWrapper.onmessage({uuid: "404-42-magic"});
 | 
			
		||||
		}, 1000);
 | 
			
		||||
		return socketWrapper;
 | 
			
		||||
		//return getWebsocket(URL_CALLS['temp_push'], false, 5000);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -138,10 +138,9 @@ textsecure.registerOnLoadFunction(function() {
 | 
			
		|||
				var socket = textsecure.api.getTempWebsocket();
 | 
			
		||||
 | 
			
		||||
				socket.onmessage = function(message) {
 | 
			
		||||
					//TODO: Get a server format for this
 | 
			
		||||
					if (message.type === 4) {
 | 
			
		||||
					if (message.uuid) {
 | 
			
		||||
						qrCode.makeCode('textsecure-device-init:/' +
 | 
			
		||||
										'?channel_uuid=' + message.message +
 | 
			
		||||
										'?channel_uuid=' + message.uuid +
 | 
			
		||||
										'&channel_server=' + textsecure.api.relay +
 | 
			
		||||
										'&publicKey=' + btoa(getString(cryptoInfo.publicKey)));
 | 
			
		||||
						$('img').removeAttr('style');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue