Core - Geodan/cow GitHub Wiki

Classes


Description

The Core class is the COW instance object that contains the projects, the users and the server url.

Attributes

Below are the attributes of the COW Core class. NOTE: the attributes must not be accessed directly but through the API functionality.

  • string serverUrl: string containing the URL of the server. Default is wss://localhost:443

  • project [ ] projects: array of projects. Each project is uniquely identified by it's PID (project identity).

  • user [ ] users: array of users. Each user is uniquely identified by it's ID (user identity).

Internal Attributes

  • string options: $.extend({}, new $.fn.cow.defaults.core(), options);
  • string element: element;
  • string map: window[this.options.map];
  • string ws: {};
  • peers [ ] peerList: [];
  • groups [ ] groupList: [];
  • string _username: 'Anonymous';
  • string _pid: //Personal ID. Used to identify people.
  • PID project: //This will become the active project object
  • PID activeProject:
  • string localDbase:
  • string projectsDb:
  • groups [ ] groupsDb:
  • string itemsDb:
  • string geoLocator:
  • string items:
  • string events:

Methods

(Currently under revision)

  • string getServerUrl():

  • string setServerUrl(URL):

  • project getProject(PID):

  • string createProject():

  • boolean deleteProject(PID):

  • boolean connected():

Internal Methods

(Currently under revision)

msg: the message received

  • onConnected(msg): Client should: 1. assign CID to self. 2. Let the world know about self with 'newPeer' 3. Let the world know about own herd with 'herdInfo' 4. Sent feature idlist to world with 'newPeerFidList'

  • onPeerGone(msg): Client should: remove peer with peerCid from list. Assign newCid to self and sent new Cid to world with 'updatePeers'.

  • onInformPeer(msg): Client should: add peerinformation to peerslist

  • onSyncPeer(msg): Client should: 1. sent features from requestlist to other peers with 'requestedFeats' 2. add features for own use from pushlist

  • onRequestedFeats(msg): Client should: add features to own store

  • onUpdatePeers(msg): Client should: update peerlist with new CID's

  • onNewPeer(msg): Client should: 1. Add peer to own peerslist 2. Sent own peerinformation with 'informPeer' 3. Sent info on own herd with 'herdInfo'

  • onNewPeerIidList(msg): Client should: (only when being the alphapeer) 1. Find id's that are new(er) compared to own list and add to requestlist 2. Find id's that are old(er) compared to own list and add to pushlist 3. Sent requestlist and pushlist with 'syncPeer

  • onPeerUpdated(msg): Client should: update the peer in the peerslist accordingly

  • onNewItem(msg): Client should: add feature to own store

  • onGetProjectInfo(msg): Client should: send info about project

  • onProjectInfo(msg): Client should: ....