Beispiel #1
0
def _bio(sock: socket, bio):
    timestamp = ''
    bio_msg = send_bio_processor(token, bio, timestamp)
    send = sock.makefile('w')
    send.write(bio_msg + '\r\n')  # bio
    send.flush()
    response(sock)
Beispiel #2
0
def _bio(sock: socket, bio, nprofile):
    timestamp = ''
    # encryption and send back my public key to the server
    bio = nprofile.encrypt_entry(bio, token)
    bio_msg = send_bio_processor(nprofile.public_key, bio, timestamp)
    send = sock.makefile('w')
    send.write(bio_msg + '\r\n')  # bio
    send.flush()
    response(sock)
Beispiel #3
0
def post(sock: socket, message):
    send = sock.makefile('w')
    for single_post in message:
        entry = single_post.get_entry()
        if test_mode:
            print(entry)
        timestamp = single_post.get_time()
        post_msg = send_post_processor(token, entry, timestamp)
        send.write(post_msg + '\r\n')  # bio
        send.flush()
        # the server's message reception time interval must be long enough
        # and I set 1 for convenience, or it will print an error cause I'm
        # sending message to it too frequently.
        time.sleep(1)
    response(sock)
Beispiel #4
0
def join(sock: socket, username, password):
    global token
    join_msg = send_join_processor(username, password)
    send = sock.makefile('w')
    send.write(join_msg + '\r\n')  # bio
    send.flush()
    token = response(sock).token
Beispiel #5
0
def post(sock: socket, message, nprofile):
    send = sock.makefile('w')
    for single_post in message:
        entry = single_post.get_title() + '\n' + single_post.get_entry()
        # encryption
        entry = nprofile.encrypt_entry(entry, token)

        if test_mode:
            print(entry)

        timestamp = single_post.get_time()
        # and send back my public key to the server
        post_msg = send_post_processor(nprofile.public_key, entry, timestamp)
        send.write(post_msg + '\r\n')  # bio
        send.flush()
        # the server's message reception time interval must be long enough
        # and I set 1 for convenience, or it will print an error cause I'm
        # sending message to it too frequently.
        response(sock)
        time.sleep(1)