#region Start DiscoTech
private void StartDiscoTech(IPAddress
serverIP)
{
//Enabling message storing option to get feedback
upon reconnection
DISCOFramework.Instance.WithMessageStoring = true;
//Initialize Disco with the server IP and port number.
DISCOFramework.Instance.Initialization(serverIP,
8010);
// Subscribe to command received event.
DiscoFramework.DISCOFramework.Instance.CommandReceived+=new CommandReceivedEventHandler(Instance_CommandReceived);
//Subscribe to the event "ConnectingSuccessed" to
see whether the connection to the server is established or not.
DISCOFramework.Instance.ConnectingSuccessed += new ConnectingSuccessedEventHandler(Instance_ConnectingSuccessed);
// Subscribe to the event "ConnectingFailed" to
see whether the connection attempt to the server fail or not.
DISCOFramework.Instance.ConnectingFailed+=new ConnectingFailedEventHandler(Instance_ConnectingFailed);
//To receive events from the DiscoTech toolkit at normal
connected situation, you need to add the Daefault
replayer.
DISCOFramework.Instance.ReplayEvents += new ReplayEventHandler(OnReplayEvents);
}
#endregion
#region DiscoTech Handlers
private
void Instance_ConnectingSuccessed(object sender, EventArgs
e)
{
DISCOFramework.Instance.SendCommand(new
Command(DiscoFramework.CommandType.IsNameExists,
DISCOFramework.Instance.LocalClientIP,
DISCOFramework.Instance.LocalClientName));
}
private void Instance_CommandReceived(object sender,
DiscoFramework.CommandEventArgs e)
{
}
private void Instance_ConnectingFailed (object sender, EventArgs
e)
{
MessageBox.Show("Server
is not connected: please try again");
}
System.Threading.Semaphore
semaphor = new System.Threading.Semaphore(1, 1);
public
void OnReplayEvents(object
sender, DiscoFramework.ReplayEventArgs re)
{
semaphor.WaitOne();
try
{
// you need to write code here to interpret
the receive event according to the
//application requirements.
semaphor.Release();
}
catch (Exception
ex)
{
semaphor.Release();
}
}
#endregion