Exemplo n.º 1
0
 protected virtual void OnReportInfo(ServerProtocols.ReportInfo e)
 {
     if (this.ReportInfo != null)
     {
         this.ReportInfo(this, e);
     }
 }
Exemplo n.º 2
0
        public void Handle(string data)
        {
            try
            {
                string[] srg = data.Split('\\');
                if (srg.Length == 0)
                {
                    return;
                }

                if (srg[0] == TerminalConnectionSettings.Sender.CIPCTerminal.ToString())
                {
                    if (srg[1] == TerminalCommand.Connect.ToString())
                    {
                        this.OnConnect(new TerminalProtocols.Connect(int.Parse(srg[2]), int.Parse(srg[3])));
                    }
                    else if (srg[1] == TerminalCommand.DisConnect.ToString())
                    {
                        this.OnDisConnect(new TerminalProtocols.DisConnect(int.Parse(srg[2]), int.Parse(srg[3])));
                    }
                    else if (srg[1] == TerminalCommand.Close.ToString())
                    {
                        this.OnClose(new TerminalProtocols.Close());
                    }
                    else if (srg[1] == TerminalCommand.Restart.ToString())
                    {
                        this.OnRestart(new TerminalProtocols.Restart());
                    }
                    else if (srg[1] == TerminalCommand.DemandInfo.ToString())
                    {
                        this.OnDemmandInfo(new TerminalProtocols.DemmandInfo());
                    }
                    else if (srg[1] == TerminalCommand.Undo.ToString())
                    {
                        this.OnUndo(new TerminalProtocols.Undo());
                    }
                    else if (srg[1] == TerminalCommand.Redo.ToString())
                    {
                        this.OnRedo(new TerminalProtocols.Redo());
                    }
                    else if (srg[1] == TerminalCommand.Emergence.ToString())
                    {
                        this.OnEmergenceT(new TerminalProtocols.Emergence());
                    }
                    else if (srg[1] == TerminalCommand.AllDisConnect.ToString())
                    {
                        this.OnAllDisConnect(new TerminalProtocols.AllDisConnect());
                    }
                    else if (srg[1] == TerminalCommand.LoadConnectionFast.ToString())
                    {
                        this.OnLoadConnectionFast(new TerminalProtocols.LoadConnectionFast());
                    }
                    else if (srg[1] == TerminalCommand.SaveConnectionFast.ToString())
                    {
                        this.OnSaveConnectionFast(new TerminalProtocols.SaveConnectionFast());
                    }
                    else if (srg[1] == TerminalCommand.TurnOnSyncConnect.ToString())
                    {
                        this.OnTurnOnSyncConnect(new TerminalProtocols.TurnOnSyncConnect());
                    }
                    else if (srg[1] == TerminalCommand.TurnOffSyncConnect.ToString())
                    {
                        this.OnTurnOffSyncConnect(new TerminalProtocols.TurnOffSyncConnect());
                    }
                    else
                    {
                        return;
                    }
                }
                else if (srg[0] == TerminalConnectionSettings.Sender.CIPCSever.ToString())
                {
                    if (srg[1] == TerminalConnectionSettings.ServerCommand.ReportInfo.ToString())
                    {
                        int index = 2;
                        List <ServerProtocols.ReportInfo.CIPCInfo.Client>     ClientList     = new List <ServerProtocols.ReportInfo.CIPCInfo.Client>();
                        List <ServerProtocols.ReportInfo.CIPCInfo.Connection> ConnectionList = new List <ServerProtocols.ReportInfo.CIPCInfo.Connection>();

                        int clientlength = int.Parse(srg[index]);
                        index++;

                        for (int i = 0; i < clientlength; i++)
                        {
                            int myport = int.Parse(srg[index]);
                            index++;
                            string name = srg[index];
                            index++;
                            int remoteport = int.Parse(srg[index]);
                            index++;
                            string remoteIP = srg[index];
                            index++;
                            int FPS = int.Parse(srg[index]);
                            index++;
                            ServerProtocols.ReportInfo.CIPCInfo.Client.Mode mode;
                            if (srg[index] == ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Sender.ToString())
                            {
                                mode = ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Sender;
                                index++;
                            }
                            else if (srg[index] == ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Receiver.ToString())
                            {
                                mode = ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Receiver;
                                index++;
                            }
                            else
                            {
                                mode = ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Default;
                                index++;
                            }
                            ClientList.Add(new ServerProtocols.ReportInfo.CIPCInfo.Client(myport, name, remoteport, remoteIP, FPS, mode));
                        }

                        int connectionlength = int.Parse(srg[index]);
                        index++;

                        for (int i = 0; i < connectionlength; i++)
                        {
                            int senderport = int.Parse(srg[index]);
                            index++;
                            int receiverport = int.Parse(srg[index]);
                            index++;
                            ConnectionList.Add(new ServerProtocols.ReportInfo.CIPCInfo.Connection(senderport, receiverport));
                        }

                        bool IsSyncConnect = bool.Parse(srg[index]);
                        index++;

                        ServerProtocols.ReportInfo reportinfo = new ServerProtocols.ReportInfo(new ServerProtocols.ReportInfo.CIPCInfo(ClientList, ConnectionList, IsSyncConnect));
                        this.OnReportInfo(reportinfo);
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public void Handle(string data)
        {
            try
            {
                string[] srg = data.Split('\\');
                if (srg.Length == 0)
                {
                    return;
                }

                if (srg[0] == TerminalConnectionSettings.Sender.CIPCTerminal.ToString())
                {
                    if (srg[1] == TerminalCommand.Connect.ToString())
                    {
                        this.OnConnect(new TerminalProtocols.Connect(int.Parse(srg[2]), int.Parse(srg[3])));
                    }
                    else if (srg[1] == TerminalCommand.DisConnect.ToString())
                    {
                        this.OnDisConnect(new TerminalProtocols.DisConnect(int.Parse(srg[2]), int.Parse(srg[3])));
                    }
                    else if (srg[1] == TerminalCommand.Close.ToString())
                    {
                        this.OnClose(new TerminalProtocols.Close());
                    }
                    else if (srg[1] == TerminalCommand.Restart.ToString())
                    {
                        this.OnRestart(new TerminalProtocols.Restart());
                    }
                    else if (srg[1] == TerminalCommand.DemandInfo.ToString())
                    {
                        this.OnDemmandInfo(new TerminalProtocols.DemmandInfo());
                    }
                    else if (srg[1] == TerminalCommand.Undo.ToString())
                    {
                        this.OnUndo(new TerminalProtocols.Undo());
                    }
                    else if (srg[1] == TerminalCommand.Redo.ToString())
                    {
                        this.OnRedo(new TerminalProtocols.Redo());
                    }
                    else if (srg[1] == TerminalCommand.Emergence.ToString())
                    {
                        this.OnEmergenceT(new TerminalProtocols.Emergence());
                    }
                    else if (srg[1] == TerminalCommand.AllDisConnect.ToString())
                    {
                        this.OnAllDisConnect(new TerminalProtocols.AllDisConnect());
                    }
                    else if (srg[1] == TerminalCommand.LoadConnectionFast.ToString())
                    {
                        this.OnLoadConnectionFast(new TerminalProtocols.LoadConnectionFast());
                    }
                    else if (srg[1] == TerminalCommand.SaveConnectionFast.ToString())
                    {
                        this.OnSaveConnectionFast(new TerminalProtocols.SaveConnectionFast());
                    }
                    else if (srg[1] == TerminalCommand.TurnOnSyncConnect.ToString())
                    {
                        this.OnTurnOnSyncConnect(new TerminalProtocols.TurnOnSyncConnect());
                    }
                    else if (srg[1] == TerminalCommand.TurnOffSyncConnect.ToString())
                    {
                        this.OnTurnOffSyncConnect(new TerminalProtocols.TurnOffSyncConnect());
                    }
                    else
                    {
                        return;
                    }
                }
                else if (srg[0] == TerminalConnectionSettings.Sender.CIPCSever.ToString())
                {
                    if (srg[1] == TerminalConnectionSettings.ServerCommand.ReportInfo.ToString())
                    {
                        int index = 2;
                        List<ServerProtocols.ReportInfo.CIPCInfo.Client> ClientList = new List<ServerProtocols.ReportInfo.CIPCInfo.Client>();
                        List<ServerProtocols.ReportInfo.CIPCInfo.Connection> ConnectionList = new List<ServerProtocols.ReportInfo.CIPCInfo.Connection>();

                        int clientlength = int.Parse(srg[index]);
                        index++;

                        for (int i = 0; i < clientlength; i++)
                        {
                            int myport = int.Parse(srg[index]);
                            index++;
                            string name = srg[index];
                            index++;
                            int remoteport = int.Parse(srg[index]);
                            index++;
                            string remoteIP = srg[index];
                            index++;
                            int FPS = int.Parse(srg[index]);
                            index++;
                            ServerProtocols.ReportInfo.CIPCInfo.Client.Mode mode;
                            if (srg[index] == ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Sender.ToString())
                            {
                                mode = ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Sender;
                                index++;
                            }
                            else if (srg[index] == ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Receiver.ToString())
                            {
                                mode = ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Receiver;
                                index++;
                            }
                            else
                            {
                                mode = ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Default;
                                index++;
                            }
                            ClientList.Add(new ServerProtocols.ReportInfo.CIPCInfo.Client(myport, name, remoteport, remoteIP, FPS, mode));
                        }

                        int connectionlength = int.Parse(srg[index]);
                        index++;

                        for (int i = 0; i < connectionlength; i++)
                        {
                            int senderport = int.Parse(srg[index]);
                            index++;
                            int receiverport = int.Parse(srg[index]);
                            index++;
                            ConnectionList.Add(new ServerProtocols.ReportInfo.CIPCInfo.Connection(senderport, receiverport));
                        }

                        bool IsSyncConnect = bool.Parse(srg[index]);
                        index++;

                        ServerProtocols.ReportInfo reportinfo = new ServerProtocols.ReportInfo(new ServerProtocols.ReportInfo.CIPCInfo(ClientList, ConnectionList,IsSyncConnect));
                        this.OnReportInfo(reportinfo);
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }