-
Notifications
You must be signed in to change notification settings - Fork 0
Draft
Charles Samborski edited this page Jan 27, 2016
·
2 revisions
let ircProxy = new ProxyIRC();
interface Message{
getText(): string; // tout message (texte, image, autre fichier) doit avoir une représentation sous forme de string pour toujours avoir quelque chose à afficher (erreur de chargement, etc).
getCreationDate(): Date;
getLastUpdateDate(): Date;
getAuthor(): Contact;
// getType(): string;
getContent(): any; // renvoi un contenu plus pertinent. Chaque type de message devra implémenter elle-même cette méthode.
}
class Account{
protocols: string; // irc, facebook, etc
data: any;
}
interface Contact{
accounts: Account[];
name: string;
_id: any;
startDiscussion();
}
interface Discussion{
getMessages(): Message[]; // ou getHistory {dateMax, dateMin, nbMessages}
sendMessage(msg: Message); // envoie le message à tous les participants de la discussion
getParticipants(): Contact[];
onMessage(callback: (msg: Message) => any);
creationDate: Date;
getName(): string; // nom de le discussion
getDescription(): string; // description de la discussion
getSettings(): any; // tout les paramètres de la discussion, même spécifiques (map)
}
/*
Entry point for the library
Maintains the list of available proxies and connected users
*/
class Client{
proxies: StaticProxy[];
users: User[];
// useProxy(p: Proxy);
getProxyFor(protocol: string):StaticProxy{
for(let i=0; i<this.proxies.length; i++){
if(this.proxies[i].isCompatibleWith(protocol)){
return this.proxies[i];
}
}
}
}
interface User{
getAccounts(): Account[];
getContacts(): Contact[];
}
interface StaticProxy{
isCompatibleWith(protocol: string): boolean;
getContacts(account: Account): Contact[];
sendMessage(target: Contact, discussion: Discussion);
}
interface Proxy{
}
class ProxyIRC implements Proxy{
static isCompatibleWith(protocol: string): boolean{
return protocol === 'irc';
};
getContacts() {
}
}
let a:StaticProxy = ProxyIRC;