public void OnRegister(IServiceProvider serviceProvider)
        {
            offlineStore = ((StorageManager)serviceProvider.GetService(typeof(StorageManager))).OfflineStorage;
            rosterStore = ((StorageManager)serviceProvider.GetService(typeof(StorageManager))).RosterStorage;
            sender = (IXmppSender)serviceProvider.GetService(typeof(IXmppSender));
            sessionManager = (XmppSessionManager)serviceProvider.GetService(typeof(XmppSessionManager));
            handlerManager = (XmppHandlerManager)serviceProvider.GetService(typeof(XmppHandlerManager));

            sessionManager.SessionAvailable += SessionAvailable;
            sessionManager.SessionUnavailable += SessionUnavailable;
        }
Example #2
0
		public XmppServer()
		{
			StorageManager = new StorageManager();
			userManager = new UserManager(StorageManager);
			AuthManager = new AuthManager();

			streamManager = new XmppStreamManager();
			SessionManager = new XmppSessionManager();

			gateway = new XmppGateway();
			sender = new XmppSender(gateway);

			serviceManager = new XmppServiceManager(this);
			handlerManager = new XmppHandlerManager(streamManager, gateway, sender, this);
		}
Example #3
0
		public override void OnRegister(IServiceProvider serviceProvider)
		{
			sessionManager = (XmppSessionManager)serviceProvider.GetService(typeof(XmppSessionManager));
			xmppSender = (IXmppSender)serviceProvider.GetService(typeof(IXmppSender));
			base.OnRegister(serviceProvider);
		}
Example #4
0
 public void SendPresenceToSignalR(Presence presence, XmppSessionManager sessionManager) 
 {
     try
     {
         var state = SignalRHelper.GetState(presence.Show, presence.Type);
         if (state == SignalRHelper.USER_OFFLINE && sessionManager != null)
         {
             var jidSessions = sessionManager.GetBareJidSessions(presence.From).
                 Where(s => !s.IsSignalRFake && s.Presence.Type != PresenceType.unavailable);
             if (jidSessions.Count() > 0)
             {
                 int priority = jidSessions.First().Priority;
                 var bestSession = jidSessions.First();
                 foreach (var session in jidSessions)
                 {
                     if (session.Priority > priority)
                     {
                         priority = session.Priority;
                         bestSession = session;
                     }
                 }
                 _reverseJabberServiceClient.SendState(bestSession.Presence.From.User.ToLowerInvariant(),
                     SignalRHelper.GetState(bestSession.Presence.Show, bestSession.Presence.Type), -1, bestSession.Presence.From.Server);
                 return;
             }
         }
         _reverseJabberServiceClient.SendState(presence.From.User.ToLowerInvariant(), state, -1, presence.From.Server);
     }
     catch (Exception e)
     {
         _log.ErrorFormat("Can not send to {0} to SignalR: {1} {2}", presence, e.Message, e.StackTrace);
     }
 }
		public override void OnRegister(IServiceProvider serviceProvider)
		{
			storages = (StorageManager)serviceProvider.GetService(typeof(StorageManager));
			sender = (IXmppSender)serviceProvider.GetService(typeof(IXmppSender));
			sessionManager = (XmppSessionManager)serviceProvider.GetService(typeof(XmppSessionManager));
		}
Example #6
0
 public void SendPresenceToSignalR(Presence presence, XmppSessionManager sessionManager) 
 {
     try
     {
         var state = SignalRHelper.GetState(presence.Show, presence.Type);
         if (state == SignalRHelper.USER_OFFLINE && sessionManager != null)
         {
             var session = sessionManager.GetAvailableSession(presence.From.BareJid);
             if (session != null && session.Presence != null)
             {
                 signalrServiceClient.SendState(session.Presence.From.User.ToLowerInvariant(),
                     SignalRHelper.GetState(session.Presence.Show, session.Presence.Type), -1, session.Presence.From.Server);
                 return;
             }
         }
         signalrServiceClient.SendState(presence.From.User.ToLowerInvariant(), state, -1, presence.From.Server);
     }
     catch (Exception e)
     {
         _log.ErrorFormat("Can not send to {0} to SignalR: {1} {2}", presence, e.Message, e.StackTrace);
     }
 }