public override string CreateId(HttpContext context)
        {
            if (!context.Request.Query.ContainsKey("id"))
            {
                return(string.Empty);
            }


            string          id      = context.Request.Query["id"].ToString();
            ClientSessionDM session = ARDirect.Instance.Query <ClientSessionDM>().Where("clientSessionGuid={0}", id).LoadSingle();

            if (session == null)
            {
                return(string.Empty);
            }

            if (this.AndroidSockets.ContainsKey(id))
            {
                return(string.Empty);
            }

            AndroidSocket socket = new AndroidSocket(this, session);

            this.AndroidSockets.Add(id, socket);

            return(id);
        }
Beispiel #2
0
        public async Task <LoginModel> Index(LoginInputModel input)
        {
            var result = new LoginModel();

            if (string.IsNullOrEmpty(input.username) || string.IsNullOrEmpty(input.password))
            {
                result.GenerateError("Неки од података фале!");
                return(result);
            }

            ClientDM client = await ARDirect.Instance.Query <ClientDM>().Where("username={0}", input.username).LoadSingleAsync();

            if (client == null)
            {
                result.GenerateError("Не постоји налог са корисничким именом!");
                return(result);
            }

            if (!DirectPassword.Verify(input.password, client.password))
            {
                result.GenerateError("Погрешна шифра!");
                return(result);
            }

            ClientSessionDM session = new ClientSessionDM()
            {
                clientid = client.ID.Value
            };
            await session.InsertAsync();

            session.WaitID(3);

            result.clientID   = client.ID.Value;
            result.session    = session.clientSessionGuid.ToString();
            result.username   = client.username;
            result.firstName  = client.firstName;
            result.lastName   = client.lastName;
            result.profilePic = client.profilePic;

            this.Notify(Sockets.Dashboard.Models.DashboardModel.FunctionTypes.notifySuccess, $"Korisnik '${client.username}' se ulogovao!");
            AndroidSocketManager.Current.Send(FitAR.Sockets.Models.AndroidSocketMessage.Construct("text", "green", new FitAR.Sockets.Models.AndroidSocketTextMessage()
            {
                text = $"Korisnik '${client.username}' se ulogovao!"
            }));

            return(result);
        }
        public async Task <AnchorResponseModel> Index(AnchorModel input)
        {
            var             db       = ARDirect.Instance;
            var             response = new AnchorResponseModel();
            ClientSessionDM session  = await db.Query <ClientSessionDM>().Where("clientSessionGuid={0}", input.sessionid).LoadSingleAsync();

            if (session == null)
            {
                response.GenerateError("Sesija ne postoji");
                return(response);
            }

            ClientDM client = await db.Query <ClientDM>().Where("clientid={0}", session.clientid).LoadSingleAsync();

            AnchorDM anchor = new AnchorDM()
            {
                clientid        = session.clientid,
                clientsessionid = session.clientSessionID,
                sessionid       = input.anchorid,
                noteText        = input.noteText,
                lat             = input.lat,
                lng             = input.lng
            };
            await anchor.InsertAsync();

            AndroidSocketManager.Current.Send(FitAR.Sockets.Models.AndroidSocketMessage.Construct("text", "green", new FitAR.Sockets.Models.AndroidSocketTextMessage()
            {
                text = $"Korisnik '{client.username}' je postavio poruku '{input.noteText}'."
            }));
            DashboardSocketHandler.Current?.SendToAll(new DashboardModel()
            {
                Function      = DashboardModel.FunctionTypes.notifyInverse,
                RequireReload = false,
                Text          = $"Korisnik '{client.username}' je postavio poruku '{input.noteText}'."
            });;

            return(response);
        }
Beispiel #4
0
 public AndroidSocket(AndroidSocketManager manager, ClientSessionDM session)
 {
     this.manager = manager;
     this.session = session;
     this.client  = ARDirect.Instance.Query <ClientDM>().Where("clientid={0}", session.clientid).LoadSingle();
 }