Exemple #1
0
        public void Register(string sMachineInfo, NebulaModuleInfo[] hModules)
        {
            OperationContext       hCurrent = OperationContext.Current;
            INebulaMasterServiceCB hCb      = hCurrent.GetCallbackChannel <INebulaMasterServiceCB>();

            T hClient;

            if (m_hClients.TryGetValue(hCb, out hClient))
            {
                hClient.Modules.AddRange(hModules);
            }
            else
            {
                (hCb as ICommunicationObject).Faulted += OnFaulted;

                RemoteEndpointMessageProperty hRemoteProperty = (OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty);

                hClient          = new T();
                hClient.Id       = Interlocked.Increment(ref m_iCounter);
                hClient.Callback = hCb;
                hClient.Machine  = sMachineInfo;
                hClient.Address  = new IPEndPoint(IPAddress.Parse(hRemoteProperty.Address), hRemoteProperty.Port);
                hClient.Modules  = new List <NebulaModuleInfo>(hModules);

                m_hClients.TryAdd(hCb, hClient);
                ClientConnected?.Invoke(hClient);
            }
        }
Exemple #2
0
        //TODO: gestire la sessione, se arriva prima questa chiamata di register (plausibile per moduli mal implementati)
        public void ModuleData(Guid vId, string sData)
        {
            OperationContext       hCurrent = OperationContext.Current;
            INebulaMasterServiceCB hCb      = hCurrent.GetCallbackChannel <INebulaMasterServiceCB>();

            T hClient;

            m_hClients.TryGetValue(hCb, out hClient);

            NebulaModuleInfo hModule = hClient.Modules.Where(m => m.Guid == vId).First();

            ModuleDataReceived?.Invoke(hClient, vId, sData);
        }
Exemple #3
0
        private void OnFaulted(object sender, EventArgs e)
        {
            INebulaMasterServiceCB hClient = sender as INebulaMasterServiceCB;

            T hRemoved;

            if (m_hClients.TryRemove(hClient, out hRemoved))
            {
                ClientFaulted?.Invoke(hRemoved);
            }
            else
            {
                //TODO: accrocco temporaneo, prevedere sistema per la notifica dei  dei client mancanti
                throw new NotImplementedException();
            }
        }