Tuesday, December 8, 2015

Thin exnsions to my Dipp Dart app; and: creating common methods.

Certain phase in building my Dipp app: now I think to be ready for to build my first big app. Actually I need this for my learning; otherwise I might get stucked, and this brings some discipline here.  

What? I'm building very thin, elementary and quick expansions (1-24) to Dipp. This "tree" is meant to be thin, for to avoid burden, which might come, when is time to make big fundamental changes. I hope to avoid later big changes, if I create in early phase some common-use methods and classes.  

How am I here?  Hard work, many erros, stupid slowness... and unwillingness to read howTo:s. Project Dipp seems right way to test-learn, and maybe -leave- it at any minute, if it feels so. Route is more important than goal. 

How long will it be fun? Small steps policy... yep..  it means fun forever.

How is this work done?  Very patiently and slowly, one step at a time. One happy hour a day.. at least.  None of those 1-24 phases should take more than an hour to complete, by an exprerienced Dart programmer (not me).

How thin are they?  Hermes might be just to check, that words in streams belong to 170-words lists. Server and-client parts: ready code examples with one default answer.  Some might be just: -Not Ready Yet. HTTP requests are simple..  aso.



///  dipp development flow planList dppDevPlanL = [  
  '1 Rondo everywhere and loopRun, runAll show sleep',
  '2 Main and Side Data',
  
  '3 CL Boxes',
  '4 Web  Dom / Rondo',

  '5 UP-comXX  commands',
  '6     ',
  
  '7 Stream Connection',
  '8 StringBuffer connection  Buffalo',
  
  '9 Labor    data',
  '10 Plugins and their data',

  '11 Flags, ables',
  '12 Zyld, structures',

  '13 Hermes',
  '14 Hermit  ',

  '15 Webster DB Mongo',
  '16 Webster  List, text  ',

  '17 Work, tools, effort',
  '18 Ideas, learn, funny',
  
  '19     ',
  '20 HTTP  data',

  '21 Asker  server',
  '22 Asker  client',
  
  '23 async  version',
  '24     '];


About Dipp app:  Dipp is for collecting and presenting information in various ways.
About 50 classes are grouped under control of 4 main classes: DippApp,wich keeps plugins and extras.  Venue,is like theatre where main flow happends, aso. Parade,which presents Frames. Worker package is used in Hermit class.
  
Dipp has 4 main parts / ideas:
1. Plugins, that give extra functionality and data to other apps
2. Human / labor like entities, that have their own nature,  like Newton.
3. Main data-flow and UNLRS-class which gives main functionality to central Dipp classes. 
4. Extra-functionality under DipApp; Server-client-DB-connections-HTTP aso. 

Basic class is UNLRS.  Upper-Name-loop-run-show  class, which gives much of needed ability to main classes, to run, handle and present their data and show statistic info. 

1. Rondo is common run-method, which gets much automation from UNLRS-class.
5. up-comXX  are 2-letter common upper-level variables. Editor can easy find them.
7.8.  StreamConnection and StringBuffer connections from inside UNLRS class.
9.Labor is about human - worker like objects that have their own nature and interests.
10. Plugins.  In this state is plan to make one of 10:s ready.
11. Flags control some abilities that objects has. I love bits "0100 1011 11", but they might be too difficult, compared to booleans.
12. Zyld is data cylinder. Just a plain idea for now.

13. Hermes is big plan, "Gods messenger" with it's own language handling messages between objects.
14. Hermit is isolates, threads.

15.16. Webster is about Databse,Mongo and simpler data

17. Work, tools effort are some extra folders and files.
18. Ideas - learn, funny...   nmore folders with ideas.

20. HTTP data. Objects might have every their own data in the web for daily search.
21.22. Asker is server-client system for objects data. Plan: Copy-paste from Dartlang.

23. Quick async-version in just one tiny web file.
24. More ideas to come



And common methods, which are to be developed here.  What might they be?

1. Complicated function for giving access to Streams from inside a class.
2. Same with StringBuffer. Remember; Dart do not have nested classes.

3. Presenting "List lof Data" in  "List Of Screen Dom elements".
4. Handling bit-data and developing bit tables / booleans.

5. Common methods for seeking data from diff sources and storing it.
6. Some more sophisticated base-classes for special cases.

7. more...
8. ...And more... 

And:  also these must be very thin and schematic.



And some routines / basic elements for web programming.

Saturday, February 14, 2015

Explanations of methods and properties in Dart HttpClient class. With some notes.

Building Dart clients:      Same post as previous one, but with explanations: 
Some notes of Dart HttpClient class for to help implementing, hacking it.  Source:  
https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:io.HttpClient
This is meant to serve as notebook..

  client.authenticate;
  Add credentials to be used for authorizing HTTP requests.

set authenticate(Function Future<bool> f(Uri url, String scheme, String realm))
Sets the function to be called when a site is requesting authentication. The URL requested and the security realm from the server are passed in the arguments url and realm.
         The function returns a Future which should complete when the authentication has been resolved. If credentials cannot be provided the Future should complete with false. If credentials are available the function should add these using addCredentials before completing the Future with the value true.

If the Future completes with true the request will be retried using the updated credentials. Otherwise response processing will continue normally.

  client.authenticateProxy;      LONG!!:  
  Add credentials to be used for authorizing HTTP proxies.
set authenticateProxy(Function Future<bool> f(String host, int port, String scheme, String realm))


  client.autoUncompress;      LONG:
  bool autoUncompress     :
Get and set whether the body of a response will be automatically uncompressed.

  client.badCertificateCallback;        LONG:
  client.badCertificateCallback( callback(X509Certificate, String, int) → bool)
set badCertificateCallback(Function bool callback(X509Certificate cert, String host, int port))
Sets a callback that will decide whether to accept a secure connection with a server certificate that cannot be authenticated by any of our trusted root certificates.


  client.findProxy;       Long explanation....
set findProxy(Function String f(Uri url))
static String findProxyFromEnvironment(Uri url, {Map<String, String> environment})
Function for resolving the proxy server to be used for a HTTP connection from the proxy configuration specified through environment variables.
  client.findProxy( f(Uri) → String);

  client.hashCode;
int get hashCode
Inherited from Object.       Get a hash code for this object.

  client.idleTimeout;
Duration idleTimeout  Get and set the idle timeout of non-active persistent (keep-alive) connections. The default value is 15 seconds.


  client.maxConnectionsPerHost;
int maxConnectionsPerHost.  Get and set the maximum number of live connections, to a single host.
Increasing this number may lower performance and take up unwanted system resources.
To disable, set to null.  Default is null.

  client.runtimeType;
Type get runtimeType. Inherited from Object.
A representation of the runtime type of the object.

  client.userAgent;
String userAgent.  Set and get the default value of the User-Agent header for all requests generated by this HttpClient. The default value is Dart/<version> (dart:io).
If the userAgent is set to null, no default User-Agent header will be added to each request.

  client.addCredentials(url, realm, credentials);
void addCredentials(Uri url, String realm, HttpClientCredentials credentials)
Add credentials to be used for authorizing HTTP requests.


  client.addProxyCredentials(host, port, realm, credentials);
void addCredentials(Uri url, String realm, HttpClientCredentials credentials)

Add credentials to be used for authorizing HTTP requests.

  client.close();
Shutdown the HTTP client. If force is false (the default) the HttpClient will be kept alive until all active connections are done. If force is true any active connections will be closed to immediately release all resources. These closed connections will receive an onError callback to indicate that the client was shutdown. In both cases trying to establish a new connection after calling shutdown will throw an exception.

  client.delete(host, port, path);
Future<HttpClientRequest> delete(String host, int port, String path)
Opens a HTTP connection using the DELETE method.
The server is specified using host and port, and the path (including possible fragment and query) is specified using path. See open for details.

  client.deleteUrl(url);
Future<HttpClientRequest> deleteUrl(Uri url)
Opens a HTTP connection using the DELETE method.  The URL to use is specified in url.

  client.get(host, port, path);
Future<HttpClientRequest> get(String host, int port, String path)
Opens a HTTP connection using the GET method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

  client.getUrl(url);
Future<HttpClientRequest> getUrl(Uri url)
Opens a HTTP connection using the GET method.  The URL to use is specified in url.


  client.hashCode;

  client.head(host, port, path);
Future<HttpClientRequest> head(String host, int port, String path)
Opens a HTTP connection using the HEAD method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.


  client.headUrl(url);Future<HttpClientRequest> headUrl(Uri url)
Opens a HTTP connection using the HEAD method.   The URL to use is specified in url.

  client.noSuchMethod(invocation);noSuchMethod is invoked when users invoke a non-existent method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod in an Invocation. If noSuchMethod returns a value, that value becomes the result of the original invocation.
The default behavior of noSuchMethod is to throw a NoSuchMethodError.

  client.open(method, host, port, path)
Future<HttpClientRequest> open(String method, String host, int port, String path)
Opens a HTTP connection.
The HTTP method to use is specified in method, the server is specified using host and port, and the path (including possible fragment and query) is specified using path.
The Host header for the request will be set to the value host:port. This can be overridden through the HttpClientRequest interface before the request is sent. NOTE if host is an IP address this will still be set in the Host header.
For additional information on the sequence of events during an HTTP transaction, and the objects returned by the futures, see the overall documentation for the class HttpClient.

  client.openUrl(method, url);
Future<HttpClientRequest> openUrl(String method, Uri url)
Opens a HTTP connection.  The HTTP method is specified in method and the URL to use in url.
The Host header for the request will be set to the value host:port. This can be overridden through the HttpClientRequest interface before the request is sent. NOTE if host is an IP address this will still be set in the Host header.
For additional information on the sequence of events during an HTTP transaction, and the objects returned by the futures, see the overall documentation for the class HttpClient.

  client.patch(host, port, path);
Future<HttpClientRequest> patch(String host, int port, String path)
Opens a HTTP connection using the PATCH method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

  client.patchUrl(url);
Future<HttpClientRequest> patchUrl(Uri url)
Opens a HTTP connection using the PATCH method.  The URL to use is specified in url.

  client.post(host, port, path)
Future<HttpClientRequest> post(String host, int port, String path)
Opens a HTTP connection using the POST method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

    client.postUrl(url);
Future<HttpClientRequest> postUrl(Uri url)
Opens a HTTP connection using the POST method.   The URL to use is specified in url.


  client.put(host, port, path);
Future<HttpClientRequest> put(String host, int port, String path)
Opens a HTTP connection using the PUT method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

  client.putUrl(url); 
Future<HttpClientRequest> putUrl(Uri url)
Opens a HTTP connection using the PUT method.  The URL to use is specified in url.

  client.toString();
String toString()      Inherited from Object  
Returns a string representation of this object.

And somewhere is meant to put some red-pen markings for this...

List of methods and properties in Dart HttpClient class.

Some notes of Dart HttpClient class for to help implementing, hacking it.

https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:io.HttpClient
Tutorial:   https://www.dartlang.org/docs/tutorials/httpserver/
Write HTTP Clients & Servers.
This is meant to quicly be copied for to get needed parts of client, and delete others.
Warning: in editor this brings errors, 'cos missing elements; host, port, path, url, uri, realm aso.
I might do other posting of these, with full explanation of usage instructions.
Material is pasted directly from DartEditors hints-window. Usage: Use this to build "show client properties" app, for to demonstrate your client.  Somebody surely already did it :)


void clientPlay() {      //  my wrapper function
                                   //  add parameters:  host, port, path, url, suri, realm aso.
  client.authenticate;
  client.authenticateProxy;

  client.autoUncompress;

  client.badCertificateCallback;
  client.badCertificateCallback( callback(X509Certificate, String, int) → bool)

  client.findProxy;
  client.findProxy( f(Uri) → String);

  client.hashCode;
  client.idleTimeout;

  client.maxConnectionsPerHost;

  client.runtimeType;
  client.userAgent;

  client.addCredentials(url, realm, credentials);

  client.addProxyCredentials(host, port, realm, credentials);
  client.close();

  client.delete(host, port, path);
  client.deleteUrl(url);

  client.get(host, port, path);
  client.getUrl(url);

  client.hashCode;

  client.head(host, port, path);
  client.headUrl(url);

  client.noSuchMethod(invocation);

  client.open(method, host, port, path)
  client.openUrl(method, url);

  client.patch(host, port, path);
  client.patchUrl(url);

  client.post(host, port, path)
  client.post(host, port, path);
  client.postUrl(url);

  client.put(host, port, path);
  client.putUrl(url);

  client.toString();

}