示例#1
0
        /// Client Connected. Add new Client to list.
        void hNur_ClientConnected(object sender, NurApi.ClientInfoEventArgs e)
        {
            string     clientTitle = "No title";
            ClientInfo ci          = new ClientInfo();

            try
            {
                clientTitle = e.cApi.Title; //Get Title of client device
            }
            catch (Exception ex)
            {
                ci.lastErr = ex.Message; //Propably Title property is not support by client.
            }

            AddLog("Client:" + clientTitle + " " + e.data.ip + " Connected!");

            //Save information to ClientInfo struct and save it to the simple list
            ci.cApi            = e.cApi;
            ci.title           = clientTitle;
            ci.ip              = e.data.ip;
            ci.StreamerRunning = false;
            ci.tagsFound       = -1;

            clientList.Add(ci); //Add it
            UpdateClientList(); //Show to user
        }
示例#2
0
        // Client Disconnected.
        // At this point client is not useful to us anymore.
        // We need to remove it from our ClientList and call NurApi.Dispose function for freeing resources.
        void hNur_ClientDisonnected(object sender, NurApi.ClientInfoEventArgs e)
        {
            ClientInfo ci = new ClientInfo();

            //Search correct client from list
            for (int i = 0; i < clientList.Count; i++)
            {
                ci = clientList[i];
                if (ci.cApi.GetHandle() == e.cApi.GetHandle()) //Compare handle pointers for making sure we talking about correct client..
                {
                    //Found.
                    AddLog("Disconnect:" + ci.ip);
                    if (ci.StreamerRunning)
                    {
                        //if StramerThread is running we need to drive it down.
                        ci.invStreamer.Stop();
                    }
                    clientList.RemoveAt(i); //remove it from our List.
                    e.cApi.Dispose();       //No use anymore. Free resources
                    UpdateClientList();     //View client list to user (one client less than previous view)
                    break;                  //We're done.
                }
            }
        }