using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using EQNetwork;
using EQNetwork.Objects;
using EQNetwork.Interfaces;
using EQNetwork.Utility;

namespace EQNetwork.Services
{
    public partial class SessionService : ISessionService
    {
        public EQTask Create(string username, string password, Action<Session, EQException> onComplete)
        {
            return _api.Session_Create(username, password,
                (Session session, EQException ex) => // onComplete
                {
                    if (ex == null)
                    {
                        this.Session = session;
                        onComplete(session, null);
                    }
                    else onComplete(null, ex);
                }
            );
        }

        public EQTask Check(Guid sessionGuid, Action<Session, EQException> onComplete)
        {
            return _api.Session_Check(sessionGuid,
                (Session session, EQException ex) => // onComplete
                {
                    if (ex == null)
                    {
                        this.Session = session;
                        onComplete(session, null);
                    }
                    else onComplete(null, ex);
                }
            );
        }
    }
}
