diff --git a/LOKI-NOTES.md b/LOKI-NOTES.md new file mode 100644 index 000000000..b452a56bd --- /dev/null +++ b/LOKI-NOTES.md @@ -0,0 +1,6 @@ +Create fake contacts +#################### +Run `window.getAccountManager().addMockContact()` in the debugger console. This will print the fake contact public key. +Behind the scenes, this also emulates that we're already received the contact's prekeys by generating them and saving them in our db. +Copy/paste that public key in the search bar to start chatting. +The messages should have a "v" tick to mark that the message was correctly sent (you need to run the httpserver from /mockup_servers) \ No newline at end of file diff --git a/mockup_servers/httpserver.py b/mockup_servers/httpserver.py new file mode 100644 index 000000000..b5b7fa0ae --- /dev/null +++ b/mockup_servers/httpserver.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +import time +from http.server import BaseHTTPRequestHandler, HTTPServer + +# HTTPRequestHandler class +class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): + def do_PUT(self): + print('got PUT request to ' + self.path) + # add some latency + time.sleep(2) + # Send response status code + self.send_response(201) + + # Send headers + #self.send_header() + self.end_headers() + + message = self.rfile.read(int(self.headers.get('Content-Length'))).decode('UTF-8') + + print(message) + + # Send message back to client + #message = "ok" + # Write content as utf-8 data + #self.wfile.write(bytes(message, "utf8")) + + # GET + def do_GET(self): + # Send response status code + time.sleep(1) + self.send_response(200) + + # Send headers + self.send_header('Content-type','text/html') + self.end_headers() + + # Send message back to client + message = "Hello world!" + # Write content as utf-8 data + self.wfile.write(bytes(message, "utf8")) + return + +def run(): + print('starting server...') + + # Server settings + # Choose port 8080, for port 80, which is normally used for a http server, you need root access + server_address = ('127.0.0.1', 80) + httpd = HTTPServer(server_address, testHTTPServer_RequestHandler) + print('running server...') + httpd.serve_forever() + + +run() \ No newline at end of file diff --git a/mockup_servers/readme.md b/mockup_servers/readme.md new file mode 100644 index 000000000..fbb3f6320 --- /dev/null +++ b/mockup_servers/readme.md @@ -0,0 +1,6 @@ +http server for mocking up sending message to the server and getting a response back. +websocket server for mocking up opening a connection to receive messages from the server. + +run either server with +`sudo python3