PhoneSystemReset Method
This method resets(initializes) connection to Configuration server and provides Root object without exceptions.
All handlers connected to the PhoneSystem.Root will receive "CFGSERVER" deleted and will be removed.
new set of hanlders will be set and they will receive CFGSERVER Inserted/Updated according to status of new connection
this method obsoletes initialization code like
try
{
PhoneSystem.ApplicationName = appname;
PhoneSystem.CfgServerHost = cfghost;
PhoneSystem.CfgServerPort = cfgport;
PhoneSystem.CfgServerUser = cfguser;
PhoneSystem.CfgServerPassword = cfgpassword;
var root = PhoneSystem.Root;
root.Inserted += insertHandler;
root.Updated += updatHandler;
root.Deleted += deleteHandler;
}
catch
{
//we are here without subscription to the events and need to repeat code in try section
}
Now it should be coupled with
WaitForConnect(TimeSpan):
PhoneSystem ps = PhoneSystem.Reset(appname, cfghost, cfgport, cfguser, cfgpassword, insertedHandler, updatedHandler, deletedHandler)
while(!ps.WaitForConnection(Timespan.FromSeconds))
{
//no connection handler
}
benefits of using
Reset(String, String, Int32, String, String, NotificationEventHandler, NotificationEventHandler, NotificationEventHandler) method:
1. returned object can be used instead of
Root
2. new handlers will receive CFGSERVER event which will allow to implement "OnConnect"/"OnDisconnect" handlers
3. automaticaly removes all subscriptions which were initialized for previous server.