Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 public TopicUpdatedEvent(IAcSession acSession, TopicBase source)
     : base(acSession, source)
 {
 }
Beispiel #2
0
 public TopicRemovedEvent(IAcSession acSession, TopicBase source) : base(acSession, source)
 {
 }
Beispiel #3
0
        }//ProcessFillHubEvent().

        //
        //
        //
        //
        //
        // *********************************************************
        // ****             Process Socket Event                ****
        // *********************************************************
        /// <summary>
        /// This is an event received from the socket. (Its usually of type "MessageReceived" from socket,
        /// which is from BreTalker (on the other end of the socket connection), which needs to be decoded.
        /// </summary>
        private void ProcessSocketEvent(SocketEventArgs eventArgs)
        {
            // TODO: it'd be convenient if the SocketEventArgs told us exactly which SocketManager/Conversation sent the event.
            // In cases there are multiple socket clients.
            Log.NewEntry(LogLevel.Major, "SocketEvent [{0}] {1}", eventArgs.EventType.ToString(), eventArgs.Message);
            if (eventArgs.EventType == SocketEventType.MessageReceived)
            {
                // Analyze message from
                MessageType messageType;
                int         topicID;
                string      currentValue;
                string[]    args;
                Topic       topic;
                if (TopicBase.TryReadSerialString(eventArgs.Message, out messageType, out topicID, out currentValue, out args))
                {
                    switch (messageType)
                    {
                    case MessageType.TopicArgs:
                        if (m_Topics.TryGetValue(topicID, out topic))
                        {       // This is an resending of a topic we already know.
                                // TODO: update this? dunno.
                            Log.NewEntry(LogLevel.Major, "Received TopicArgs for an old topic {0}, Message = {1}.  Will remove, and replace with new topic.", topic.ToString(), eventArgs.Message);
                            if (TryRemoveTopic(topicID))
                            {
                                Log.NewEntry(LogLevel.Minor, "Removed previous topicID = {0}.", topicID);
                            }
                            else
                            {
                                Log.NewEntry(LogLevel.Minor, "Failed to remove topicID = {0}.", topicID);
                            }
                            //if (!currentValue.Equals(topic.PeekAtValue())) //topic.SetValue(currentValue);               // at least update its current value.
                            //    topic.IsChangedSinceLastRead = true;            // tell excel that this is the current value.
                        }
                        if (!m_Topics.TryGetValue(topicID, out topic))
                        {       // New topic received, try to create a new specific topic.
                            if (Topic.TryCreate(topicID, args, currentValue, out topic))
                            {
                                m_Topics.Add(topicID, topic);                                   // add new topic to our lists.
                                CategorizeTopic(topic);
                            }
                            else
                            {       // Failed to create a new topic!
                                Log.NewEntry(LogLevel.Major, "Failed to create new topic for {0}.", eventArgs.Message);
                            }
                        }
                        break;

                    case MessageType.Current:
                        if (m_Topics.TryGetValue(topicID, out topic))
                        {
                            Log.NewEntry(LogLevel.Minor, "Received Current value response for topic {0}, Msg = {1}.", topic.ToString(), eventArgs.Message);
                            topic.IsChangedSinceLastRead = true;            // tell the user that THIS is the correct value.
                            // topic.SetValue(currentValue);
                            // Inform subscribers that this value is now up to date.
                        }
                        else
                        {
                            Log.NewEntry(LogLevel.Minor, "Topic current message received.  Failed to find topicID = {0}.", topicID);
                        }
                        break;

                    case MessageType.TopicRemoved:
                        if (TryRemoveTopic(topicID))
                        {
                            Log.NewEntry(LogLevel.Minor, "Topic removed msg received. TopicID = {0} removed.  Msg = {1}", topicID, eventArgs.Message);
                        }
                        else
                        {
                            Log.NewEntry(LogLevel.Minor, "Topic removed msg received. Failed to find topicID = {0}.  Msg = {1}", topicID, eventArgs.Message);
                        }
                        break;

                    default:
                        break;
                    } //switch
                }     // if deserialized new topic.
                else
                {
                    Log.NewEntry(LogLevel.Warning, "Failed to deserialize the NEW topic from message {0}", eventArgs.Message);
                }
            }
            else if (eventArgs.EventType == SocketEventType.Disconnected)
            {
                m_IsConnectedToClient = false;
                OnStateChanged();
            }
            else if (eventArgs.EventType == SocketEventType.Connected)
            {
                m_IsConnectedToClient          = true;
                m_AmbreXLReconnectFailureCount = 0;                     // this is the flag for we are NOT trying to reconnect.
                OnStateChanged();
            }
            else if (eventArgs.EventType == SocketEventType.InternalMessage)
            {
            }
            else
            {
                Log.NewEntry(LogLevel.Major, "[{0}] unhandled socket event {1}", eventArgs.EventType.ToString(), eventArgs.Message);
            }
        }// ProcessSocketEvent()
Beispiel #4
0
 /// <summary>
 /// Build a minimal row from a class (key fields only)
 /// </summary>
 public static void BuildMinimalRow(ref DataRow row, Topic entity)
 {
     TopicBase.BuildMinimalRow(ref row, entity);
 }
 /// <summary>
 /// 
 /// </summary>
 public TopicUpdatedEvent(IAcSession acSession, TopicBase source)
     : base(acSession, source)
 {
 }
 public TopicRemovedEvent(IAcSession acSession, TopicBase source)
     : base(acSession, source)
 {
 }