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
C#
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):
C#
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.

Definition

Namespace: TCX.Configuration
Assembly: 3cxpscomcpp2 (in 3cxpscomcpp2.dll) Version: 20.0.1
C#
public static PhoneSystem Reset(
	string ApplicationName,
	string CfgServerHost,
	int CfgServerPort,
	string CfgServerUser,
	string CfgServerPassword,
	NotificationEventHandler inserted = null,
	NotificationEventHandler updated = null,
	NotificationEventHandler deleted = null
)

Parameters

ApplicationName  String
ApplicationName
CfgServerHost  String
CfgServerHost
CfgServerPort  Int32
CfgServerPort
CfgServerUser  String
CfgServerUser
CfgServerPassword  String
CfgServerPassword
inserted  NotificationEventHandler  (Optional)
Insertedhandler for Inserted. If null, the updated will be set as the handler
updated  NotificationEventHandler  (Optional)
Updatedhandler for Updated
deleted  NotificationEventHandler  (Optional)
Deletedhandler for Deleted

Return Value

PhoneSystem
returns the object which will be returned by Root property

See Also