Log in

No account? Create an account
new network code - LogJam [entries|archive|friends|userinfo]

[ website | LogJam ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

new network code [Mar. 10th, 2003|06:18 pm]
New network code is now in CVS. LogJam now supports native networking calls on Windows, and the code for Unix is a bunch cleaner. Here are my notes on it (primarily for someone like gaal, who might have to use it someday!) and for whoever else cares.

The old network code used to be a big jumble, in part because it was the combination of a few different things in one interdependent pile of functions:
  • the code to use curl
  • the code to handle communication through the fork
  • the GUI for network progress
  • the high-level network-request functions

Redesigning things to work on Windows simultaneously required me to reevaluate all that and I think the result is cleaner. It now looks like this:
  • network-platform.c (currently) provides two low-level HTTP interfaces which report progress through callbacks.
    1. A blocking interface. This actually does the calls into the underlying library.
    2. A "mainloop" interface. (This one is two functions-- one to start, and another to cancel one in progress.) The mainloop interface starts the blocking request in another process/thread and starts a GTK/glib mainloop, which means that if you (for example) had a network status window up when you called the function, it would continue updating.
  • network.c provides the higher-level interface used through LogJam, in which you give it a NetRequest hash and it returns a NetResult hash. It handles all the GUI and serializing/deserializing these hashes for use in HTTP requests by the lower layer.

Why is this important? Well, aside from things working on Windows, now, there are a bunch of places we've needed finer control over the network requests. For example, we're now able to do things like pull a person's userpics (which will use the HTTP functions with a different GUI and not the higher-level LiveJournal-request-oriented functions) and download a person's journal (which will be a series of LiveJournal-requests that need a different GUI as well).

In case you haven't guessed, I got mono and I've been stuck inside for a week. :)

[User Picture]From: frew
2003-03-11 02:32 pm (UTC)
Wow...good job, looks sweet.
(Reply) (Thread)