Example #1
0
 private void SendUdpBroadcast(UdpMessage message)
 {
     Service1.WriteAppLogInfo("Service1->> " + UdpMessage.Convert(message), message.Type);
     if (_broadcast)
     {
         Debug.WriteLine(message.Type.ToString() + ": " + message.Info);
         UdpBroadcast1.Send(message);
     }
 }
Example #2
0
        private void UdpBroadcast1_MessageRcvd(UdpMessage message)
        {
            if (!this.IsDisposed)//Ignore UDP message if form is disposed
            {
                //Debug.WriteLine("Udp Form1<<- " + UdpMessage.Convert(message));
                WriteAppLogInfo("Udp Form1<<- " + UdpMessage.Convert(message), message.Type);
                if (message.Type < 100)//This is for everyone
                {
                    #region Decode message and notify application
                    switch (message.Type)
                    {
                    /*case 0://Control
                     *  break;
                     * case 1://Service Started
                     *  break;
                     * case 2://Service Stopped
                     *  break;
                     */
                    case 10:    //Init No Systems
                        if (!this.IsDisposed)
                        {
                            Invoke(new EmptyDelegate(NotifyNoSystems));
                        }
                        break;

                    case 11:    //Init Open System
                        if (!this.IsDisposed)
                        {
                            Invoke(new ObjectDelegate(OpenSystem), new object[1] {
                                message
                            });
                        }
                        break;
                    }
                    #endregion
                }
                else//Dispatch based on message.Recipient == Name
                {
                    if (!this.IsDisposed)
                    {
                        Invoke(new ObjectDelegate(DispatchSysMessage), new object[1] {
                            message
                        });
                    }
                }
            }
        }
Example #3
0
 private void SendUdpBroadcast(UdpMessage message)
 {
     UdpBroadcast1.Send(message);
     WriteAppLogInfo("Udp Form1->> " + UdpMessage.Convert(message), message.Type);
 }
Example #4
0
        private void UdpBroadcast1_MessageRcvd(UdpMessage message)
        {
            Service1.WriteAppLogInfo("Service1<<- " + UdpMessage.Convert(message), message.Type);
            //Decode message
            switch (message.Type)
            {
            case 200:    //App Started
                if (_clientCnt < 0)
                {
                    _clientCnt = 0;
                }                                          //Just in case we got negative
                _clientCnt++;
                _broadcast = true;
                if (SystemsCollection.Count == 0)
                {
                    SendUdpBroadcast(new UdpMessage(10, DateTime.Now, "control", "No Systems"));
                }
                else
                {
                    foreach (ManageSystem sys in SystemsCollection)
                    {
                        SendSysOpenMessage(sys);
                    }
                }
                break;

            case 201:    //App Closed
                _clientCnt--;
                if (_clientCnt < 1)
                {
                    _clientCnt = 0;
                }                                          //Just in case we got negative
                if (_clientCnt == 0)
                {
                    _broadcast = false;
                }
                break;

            case 210:               //System Added
                FillSysDefsTable(); //This will pick up any changes in the database
                CreateNewSystem(message.Recipient);
                break;

            case 211:    //System Deleted
                RemoveSystem(message.Recipient);
                break;

            case 212:    //System Modified
                FillSysDefsTable();
                ModifySystem(message.Recipient, message.Info, true);
                break;

            case 300:                                                      //Try Startup
                ModifySystem(message.Recipient, message.Recipient, false); //This will retry the startup
                break;

            case 301:    //Send a TCPIP Command
                SendTcpipCommand(message.Recipient, message.Info);
                break;

            case 302:    //Send a TCPIP Command
                SendForTrace(message.Recipient, message.Info);
                break;

            case 400:    //Change Sql Server setting
                ChangeSqlSetting(message.Info);
                break;
            }
        }