Bonjour,

J'ai une application qui est + d'un modèle Client/serveur qu'une application classique.
Je me suis développé 3 classes, un 'acheteur', un 'vendeur', tous 2 évenenemts aysnchrones et un centrailisateur (Containeur).
Si au niveau de l'idée je pense qu'il n'y a pas trop de problème, j'en ai au nivean PHP simple....

Voici ma classe Buyer

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
?php
// =============================================================================================================================== //
//                                 Class BUYER                                                                                  //
// =============================================================================================================================== //
class Buyer
{	private $container ;
 
	function __construct($container)
	{ 	$this->container = $container ;
		print("Buyer instanciated" .CRLF) ;   
	}
 
	function __destruct() 
	{ 	print("Buyer destroyed"    .CRLF) ;   }  
 
	function execute()
	{	$this->addBuyer("B1") ;   }
 
	function addBuying()
	{	$this->add("Membre","GU_Email" ) ;
		$this->add("Membre","GU_Member") ;
	}
 
	function add($class , $method)$method) ) ;}
 
	function notify($event)
	{}
}
?>
Et ma classe Seller
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
<?php
// =============================================================================================================================== //
//                                 Class PROVIDER                                                                                  //
// =============================================================================================================================== //
class Seller
{	private $container ;
 
	function __construct($container)
	{ 	$this->container = $container ;
		print("Seller instanciated" .CRLF) ;   
	}
 
	function __destruct() 
	{ print("Request destroyed"    .CRLF) ;   }  
 
	function execute()
	{	$this->addSeller("S1") ;  }
 
	function addSelling()
	{	$this->add("Membre","GU_Email" ) ;
		$this->add("Membre","GU_Member") ;
	}
 
	function add($class , $method)
	{	$this->container->addSellin( array( microtime() , $class, $method) ) ;}
 
	function notify($event)
	{}
 }
?>
Et maintenant ma class COntainer ou centralisateur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
define("CRLF" , "\n<br>") ;
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/seller.php";  
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/buyer.php";  

/**
* 	Class Container: will pas through "request" & "supply" to the corresponding class but is responsible of the matching events !
*	=============================================================================================================================
*/
class Container
{	private $buyer  = array() ;
	private $seller = array() ;

	function __contruct()
	{	$this->execute() ;  }
	
	function execute()
	{	try {
	
			} catch (Exception $E) 
				{	throw("SKELETON CONNECTION ERROR: " . $this->display_exception($E) . CRLF);
				}
	}
	
	function __destruct()
	{}

/**
* 	add supply
*	------------
* 	param obj: objname instanciated and having an "notify" property to be get in touch
*/
	function addSeller( $obj )
	{	$this->seller[] = $obj ;	}
	
/**
* 	remove supply
*	---------------
*/
	function removeSeller($obj)
	{	if ( in_array($this->seller , $obj) )
			unset( $this->seller[$obj] ) ;   
		else
			return(false) ;
	}
	
/**
* 	count supply
*	--------------
*/
	function countSeller($obj)
	{	return( $this->seller ) ; }
	
/**
* 	print seller
*	--------------
*/
	function printSeller()
	{	print("printseller" . CRLF) ; 
		print_r($this->seller ) ;
		
		for ($i = 0 ; $i < count($this->seller) ; $i++)
Ligne 63==>		{	print($i . " seller[". $this->seller[$i] . CRLF ) ;	}
	}
	 
/**
* 	print Supplies
*	--------------
*/
	function printSupplies()
	{	print("printseller" . CRLF) ; 
		print_r($this->seller ) ;
		
		for ($i = 0 ; $i < count($this->seller) ; $i++)
		{	print($i . " Stamp   [". $this->seller[$i][0]."] => 
		                Class    [". $this->seller[$i][1]."] => 
						Ressource[". $this->seller[$i][2]."]" . CRLF ) ;  
		}
	}
	 
/**
* 	add Buyer
*	------------
* 	param obj: objname instanciated and having an "notify" property to be get in touch
*/
	function addBuyer( $obj )
	{	$this->buyer[] = $obj ; }
	
/**
* 	remove seller
*	---------------
*/
	function removeBuyer($obj)
	{	if ( in_array($this->buyer , $obj) )
			unset( $this->buyer[$obj] ) ;   
		else
			return(false) ;
	}
	
/**
* 	count Buyer
*	--------------
*/
	function countBuyer($obj)
	{	return( count($this->buyer) ) ; }
	
/**
* 	print Buyer
*	--------------
*/
	function printBuyer()
	{	print("printbuyer" . CRLF) ; 
		for ($i = 0 ; $i < count($this->buyer) ; $i++)
		{	print($i . " Stamp   [". $this->buyer[$i][0]."] => 
		                Class    [". $this->buyer[$i][1]."] => 
						Ressource[". $this->buyer[$i][2]."]" . CRLF ) ;  
		}
	}
	
/**
* 	display Exception
*	-----------------
*/
   function display_exception($E)
   {	$T = $E->getTrace() ; 
	//	======================================================================
		print("MYsql error diagnostic" .  "<br>\n") ;
		print("================" .  "<br>\n") ;
		print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
		print("<br>\n") ;
		print("Trace: " . "<br>\n") ;
		print("------ " . "<br>\n") ;
		print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
		print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
 		print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
		print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
	//	======================================================================
		user_error("Catching[connect error in File: " . $T[0]["file"] . "] - line: [" . $T[0]["line"] . "]" , E_USER_ERROR) ;  
	//	======================================================================
	}
}

$container = new Container() ;
$container->addBuyer (new Buyer ($container) ) ;
$container->addSeller(new Seller($container) ) ;

$container->printSeller() ;
$container->printBuyer() ;

?>
Donc, le principe est de dire moi B1, je vends B1,B2.....
et à un moment donné, mon A, jachète B2 et Z7

Je rôle de container est de mettre en rapport les acheteurs et vendeurs !

Bon, PHP râle déjà, car dans le print Vendeur il prend l"indicateur de celui-ci comme un object, ce que je ne comprends pas, voici le message du log:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
[18-Jun-2010 09:56:03] PHP Catchable fatal error:  Object of class Seller could not be converted to string in F:\WebSites\container\index.php on line 63
Al'écran, j'ai

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
Buyer instanciated
Seller instanciated
printseller
Array ( [0] => Seller Object ( [container:Seller:private] => Container Object ( [buyer:Container:private] => Array ( [0] => Buyer Object ( [container:Buyer:private] => Container Object *RECURSION* ) ) [seller:Container:private] => Array *RECURSION* ) ) )
Or quand j'ai fait le AddSeller, je me suis identifié par un string et non un objet.....
L'idée de départ était d'enregistrer un tableau 'identifiant, class, requête )
Maislà, je pense déjà aller un peu vite....

Merci de votre aide à continuer mon projet