コード例 #1
0
        private void SendEventDetailsToSubscriber(Communications.EventData requestedEvnt, EndPoint subscriberEndPoint)
        {
            try
            {
                Object objData      = m_Globals.m_communications.GetSerializeEventData(requestedEvnt);
                String EOMDelimiter = m_Globals.m_communications.EOMDelimiter;

                byte[] byteData = System.Text.Encoding.UTF8.GetBytes(objData.ToString() + EOMDelimiter);
                for (int i = 0; i < m_clientCount; i++)
                {
                    if (m_workerSocket[i].RemoteEndPoint == subscriberEndPoint)
                    {
                        if (m_workerSocket[i] != null)
                        {
                            if (m_workerSocket[i].Connected)
                            {
                                m_workerSocket[i].Send(byteData);
                            }
                        }
                    }
                }
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
コード例 #2
0
        // Begin processing and reacting to the message that was sent.
        private void ProcessCommMessage(string commMessage, EndPoint endPoint)
        {
            Communications.EventData receivedEventData = m_Globals.m_communications.DeserializeReceivedEventData(commMessage);

            if (receivedEventData.Details == null || receivedEventData.Details == "")
            {
                return;
            }
            if (receivedEventData.Name.Contains("client"))
            {   // Subscribers send NO details.  We assume this is part of the design spec.
                String appendedMessage = Get_richTextBoxFromSubscribers() + "\n\n " + ReceivedMsg.GetText();
                Set_richTextBoxFromSubscribers(appendedMessage);

                AnalyseRequestFromSubscriber(endPoint, receivedEventData);
            }
            else
            {   // Publishers ALWAYS send details.  We assume this is part of the design spec.
                String appendedMessage = Get_richTextBoxFromPublishers() + "\n\n " + ReceivedMsg.GetText();
                Set_richTextBoxFromPublishers(appendedMessage);

                AnalyseRequestFromPublisher(endPoint, receivedEventData);
            }

            // Empty the textbox to read correctly the next request, to not be confused by "ENDOFMESSAGE" which
            // will appear in every request.
            ReceivedMsg.SetText("");
        }
コード例 #3
0
 private void SendMediaKillCommand()
 {
     if (isLastBroadcastEventDataSet)
     {
         Communications.EventData lastEventData = m_lastPlayList;
         lastEventData.Name    = "server_media_kill";
         lastEventData.Details = "";
         GoCallAllSubscribers(lastEventData);
     }
 }
コード例 #4
0
 private void GoCallAllSubscribers(Communications.EventData receivedEventData)
 {
     if (isLastBroadcastEventDataSet)
     {
         foreach (IPAddress address in data.subscribersIPEndPoints.Keys)
         {
             SendEventDetailsToSubscriber(receivedEventData, data.subscribersIPEndPoints[address]);
         }
     }
 }
コード例 #5
0
        private void SendPlayCommand()
        {
            if (isLastBroadcastEventDataSet)
            {
                Communications.EventData playLastEventsPlayList = m_lastPlayList;
                playLastEventsPlayList.Name    = "server_play";
                playLastEventsPlayList.Details = "";
                m_clientsNotDonePlayList       = data.subscribersIPEndPoints.Count;
                Set_label_clientsNotDonePlayList(m_clientsNotDonePlayList.ToString());
                GoCallAllSubscribers(playLastEventsPlayList);

                //MessageBox.Show("Sending play command.");
            }
        }
コード例 #6
0
        // Begin processing and reacting to the message that was sent.
        private void ProcessCommMessage(string commMessage)
        {
            Communications.EventData receivedEventData = m_Globals.m_communications.DeserializeReceivedEventData(commMessage);

            logFile.WriteToLog("-I-  received message: " + receivedEventData.ToString());

            if (m_Globals.isTempPathSet == false)
            {
                String tempPath = m_Globals.Get_tempPath();
                if (m_Globals.m_library.TestFilePathExistance(tempPath))
                {
                    m_Globals.isTempPathSet = true;
                }
            }

            if (m_Globals.isTempPathSet)
            {
                CheckForIllegalCrossThreadCalls = false;
                if (receivedEventData.Name.Contains("playlist"))
                {
                    label_PlayListCopyIndicator.BackColor = System.Drawing.Color.Red;
                    label_PlayListCopyIndicator.Text      = "Copying Files";
                }

                String tempPath = m_Globals.Get_tempPath();
                CallParserProcessEvents(receivedEventData.Name, receivedEventData.Details);
                if (receivedEventData.Name.Contains("playlist"))
                {
                    label_PlayListCopyIndicator.BackColor = System.Drawing.Color.LightGreen;
                    label_PlayListCopyIndicator.Text      = "Done Copying";
                }
                CheckForIllegalCrossThreadCalls = true;
            }
            else
            {
                MessageBox.Show("Please use the Tools menu to set a Temp Directory Path.");
            }
        }
コード例 #7
0
        private void AnalyseRequestFromSubscriber(EndPoint subscriberEndPoint, Communications.EventData eventData)
        {
            bool ignorePriorEntry = false;

            if (eventData.Name.Contains("connect"))
            {
                ignorePriorEntry = true;
            }
            else if (eventData.Name.Contains("playlist_done"))
            {
                m_clientsNotDonePlayList--;
                Set_label_clientsNotDonePlayList(m_clientsNotDonePlayList.ToString());
                EvaluateRepeat();
            }
            else if (eventData.Name.Contains("file_copy_done"))
            {
                m_clientsNotDoneFileCopying--;
                Set_label_clientsNotDoneFileCopying(m_clientsNotDoneFileCopying.ToString());
            }
            data.AddSubscriber((IPEndPoint)subscriberEndPoint, ignorePriorEntry);

            // Look for the requested Event.
            foreach (Publisher publisher in data.Publishers)
            {
                publisher.Events.Reverse();
                foreach (Communications.EventData evnt in publisher.Events)
                {
                    if (evnt.Name == eventData.Name)
                    {   // If the requested event already exist, then send it to the appropriate subscriber.
                        SendEventDetailsToSubscriber(evnt, subscriberEndPoint);
                        return;
                    }
                }
            }
            // If execution reaches here, the requested event was not found.
        }
コード例 #8
0
 public Publisher(IPEndPoint ipEndPoint, Communications.EventData evnt)
 {
     IpEndPoint = ipEndPoint;
     Events.Add(evnt);
 }
コード例 #9
0
        private void AnalyseRequestFromPublisher(EndPoint endPoint, Communications.EventData receivedEventData)
        {
            // Register the Event in the appropriate Publisher's list.
            // If this Publisher already exists, then just add this Event to its list.
            Boolean eventAdded = false;

            // How to determine if an anonymous publisher would already exist in the publisher list.
            //if (data.Publishers.Contains(new Publisher((IPEndPoint)endPoint, receivedEventData)))
            //{
            //    String found = "we found it";
            //}

            foreach (Publisher publisher in data.Publishers)
            {
                if (publisher.IpEndPoint == (IPEndPoint)endPoint)
                {
                    publisher.Events.Clear();
                    publisher.Events.Add(receivedEventData);
                    eventAdded = true;

                    if (receivedEventData.Name.Contains("playlist"))
                    {
                        m_lastPlayList = receivedEventData;
                        isLastBroadcastEventDataSet = true;
                        m_clientsNotDoneFileCopying = data.subscribersIPEndPoints.Count;
                        Set_label_clientsNotDoneFileCopying(m_clientsNotDoneFileCopying.ToString());
                        GoCallAllSubscribers(receivedEventData);
                    }
                }
            }

            // If the Publisher did NOT exist.
            if (!eventAdded)
            {
                data.Publishers.Add(new Publisher((IPEndPoint)endPoint, receivedEventData));
            }


            bool ignorePriorEntry = false;

            if (receivedEventData.Name.Contains("connect"))
            {
                ignorePriorEntry = true;
                data.AddPublisher((IPEndPoint)endPoint, ignorePriorEntry);
                //isLastBroadcastEventDataSet = false;
            }

            if (receivedEventData.Name.Contains("playlist"))
            {
                data.AddPublisher((IPEndPoint)endPoint, ignorePriorEntry);
                m_lastPlayList = receivedEventData;
                isLastBroadcastEventDataSet = true;

                if (isAutoPlayCmd)
                {
                    m_clientsNotDoneFileCopying = data.subscribersIPEndPoints.Count;
                    Set_label_clientsNotDoneFileCopying(m_clientsNotDoneFileCopying.ToString());
                    GoCallAllSubscribers(receivedEventData);
                    SendPlayCommand();
                }
            }
        }