Exemplo n.º 1
0
        //
        // Write a object instance to data output stream
        //
        public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut)
        {
            DiscoveryEvent info = (DiscoveryEvent)o;

            base.LooseMarshal(wireFormat, o, dataOut);
            LooseMarshalString(info.ServiceName, dataOut);
            LooseMarshalString(info.BrokerName, dataOut);
        }
Exemplo n.º 2
0
        //
        // Un-marshal an object instance from the data input stream
        //
        public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
        {
            base.LooseUnmarshal(wireFormat, o, dataIn);

            DiscoveryEvent info = (DiscoveryEvent)o;

            info.ServiceName = LooseUnmarshalString(dataIn);
            info.BrokerName  = LooseUnmarshalString(dataIn);
        }
Exemplo n.º 3
0
        //
        // Write a object instance to data output stream
        //
        public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs)
        {
            base.TightMarshal2(wireFormat, o, dataOut, bs);

            DiscoveryEvent info = (DiscoveryEvent)o;

            TightMarshalString2(info.ServiceName, dataOut, bs);
            TightMarshalString2(info.BrokerName, dataOut, bs);
        }
Exemplo n.º 4
0
        //
        // Un-marshal an object instance from the data input stream
        //
        public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
        {
            base.TightUnmarshal(wireFormat, o, dataIn, bs);

            DiscoveryEvent info = (DiscoveryEvent)o;

            info.ServiceName = TightUnmarshalString(dataIn, bs);
            info.BrokerName  = TightUnmarshalString(dataIn, bs);
        }
Exemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        DiscoveryEvent discoveryEvent = collision.gameObject.GetComponent <DiscoveryEvent>();

        if (!discoveryEvent)
        {
            Debug.LogWarning("no discovery event is found in " + collision.gameObject.name);
            return;
        }

        if (collision.gameObject.CompareTag("Knowledge"))
        {
            if (!discoveryEvent.GetHasOpened())
            {
                Time.timeScale = 0;
                discoveryEvent.SetHasOpened(true);
                discoveryEvent.ActivateThePanel();
                _knowledge++;
                knowledgeText.text = "Knowledge: " + _knowledge.ToString();
                m_eventLog.LogEvent(collision.gameObject.name, discoveryEvent.GetNarrative());
            }
        }
        if (collision.gameObject.CompareTag("Mood"))
        {
            if (!discoveryEvent.GetHasOpened())
            {
                Time.timeScale = 0;
                discoveryEvent.SetHasOpened(true);
                discoveryEvent.ActivateThePanel();
                _mood           += 0.5f;
                moodSlider.value = _mood / _fullMood;
                m_eventLog.LogEvent(collision.gameObject.name, discoveryEvent.GetNarrative());
            }
        }
        if (collision.gameObject.CompareTag("DoorInfo"))
        {
            if (!discoveryEvent.GetHasOpened())
            {
                Time.timeScale = 0;
                discoveryEvent.SetHasOpened(true);
                discoveryEvent.ActivateThePanel();
                m_eventLog.LogEvent(collision.gameObject.name, discoveryEvent.GetNarrative());
            }
        }

        if (collision.gameObject.CompareTag("Key"))
        {
            Time.timeScale = 0;
            SpriteRenderer[] spriteRenderers = door.GetComponentsInChildren <SpriteRenderer>();
            spriteRenderers[0].sprite = doorOpenMid;
            spriteRenderers[1].sprite = doorOpenTop;
            discoveryEvent.SetHasOpened(true);
            discoveryEvent.ActivateThePanel();
            m_eventLog.LogEvent(collision.gameObject.name, discoveryEvent.GetNarrative());
        }
    }
 protected void FireServiceAddEvent(DiscoveryEvent data)
 {
     if (serviceAddHandler != null && started.Value)
     {
         // Have the listener process the event async so that
         // he does not block this thread since we are doing time sensitive
         // processing of events.
         executor.QueueUserWorkItem(ServiceAddCallback, data);
     }
 }
        public void ServiceFailed(DiscoveryEvent failedEvent)
        {
            DiscoveredServiceData data = null;

            discoveredServices.TryGetValue(failedEvent.ServiceName, out data);
            if (data != null && MarkFailed(data))
            {
                FireServiceRemoveEvent(data);
            }
        }
Exemplo n.º 8
0
        //
        // Write the booleans that this object uses to a BooleanStream
        //
        public override int TightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs)
        {
            DiscoveryEvent info = (DiscoveryEvent)o;

            int rc = base.TightMarshal1(wireFormat, o, bs);

            rc += TightMarshalString1(info.ServiceName, bs);
            rc += TightMarshalString1(info.BrokerName, bs);

            return(rc + 0);
        }
Exemplo n.º 9
0
 private void OnDeviceStatusUpdate(DiscoveredDevice dv, DiscoveryType type, DiscoveryEvent evt)
 {
     if (DeviceStatusUpdate != null)
     {
         DeviceStatusUpdate(this, new DiscoveredEventArgs()
         {
             Device          = dv,
             Event           = evt,
             DiscoveredUsing = type
         });
     }
 }
Exemplo n.º 10
0
        private void OnServiceRemoved(DiscoveryEvent removeEvent)
        {
            Uri toRemove = null;

            lock (syncRoot)
            {
                serviceURIs.TryGetValue(removeEvent.ServiceName, out toRemove);
            }
            if (toRemove != null)
            {
                next.Remove(false, new Uri[] { toRemove });
            }
        }
Exemplo n.º 11
0
        //SSDP process
        private void ProcessSSDPMessage(string message)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            DiscoveredDevice ssdpDevice;
            DiscoveryType    foundwith   = DiscoveryType.MSEARCH;
            DiscoveryEvent   discovEvent = DiscoveryEvent.DeviceFound;

            if (message.Contains("M-SEARCH"))
            {
                return;
            }
            else if (message.Contains("NOTIFY"))
            {
                foundwith = DiscoveryType.NOTIFY;

                if (message.Contains("DiscoveryService:alive"))
                {
                    discovEvent = DiscoveryEvent.DeviceFound;
                }
                else if (message.Contains("DiscoveryService:byebye"))
                {
                    discovEvent = DiscoveryEvent.DeviceRemoved;
                }
            }
            else if (message.Contains("HTTP/1.1 200 OK"))
            {
                foundwith = DiscoveryType.MSEARCH;
            }

            if (DiscoveredDevice.TryParse(message, out ssdpDevice))
            {
                try
                {
                    ValidateDiscoveredDevice(ssdpDevice, foundwith);
                    var ok = FilterDevice(ssdpDevice, foundwith);
                    if (ok)
                    {
                        OnDeviceStatusUpdate(ssdpDevice, foundwith, discovEvent);
                    }
                }
                catch (Exception) { }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AffinityFunctionContext"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal AffinityFunctionContext(IBinaryRawReader reader)
        {
            var cnt = reader.ReadInt();

            if (cnt > 0)
            {
                _previousAssignment = new List <List <IClusterNode> >(cnt);

                for (var i = 0; i < cnt; i++)
                {
                    _previousAssignment.Add(IgniteUtils.ReadNodes(reader));
                }
            }

            _backups = reader.ReadInt();
            _currentTopologySnapshot = IgniteUtils.ReadNodes(reader);
            _currentTopologyVersion  = new AffinityTopologyVersion(reader.ReadLong(), reader.ReadInt());
            _discoveryEvent          = EventReader.Read <DiscoveryEvent>(reader);
        }
Exemplo n.º 13
0
 public void OnDeviceDiscovered(string theIPAddress, Device theDeviceDesription)
 {
     DiscoveryEvent.Fire(new Payload
                         (
                             DiscoveryEvent.Id,
                             new []
     {
         new PayloadSubject(DiscoveryEvent.Subjects[0], theIPAddress),
         new PayloadSubject(DiscoveryEvent.Subjects[1], string.IsNullOrEmpty(theDeviceDesription.DeviceType)? string.Empty: theDeviceDesription.DeviceType),
         new PayloadSubject(DiscoveryEvent.Subjects[2], string.IsNullOrEmpty(theDeviceDesription.FriendlyName)? string.Empty: theDeviceDesription.FriendlyName),
         new PayloadSubject(DiscoveryEvent.Subjects[3], string.IsNullOrEmpty(theDeviceDesription.Manufacturer)? string.Empty: theDeviceDesription.Manufacturer),
         new PayloadSubject(DiscoveryEvent.Subjects[4], string.IsNullOrEmpty(theDeviceDesription.ManufacturerURL)? string.Empty: theDeviceDesription.ManufacturerURL),
         new PayloadSubject(DiscoveryEvent.Subjects[5], string.IsNullOrEmpty(theDeviceDesription.ModelDescription)? string.Empty: theDeviceDesription.ModelDescription),
         new PayloadSubject(DiscoveryEvent.Subjects[6], string.IsNullOrEmpty(theDeviceDesription.ModelName)? string.Empty: theDeviceDesription.ModelName),
         new PayloadSubject(DiscoveryEvent.Subjects[7], string.IsNullOrEmpty(theDeviceDesription.ModelNumber)? string.Empty: theDeviceDesription.ModelNumber),
         new PayloadSubject(DiscoveryEvent.Subjects[8], string.IsNullOrEmpty(theDeviceDesription.UDN)? string.Empty: theDeviceDesription.UDN),
         new PayloadSubject(DiscoveryEvent.Subjects[9], string.IsNullOrEmpty(theDeviceDesription.SerialNumber)? string.Empty: theDeviceDesription.SerialNumber),
         new PayloadSubject(DiscoveryEvent.Subjects[10], string.IsNullOrEmpty(theDeviceDesription.PresentationURL)? string.Empty: theDeviceDesription.PresentationURL)
     }
                         ));
 }
Exemplo n.º 14
0
        private void OnServiceAdded(DiscoveryEvent addEvent)
        {
            String url = addEvent.ServiceName;

            if (url != null)
            {
                try
                {
                    Uri uri = new Uri(url);
                    Tracer.InfoFormat("Adding new broker connection URL: {0}", uri);
                    uri = ApplyParameters(uri, properties, DISCOVERED_OPTION_PREFIX);

                    lock (syncRoot)
                    {
                        serviceURIs[addEvent.ServiceName] = uri;
                    }
                    next.Add(false, new Uri[] { uri });
                }
                catch (Exception e)
                {
                    Tracer.WarnFormat("Could not connect to remote URI: {0} due to bad URI syntax: {1}", url, e.Message);
                }
            }
        }
        private void ServiceAddCallback(object data)
        {
            DiscoveryEvent serviceData = data as DiscoveryEvent;

            this.serviceAddHandler(serviceData);
        }