Ejemplo n.º 1
0
        protected string GetSourceTemplate(string path)
        {
            path = _templatesRoot + "/" + path;

            string sourceTemplate = null;

            UnityMainThreadDispatcher.Instance().EnqueueAndWait(() =>
            {
                try
                {
                    sourceTemplate = ResourceLoader.GetTextFileContent(path);
                }
                catch (ResourceNotFoundException)
                {
                    MiddlewareServer.LogWarning("View not found : " + path);
                }
            });

            if (sourceTemplate == null)
            {
                throw new ViewNotFoundException(path);
            }

            return(sourceTemplate);
        }
Ejemplo n.º 2
0
 public void CerrarConexion()
 {
     if (IsConversacionActiva())
     {
         FinalizarConversacion();
     }
     MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.DESCONECTAR, String.Empty, String.Empty);
 }
        private void StartServer()
        {
            if (_server == null)
            {
                _server = new RemoteInspectorServer((ushort)ServerPort);
            }

            _server.Start();
        }
Ejemplo n.º 4
0
 public bool CrearUsuario(string userName)
 {
     try
     {
         MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.CREAR_USUARIO, userName, String.Empty);
     }
     catch (ExceptionUserAware)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 5
0
 public bool VerUsuariosConectados()
 {
     try
     {
         string response = MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.VER_USUARIOS_CONECTADOS, String.Empty, String.Empty);
         Cliente.SetUsuariosConectados(MiddlewareServer.ArmarListaDeUsuarios(response));
     }
     catch (ExceptionUserAware)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 6
0
 public bool EnviarMsg(string mensaje)
 {
     try
     {
         MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.ENVIO_MSG, mensaje, String.Empty);
         Cliente.AgregarMensajesEnviados(mensaje);
     }
     catch (ExceptionUserAware)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 7
0
 public bool Desloguearse()
 {
     try
     {
         MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.CERRAR_SESION, String.Empty, String.Empty);
         Cliente.DesLoguear();
     }
     catch (ExceptionUserAware)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 8
0
 public bool IniciarChat(int idUser)
 {
     try
     {
         string respuesta      = MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.INICIO_CHAT, idUser.ToString(), String.Empty);
         int    idConversacion = int.Parse(respuesta);
         Cliente.IniciarConversacion(idUser, idConversacion);
     }
     catch (ExceptionUserAware)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 9
0
 public bool FinalizarConversacion()
 {
     try
     {
         int idUsuario = Cliente.GetUsuarioConversando();
         MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.FIN_CHAT, idUsuario.ToString(), String.Empty);
         Cliente.FinalizarConversacion();
     }
     catch (ExceptionUserAware)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 10
0
        public ClienteControlador()
        {
            try
            {
                //Inicio conexion con el servidor
                MiddlewareServer.EstablecerConexionConServidor();

                //Instancio un nuevo cliente
                Cliente = new Cliente();
            }
            catch (SocketException)
            {
                throw new ExceptionServer("Error de conexión con el servidor. Por favor intente más tarde.");
            }
        }
Ejemplo n.º 11
0
 public void RecibirMensajes()
 {
     try
     {
         string         respuesta      = MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.RECIBIR_MENSAJES, String.Empty, String.Empty);
         char[]         separador      = "//>*<'".ToCharArray();
         string[]       respuestaSplit = respuesta.Split(separador);
         IList <string> mensajes       = respuestaSplit.ToList();
         mensajes.RemoveAt(0);
         mensajes = mensajes.Where(r => !String.IsNullOrEmpty(r)).ToList();
         Cliente.AgregarMensajesRecibidos(mensajes);
     }
     catch (ExceptionUserAware)
     {
     }
 }
Ejemplo n.º 12
0
        public bool VerificarSiHayConversacionExistente()
        {
            bool conversacionNueva = false;

            try
            {
                string   respuesta      = MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.IS_CONVERSACION_EXISTENTE, String.Empty, String.Empty);
                string[] respuestaSplit = respuesta.Split(' ');
                int      idUsuario      = int.Parse(respuestaSplit[0]);
                int      idConversacion = int.Parse(respuestaSplit[1]);
                conversacionNueva = Cliente.IniciarConversacion(idUsuario, idConversacion);
            }
            catch (ExceptionUserAware)
            {
                Cliente.FinalizarConversacion();
            }
            return(conversacionNueva);
        }
        public bool HandleRequest(HttpListenerRequest request, HttpListenerResponse response, string relativePath)
        {
            if (request.HttpMethod != "GET")
            {
                return(false);
            }

            if (relativePath == "/")
            {
                return(false);
            }

            var path = _root + relativePath;

            var contentType = GuessContentTypeForPath(path);

            byte[] content = null;

            UnityMainThreadDispatcher.Instance().EnqueueAndWait(() =>
            {
                try
                {
                    content = ResourceLoader.GetBinaryFileContent(path);
                }
                catch (ResourceNotFoundException)
                {
                    MiddlewareServer.LogWarning("Resource not found : " + path);
                }
            });

            if (content == null)
            {
                return(false);
            }

            response.Send(content, contentType);
            return(true);
        }
 private void InitServer()
 {
     _server = new RemoteInspectorServer((ushort)ServerPort);
 }
Ejemplo n.º 15
0
        public static Dictionary <string, object> CreateRemoteView(Component component)
        {
            var result = new Dictionary <string, object>();

            result["self"] = new RemoteReference()
            {
                id   = component.GetInstanceID(),
                name = component.name,
                path = component.transform.FullPath()
            };

            List <RemoteProperty> properties;

            result["properties"] = properties = new List <RemoteProperty>();

            foreach (var fieldInfo in component.GetType()
                     .GetFields(BindingFlags.Instance |
                                BindingFlags.NonPublic |
                                BindingFlags.Public))
            {
                if ((fieldInfo.FieldType.IsSerializable || fieldInfo.FieldType.IsValueType) &&
                    (fieldInfo.IsPublic &&
                     fieldInfo.GetCustomAttributes(typeof(HideInInspector), false).Length == 0 ||
                     !fieldInfo.IsPublic &&
                     fieldInfo.GetCustomAttributes(typeof(SerializeField), false).Length > 0))
                {
                    try
                    {
                        properties.Add(new RemoteProperty()
                        {
                            name     = fieldInfo.Name,
                            type     = fieldInfo.FieldType.FullName,
                            value    = fieldInfo.GetValue(component),
                            writable = true
                        });
                    }
                    catch (TargetInvocationException)
                    {
                    }
                }
            }

            foreach (var propInfo in component.GetType()
                     .GetProperties(BindingFlags.Instance |
                                    BindingFlags.Public))
            {
                if ((propInfo.PropertyType.IsValueType || propInfo.PropertyType.IsSerializable) &&
                    propInfo.CanRead && propInfo.GetGetMethod() != null)
                {
                    try
                    {
                        properties.Add(new RemoteProperty()
                        {
                            name     = propInfo.Name,
                            type     = propInfo.PropertyType.FullName,
                            value    = propInfo.GetGetMethod().Invoke(component, null),
                            writable = propInfo.CanWrite && propInfo.GetSetMethod() != null
                        });
                    }
                    catch (TargetInvocationException e)
                    {
                        MiddlewareServer.LogException(e);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 16
0
        public void VerUsuarios()
        {
            string response = MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.VER_USUARIOS, String.Empty, String.Empty);

            Cliente.Usuarios = MiddlewareServer.ArmarListaDeUsuarios(response);
        }
Ejemplo n.º 17
0
        public void Loguearse(string userName)
        {
            string response = MiddlewareServer.EnviarRequestAlServidor(EnumProtocolo.Codigo.LOGIN, userName, "1234");

            Cliente.SetUsuarioLogueado(new Usuario(userName, int.Parse(response)));
        }