示例#1
0
        public void BroadCastToAll(Object objrecebido, CollabServerT tEnviada, bool skipItself, String tipocon)
        {
            ArrayList list = (ArrayList)objrecebido;

            Object eventoMouse = list[0];
            String nomeEvento  = (String)list[1];

            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];


                // Console.WriteLine("T:" + aSingleThread.tipocon + " S: " + aSingleThread.nome_sessao);

                //   NOVA MODIFICACAO - olho
                if (skipItself)
                {
                    if ((!aSingleThread.Equals(tEnviada)) && (aSingleThread.tipocon.Equals(tipocon)))
                    {
                        // Console.WriteLine("Evento enviado!");
                        aSingleThread.BroadCastToClient(list);
                    }
                }
                else
                {
                    if ((aSingleThread.tipocon.Equals(tipocon)))
                    {
                        aSingleThread.BroadCastToClient(list);
                    }
                }
            }
        }
示例#2
0
        public ArrayList getLockStatus()
        {
            ArrayList     ret           = new ArrayList();
            CollabServerT aSingleThread = null;
            ArrayList     r;

            String logaJanela = "";

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                r = aSingleThread.resources_locked;

                for (int j = 0; j < r.Count; j++)
                {
                    logaJanela = logaJanela + " usuario:" + aSingleThread.login + " - objeto: " + (String)r[j] + ",";

                    String [] x = { aSingleThread.login, (String)r[j] };

                    ret.Add(x);
                }
            }

            // Toda a vez que solicitarem o status global dos locks vou
            // logar em um arquivo separado

            // this.LogaMsg(logaJanela,2);

            return(ret);
        }
示例#3
0
        public void IniciaServico(int port)
        {
            // Lista de usuários
            String [] x = { "A", "A" };
            userList.Add(x);

            String [] y = { "B", "B" };
            userList.Add(y);



            // IPHostEntry ipHostInfo = Dns.GetHostByName("localhost");
            // IPHostEntry ipHostInfo = Dns.GetHostByAddress(end_ip);

            IPHostEntry ipHostInfo = Dns.GetHostByName(Dns.GetHostName());

            IPEndPoint localEP = new IPEndPoint(ipHostInfo.AddressList[0], port);

            Console.WriteLine("Local address and port: " + localEP.ToString());

            Socket listener = new Socket(localEP.Address.AddressFamily,
                                         SocketType.Stream, ProtocolType.Tcp);

            Thread    t;
            ArrayList ListThread = new ArrayList();

            int i;

            try
            {
                listener.Bind(localEP);
                listener.Listen(10);

                i = 0;

                clientVector = new ArrayList();
                CollabServerT c;

                // A cada nova requisão uma nova Thread é criada
                while (true)
                {
                    c = new CollabServerT(listener.Accept(), this);

                    // Iniciando a Thread do cliente!

                    ThreadStart threadDelegate = new ThreadStart(c.run);
                    tClienteConectado = new Thread(threadDelegate);
                    tClienteConectado.Start();
                }
            }

            catch (Exception e)
            {
                Console.WriteLine("Error:" + e.ToString());
            }
        }
示例#4
0
        public ArrayList IdsSessaoInicial(String nomesessao)
        {
            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                if (aSingleThread.nome_sessao.Equals(nomesessao))
                {
                    return(aSingleThread.ids_inicial);
                }
            }
            return(null);
        }
示例#5
0
        // Obtem o modelo atual da sessão de algum dos participantes
        #region ModeloSessao
        public Object ModeloSessao(String nomesessao)
        {
            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                if (aSingleThread.nome_sessao.Equals(nomesessao))
                {
                    return(aSingleThread.modelo_atual);
                }
            }

            return(null);
        }
示例#6
0
        public bool ExisteSessao(String nomesessao)
        {
            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                if (aSingleThread.nome_sessao.Equals(nomesessao))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#7
0
        // Procurar a cor do telepointer do usuário
        #region getEyeColor()
        public Color getEyeColor(String user)
        {
            Color fColor = Color.Red;

            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                if (user.Equals(aSingleThread.login) && aSingleThread.tipocon.Equals("ARGO"))
                {
                    fColor = this.getColor(aSingleThread.id_pointer);
                }
            }

            return(fColor);
        }
示例#8
0
        // retorna todas os nomes da sesões colaborativas atuais
        #region NomeSessoes

        public ArrayList NomeSessoes()
        {
            CollabServerT aSingleThread = null;

            ArrayList ret_aux     = new ArrayList();
            ArrayList retorno     = new ArrayList();
            String    nome_sessao = "";
            String    user_sessao = "";

            // Neste primeiro loop eu objenho todos os nomes das sessoes
            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                if (!ret_aux.Contains(aSingleThread.nome_sessao) && !aSingleThread.nome_sessao.Equals(""))
                {
                    ret_aux.Add(aSingleThread.nome_sessao);
                }
            }

            // Aqui objeto os usuarios de cada sessao
            for (int i = 0; i < ret_aux.Count; i++)
            {
                nome_sessao = (String)ret_aux[i];
                user_sessao = "";

                for (int j = 0; j < clientVector.Count; j++)
                {
                    aSingleThread = (CollabServerT)clientVector[j];

                    if (aSingleThread.nome_sessao.Equals(nome_sessao) && user_sessao.IndexOf(aSingleThread.login) == -1)
                    {
                        user_sessao = user_sessao + ";" + aSingleThread.login;
                    }
                }
                String [] inserir = { nome_sessao, user_sessao.Substring(1) };

                retorno.Add(inserir);
            }

            return(retorno);
        }
示例#9
0
        public bool CheckLock(String fig, bool remove)
        {
            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count; i++)
            {
                aSingleThread = (CollabServerT)clientVector[i];

                if (aSingleThread.resources_locked.Contains(fig))
                {
                    if (remove)
                    {
                        aSingleThread.resources_locked.Remove(fig);
                    }

                    return(true);
                }
            }
            return(false);
        }
 public void RemoveClient(CollabServerT singleThread)
 {
     clientVector.Remove(singleThread);
 }
        public void IniciaServico(int port)
        {
            // Lista de usuários
             String []x = {"A" ,"A"};
            userList.Add (x);

            String []y = {"B" ,"B"};
            userList.Add (y);

            // IPHostEntry ipHostInfo = Dns.GetHostByName("localhost");
            // IPHostEntry ipHostInfo = Dns.GetHostByAddress(end_ip);

            IPHostEntry ipHostInfo = Dns.GetHostByName(Dns.GetHostName()) ;

            IPEndPoint localEP = new IPEndPoint(ipHostInfo.AddressList[0],port);

            Console.WriteLine("Local address and port: " + localEP.ToString());

            Socket listener = new Socket( localEP.Address.AddressFamily,
                SocketType.Stream, ProtocolType.Tcp );

            Thread t;
            ArrayList ListThread = new ArrayList();

            int i;

            try
            {
                listener.Bind(localEP);
                listener.Listen(10);

                i = 0;

                clientVector = new ArrayList();
                CollabServerT c;

                // A cada nova requisão uma nova Thread é criada
                while (true)
                {
                    c = new CollabServerT (listener.Accept(),this);

                    // Iniciando a Thread do cliente!

                    ThreadStart threadDelegate = new ThreadStart(c.run);
                    tClienteConectado = new Thread(threadDelegate);
                    tClienteConectado .Start();
                }

            }

            catch (Exception e)
            {
                Console.WriteLine("Error:" + e.ToString());

            }
        }
        public void BroadCastToAll(Object objrecebido, CollabServerT tEnviada, bool skipItself,String tipocon)
        {
            ArrayList list = (ArrayList) objrecebido;

            Object eventoMouse = list[0];
            String nomeEvento = (String)list[1];

            CollabServerT aSingleThread = null;

            for (int i = 0; i < clientVector.Count ; i++)
            {
                aSingleThread = (CollabServerT) clientVector[i];

                // Console.WriteLine("T:" + aSingleThread.tipocon + " S: " + aSingleThread.nome_sessao);

               //   NOVA MODIFICACAO - olho
                if(skipItself)
                {
                    if( (!aSingleThread.Equals(tEnviada)) && (aSingleThread.tipocon.Equals(tipocon))   )
                    {
                        // Console.WriteLine("Evento enviado!");
                        aSingleThread.BroadCastToClient(list);
                    }
                }
                else
                {
                    if( (aSingleThread.tipocon.Equals(tipocon))   )
                            aSingleThread.BroadCastToClient(list);

                }
            }
        }
 public void BroadCastToAll(Object objrecebido, CollabServerT tEnviada, bool skipItself)
 {
     this.BroadCastToAll(objrecebido,tEnviada,skipItself,tEnviada.tipocon);
 }
示例#14
0
 public void BroadCastToAll(Object objrecebido, CollabServerT tEnviada, bool skipItself)
 {
     this.BroadCastToAll(objrecebido, tEnviada, skipItself, tEnviada.tipocon);
 }
示例#15
0
 public void RemoveClient(CollabServerT singleThread)
 {
     clientVector.Remove(singleThread);
 }