forked from cory/tildefriends
		
	ssb: Connection result preliminary hookup to ui, and fix some fallout.
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	"type": "tildefriends-app",
 | 
						"type": "tildefriends-app",
 | 
				
			||||||
	"emoji": "🐌",
 | 
						"emoji": "🐌",
 | 
				
			||||||
	"previous": "&0ZjcRFTyAmJMm3qhqKy5Ffrue23G1CAUfc1i2WYZrzQ=.sha256"
 | 
						"previous": "&+UZSxjoucLAl5r/nfRNu5KXx3K/PdutGnizL/Cn2eCU=.sha256"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ class TfTabConnectionsElement extends LitElement {
 | 
				
			|||||||
			stored_connections: {type: Array},
 | 
								stored_connections: {type: Array},
 | 
				
			||||||
			users: {type: Object},
 | 
								users: {type: Object},
 | 
				
			||||||
			server_identity: {type: String},
 | 
								server_identity: {type: String},
 | 
				
			||||||
 | 
								connect_error: {type: String},
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -163,6 +164,15 @@ class TfTabConnectionsElement extends LitElement {
 | 
				
			|||||||
		tfrpc.rpc.sync();
 | 
							tfrpc.rpc.sync();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						connect(address) {
 | 
				
			||||||
 | 
							let self = this;
 | 
				
			||||||
 | 
							tfrpc.rpc.connect(address).then(function() {
 | 
				
			||||||
 | 
								self.connect_error = 'connected!';
 | 
				
			||||||
 | 
							}).catch(function(error) {
 | 
				
			||||||
 | 
								self.connect_error = error;
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	render() {
 | 
						render() {
 | 
				
			||||||
		let self = this;
 | 
							let self = this;
 | 
				
			||||||
		return html`
 | 
							return html`
 | 
				
			||||||
@@ -178,10 +188,11 @@ class TfTabConnectionsElement extends LitElement {
 | 
				
			|||||||
				<button
 | 
									<button
 | 
				
			||||||
					class="w3-button w3-theme-d1"
 | 
										class="w3-button w3-theme-d1"
 | 
				
			||||||
					@click=${() =>
 | 
										@click=${() =>
 | 
				
			||||||
						tfrpc.rpc.connect(self.renderRoot.getElementById('code').value)}
 | 
											self.connect(self.renderRoot.getElementById('code').value)}
 | 
				
			||||||
				>
 | 
									>
 | 
				
			||||||
					Connect
 | 
										Connect
 | 
				
			||||||
				</button>
 | 
									</button>
 | 
				
			||||||
 | 
									<div ?hidden=${this.connect_error === undefined}>${this.connect_error}</div>
 | 
				
			||||||
				<h2>Broadcasts</h2>
 | 
									<h2>Broadcasts</h2>
 | 
				
			||||||
				<ul class="w3-ul w3-border">
 | 
									<ul class="w3-ul w3-border">
 | 
				
			||||||
					${this.broadcasts
 | 
										${this.broadcasts
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1324,6 +1324,12 @@ static void _tf_ssb_connection_verify_identity(tf_ssb_connection_t* connection,
 | 
				
			|||||||
	JS_SetPropertyStr(context, connection->object, "is_client", JS_TRUE);
 | 
						JS_SetPropertyStr(context, connection->object, "is_client", JS_TRUE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	connection->state = k_tf_ssb_state_verified;
 | 
						connection->state = k_tf_ssb_state_verified;
 | 
				
			||||||
 | 
						if (connection->connect_callback)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							connection->connect_callback(connection, NULL, connection->connect_callback_user_data);
 | 
				
			||||||
 | 
							connection->connect_callback = NULL;
 | 
				
			||||||
 | 
							connection->connect_callback_user_data = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (connection->handshake_timer.data)
 | 
						if (connection->handshake_timer.data)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uv_timer_stop(&connection->handshake_timer);
 | 
							uv_timer_stop(&connection->handshake_timer);
 | 
				
			||||||
@@ -2909,6 +2915,8 @@ void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* ke
 | 
				
			|||||||
		.port = port,
 | 
							.port = port,
 | 
				
			||||||
		.flags = connect_flags,
 | 
							.flags = connect_flags,
 | 
				
			||||||
		.req.data = connect,
 | 
							.req.data = connect,
 | 
				
			||||||
 | 
							.callback = callback,
 | 
				
			||||||
 | 
							.user_data = user_data,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	char id[k_id_base64_len] = { 0 };
 | 
						char id[k_id_base64_len] = { 0 };
 | 
				
			||||||
	tf_ssb_id_bin_to_str(id, sizeof(id), key);
 | 
						tf_ssb_id_bin_to_str(id, sizeof(id), key);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user